mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Removed outdated inventory methods
This commit is contained in:
parent
bdb74d4719
commit
1f0fcb119d
@ -39,36 +39,21 @@ public class Item {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void chimaerawing(Player player, Plugin plugin)
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack is = player.getItemInHand();
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == LoadProperties.chimaeraId)
|
||||
int chimaeraID = LoadProperties.chimaeraId;
|
||||
int itemsUsed = LoadProperties.feathersConsumedByChimaeraWing;
|
||||
if(mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == chimaeraID)
|
||||
{
|
||||
if(Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing)
|
||||
if(Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= itemsUsed)
|
||||
{
|
||||
Block derp = player.getLocation().getBlock();
|
||||
int y = derp.getY();
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == LoadProperties.chimaeraId){
|
||||
if(x.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing + 1)
|
||||
{
|
||||
x.setAmount(x.getAmount() - LoadProperties.feathersConsumedByChimaeraWing);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
} else {
|
||||
x.setAmount(0);
|
||||
x.setTypeId(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.setItemInHand(new ItemStack(chimaeraID, is.getAmount() - itemsUsed));
|
||||
|
||||
while(y < 127)
|
||||
{
|
||||
y++;
|
||||
|
@ -48,6 +48,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Item;
|
||||
@ -65,7 +66,6 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
@ -217,6 +217,7 @@ public class mcPlayerListener implements Listener
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
/*
|
||||
* Ability checks
|
||||
@ -256,9 +257,9 @@ public class mcPlayerListener implements Listener
|
||||
if(block != null && mcPermissions.getInstance().herbalism(player) && (block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT || block.getType() == Material.SMOOTH_BRICK) && player.getItemInHand().getType() == Material.SEEDS)
|
||||
{
|
||||
boolean pass = false;
|
||||
if(Herbalism.hasSeeds(player))
|
||||
if(inventory.contains(Material.SEEDS))
|
||||
{
|
||||
Herbalism.removeSeeds(player);
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS, 1));
|
||||
|
||||
if(block.getType() == Material.DIRT || block.getType() == Material.COBBLESTONE || block.getType() == Material.SMOOTH_BRICK)
|
||||
{
|
||||
@ -312,7 +313,7 @@ public class mcPlayerListener implements Listener
|
||||
|
||||
if(player.isSneaking() && mcPermissions.getInstance().taming(player) && (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
if(player.getItemInHand().getType() == Material.BONE && player.getItemInHand().getAmount() > LoadProperties.bonesConsumedByCOTW)
|
||||
if(player.getItemInHand().getType() == Material.BONE && player.getItemInHand().getAmount() >= LoadProperties.bonesConsumedByCOTW)
|
||||
{
|
||||
for(Entity x : player.getNearbyEntities(40, 40, 40))
|
||||
{
|
||||
@ -328,24 +329,6 @@ public class mcPlayerListener implements Listener
|
||||
int bones = player.getItemInHand().getAmount();
|
||||
bones = bones - LoadProperties.bonesConsumedByCOTW;
|
||||
player.setItemInHand(new ItemStack(Material.BONE, bones));
|
||||
// ItemStack[] inventory = player.getInventory().getContents();
|
||||
// for(ItemStack x : inventory){
|
||||
// if(x != null && x.getAmount() > LoadProperties.bonesConsumedByCOTW-1 && x.getType() == Material.BONE){
|
||||
// if(x.getAmount() >= LoadProperties.bonesConsumedByCOTW)
|
||||
// {
|
||||
// x.setAmount(x.getAmount() - LoadProperties.bonesConsumedByCOTW);
|
||||
// player.getInventory().setContents(inventory);
|
||||
// player.updateInventory();
|
||||
// break;
|
||||
// } else {
|
||||
// x.setAmount(0);
|
||||
// x.setTypeId(0);
|
||||
// player.getInventory().setContents(inventory);
|
||||
// player.updateInventory();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
player.sendMessage(mcLocale.getString("m.TamingSummon"));
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -68,12 +70,14 @@ public class Herbalism
|
||||
}
|
||||
|
||||
public static void greenTerra(Player player, Block block){
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean hasSeeds = inventory.contains(Material.SEEDS);
|
||||
if(block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT){
|
||||
if(!hasSeeds(player))
|
||||
if(!hasSeeds)
|
||||
player.sendMessage("You need more seeds to spread Green Terra");
|
||||
if(hasSeeds(player) && block.getType() != Material.WHEAT)
|
||||
if(hasSeeds && block.getType() != Material.WHEAT)
|
||||
{
|
||||
removeSeeds(player);
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS, 1));
|
||||
if(LoadProperties.enableSmoothToMossy && block.getType() == Material.SMOOTH_BRICK)
|
||||
block.setData((byte)1);
|
||||
if(LoadProperties.enableDirtToGrass && block.getType() == Material.DIRT)
|
||||
@ -89,33 +93,6 @@ public class Herbalism
|
||||
return t == 103 || t == 4 || t == 3 || t == 59 || t == 81 || t == 83 || t == 91 || t == 86 || t == 39 || t == 46 || t == 37 || t == 38;
|
||||
}
|
||||
|
||||
public static boolean hasSeeds(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 295){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeSeeds(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 295){
|
||||
if(x.getAmount() == 1){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
} else{
|
||||
x.setAmount(x.getAmount() - 1);
|
||||
player.getInventory().setContents(inventory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void herbalismProcCheck(final Block block, Player player, BlockBreakEvent event, mcMMO plugin)
|
||||
{
|
||||
final PlayerProfile PP = Users.getProfile(player);
|
||||
@ -124,6 +101,8 @@ public class Herbalism
|
||||
Location loc = block.getLocation();
|
||||
ItemStack is = null;
|
||||
Material mat = null;
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean hasSeeds = inventory.contains(Material.SEEDS);
|
||||
|
||||
if(plugin.misc.blockWatchList.contains(block))
|
||||
{
|
||||
@ -144,7 +123,7 @@ public class Herbalism
|
||||
}
|
||||
|
||||
//GREEN THUMB
|
||||
if(hasSeeds(player) && PP.getGreenTerraMode() || hasSeeds(player) && (herbLevel >= 1500 || (Math.random() * 1500 <= herbLevel)))
|
||||
if(hasSeeds && PP.getGreenTerraMode() || hasSeeds && (herbLevel >= 1500 || (Math.random() * 1500 <= herbLevel)))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
m.mcDropItem(loc, is);
|
||||
@ -172,7 +151,7 @@ public class Herbalism
|
||||
}
|
||||
}, 1);
|
||||
|
||||
removeSeeds(player);
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,47 +91,40 @@ public class Mining
|
||||
switch (id){
|
||||
//GLOWSTONE
|
||||
case 89:
|
||||
mat = Material.getMaterial(348);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
item = new ItemStack(348, 1, (byte)0, damage);
|
||||
m.mcDropItems(loc, item, 2);
|
||||
m.mcRandomDropItems(loc, item, 50, 2);
|
||||
break;
|
||||
//REDSTONE
|
||||
case 73:
|
||||
mat = Material.getMaterial(331);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
item = new ItemStack(331, 1, (byte)0, damage);
|
||||
m.mcDropItems(loc, item, 4);
|
||||
m.mcRandomDropItem(loc, item, 50);
|
||||
break;
|
||||
case 74:
|
||||
mat = Material.getMaterial(331);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
item = new ItemStack(331, 1, (byte)0, damage);
|
||||
m.mcDropItems(loc, item, 4);
|
||||
m.mcRandomDropItem(loc, item, 50);
|
||||
break;
|
||||
//LAPIS
|
||||
case 21:
|
||||
mat = Material.getMaterial(351);
|
||||
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
|
||||
item = new ItemStack(351, 1, (byte)0,(byte)0x4);
|
||||
m.mcDropItems(loc, item, 4);
|
||||
m.mcRandomDropItems(loc, item, 50, 4);
|
||||
break;
|
||||
//DIAMOND
|
||||
case 56:
|
||||
mat = Material.getMaterial(264);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
item = new ItemStack(264, 1, (byte)0, damage);
|
||||
m.mcDropItem(loc, item);
|
||||
break;
|
||||
//STONE
|
||||
case 1:
|
||||
mat = Material.getMaterial(4);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
item = new ItemStack(4, 1, (byte)0, damage);
|
||||
m.mcDropItem(loc, item);
|
||||
break;
|
||||
//COAL
|
||||
case 16:
|
||||
mat = Material.getMaterial(263);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
item = new ItemStack(263, 1, (byte)0, damage);
|
||||
m.mcDropItem(loc, item);
|
||||
break;
|
||||
}
|
||||
@ -139,13 +132,10 @@ public class Mining
|
||||
|
||||
public static void blockProcCheck(Block block, Player player)
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
|
||||
if(PP.getSkillLevel(SkillType.MINING) > 1000 || (Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING)))
|
||||
{
|
||||
if(skillLevel > 1000 || (Math.random() * 1000 <= skillLevel))
|
||||
blockProcSimulate(block, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static void miningBlockCheck(Player player, Block block, mcMMO plugin)
|
||||
|
@ -56,22 +56,6 @@ public class Skills
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean hasArrows(Player player){
|
||||
for(ItemStack x : player.getInventory().getContents()){
|
||||
if (x.getTypeId() == 262){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void addArrows(Player player){
|
||||
for(ItemStack x : player.getInventory().getContents()){
|
||||
if (x.getTypeId() == 262){
|
||||
x.setAmount(x.getAmount() + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int calculateTimeLeft(Player player, long deactivatedTimeStamp, int cooldown)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user