mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Update ItemStack reference to getTypeId()
This commit is contained in:
parent
bd5fd2980f
commit
503d39ee55
8 changed files with 33 additions and 32 deletions
|
@ -38,8 +38,6 @@ public class EssentialsPlayerListener implements Listener
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private static final int AIR = Material.AIR.getId();
|
|
||||||
private static final int BED = Material.BED_BLOCK.getId();
|
|
||||||
|
|
||||||
public EssentialsPlayerListener(final IEssentials parent)
|
public EssentialsPlayerListener(final IEssentials parent)
|
||||||
{
|
{
|
||||||
|
@ -471,7 +469,7 @@ public class EssentialsPlayerListener implements Listener
|
||||||
switch (event.getAction())
|
switch (event.getAction())
|
||||||
{
|
{
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == BED && ess.getSettings().getUpdateBedAtDaytime())
|
if (!event.isCancelled() && event.getClickedBlock().getType() == Material.BED_BLOCK && ess.getSettings().getUpdateBedAtDaytime())
|
||||||
{
|
{
|
||||||
User player = ess.getUser(event.getPlayer());
|
User player = ess.getUser(event.getPlayer());
|
||||||
if (player.isAuthorized("essentials.sethome.bed"))
|
if (player.isAuthorized("essentials.sethome.bed"))
|
||||||
|
@ -492,7 +490,7 @@ public class EssentialsPlayerListener implements Listener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
if (event.getItem() != null && event.getItem().getTypeId() != AIR)
|
if (event.getItem() != null && event.getItem().getType() != Material.AIR)
|
||||||
{
|
{
|
||||||
final User user = ess.getUser(event.getPlayer());
|
final User user = ess.getUser(event.getPlayer());
|
||||||
user.updateActivity(true);
|
user.updateActivity(true);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.earth2me.essentials.utils.DateUtil;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@ -187,7 +188,7 @@ public class Kit
|
||||||
final String[] parts = kitItem.split(" +");
|
final String[] parts = kitItem.split(" +");
|
||||||
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
|
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
|
||||||
|
|
||||||
if (parseStack.getTypeId() == 0) {
|
if (parseStack.getType() == Material.AIR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.craftbukkit;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ public final class InventoryWorkaround
|
||||||
for (int i = 0; i < combined.length; i++)
|
for (int i = 0; i < combined.length; i++)
|
||||||
{
|
{
|
||||||
final ItemStack item = combined[i];
|
final ItemStack item = combined[i];
|
||||||
if (item == null || item.getTypeId() == 0)
|
if (item == null || item.getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,7 @@ public class EssentialsSign
|
||||||
}
|
}
|
||||||
final ItemStack item = getItemStack(sign.getLine(itemIndex), 1, ess);
|
final ItemStack item = getItemStack(sign.getLine(itemIndex), 1, ess);
|
||||||
final int amount = Math.min(getIntegerPositive(sign.getLine(amountIndex)), item.getType().getMaxStackSize() * player.getInventory().getSize());
|
final int amount = Math.min(getIntegerPositive(sign.getLine(amountIndex)), item.getType().getMaxStackSize() * player.getInventory().getSize());
|
||||||
if (item.getTypeId() == 0 || amount < 1)
|
if (item.getType() == Material.AIR || amount < 1)
|
||||||
{
|
{
|
||||||
throw new SignException(_("moreThanZero"));
|
throw new SignException(_("moreThanZero"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ public class SignBlockListener implements Listener
|
||||||
{
|
{
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private final static Logger LOGGER = Logger.getLogger("Minecraft");
|
private final static Logger LOGGER = Logger.getLogger("Minecraft");
|
||||||
private final static int WALL_SIGN = Material.WALL_SIGN.getId();
|
private final static Material WALL_SIGN = Material.WALL_SIGN;
|
||||||
private final static int SIGN_POST = Material.SIGN_POST.getId();
|
private final static Material SIGN_POST = Material.SIGN_POST;
|
||||||
|
|
||||||
public SignBlockListener(IEssentials ess)
|
public SignBlockListener(IEssentials ess)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ public class SignBlockListener implements Listener
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int mat = block.getTypeId();
|
final Material mat = block.getType();
|
||||||
if (mat == SIGN_POST || mat == WALL_SIGN)
|
if (mat == SIGN_POST || mat == WALL_SIGN)
|
||||||
{
|
{
|
||||||
final Sign csign = (Sign)block.getState();
|
final Sign csign = (Sign)block.getState();
|
||||||
|
@ -139,16 +139,16 @@ public class SignBlockListener implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
final Block against = event.getBlockAgainst();
|
final Block against = event.getBlockAgainst();
|
||||||
if ((against.getTypeId() == WALL_SIGN
|
if ((against.getType() == WALL_SIGN
|
||||||
|| against.getTypeId() == SIGN_POST)
|
|| against.getType() == SIGN_POST)
|
||||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against)))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (block.getTypeId() == WALL_SIGN
|
if (block.getType() == WALL_SIGN
|
||||||
|| block.getTypeId() == SIGN_POST)
|
|| block.getType() == SIGN_POST)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,8 @@ public class SignBlockListener implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (((block.getTypeId() == WALL_SIGN
|
if (((block.getType() == WALL_SIGN
|
||||||
|| block.getTypeId() == SIGN_POST)
|
|| block.getType() == SIGN_POST)
|
||||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
|
@ -202,8 +202,8 @@ public class SignBlockListener implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (((block.getTypeId() == WALL_SIGN
|
if (((block.getType() == WALL_SIGN
|
||||||
|| block.getTypeId() == SIGN_POST)
|
|| block.getType() == SIGN_POST)
|
||||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
|
@ -232,8 +232,8 @@ public class SignBlockListener implements Listener
|
||||||
|
|
||||||
for (Block block : event.getBlocks())
|
for (Block block : event.getBlocks())
|
||||||
{
|
{
|
||||||
if (((block.getTypeId() == WALL_SIGN
|
if (((block.getType() == WALL_SIGN
|
||||||
|| block.getTypeId() == SIGN_POST)
|
|| block.getType() == SIGN_POST)
|
||||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
|
@ -264,8 +264,8 @@ public class SignBlockListener implements Listener
|
||||||
if (event.isSticky())
|
if (event.isSticky())
|
||||||
{
|
{
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (((block.getTypeId() == WALL_SIGN
|
if (((block.getType() == WALL_SIGN
|
||||||
|| block.getTypeId() == SIGN_POST)
|
|| block.getType() == SIGN_POST)
|
||||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class SignEntityListener implements Listener
|
||||||
|
|
||||||
for (Block block : event.blockList())
|
for (Block block : event.blockList())
|
||||||
{
|
{
|
||||||
if (((block.getTypeId() == Material.WALL_SIGN.getId()
|
if (((block.getType() == Material.WALL_SIGN
|
||||||
|| block.getTypeId() == Material.SIGN_POST.getId())
|
|| block.getType() == Material.SIGN_POST)
|
||||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
|
@ -59,8 +59,8 @@ public class SignEntityListener implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (((block.getTypeId() == Material.WALL_SIGN.getId()
|
if (((block.getType() == Material.WALL_SIGN
|
||||||
|| block.getTypeId() == Material.SIGN_POST.getId())
|
|| block.getType() == Material.SIGN_POST)
|
||||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class SignPlayerListener implements Listener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int mat = block.getTypeId();
|
final Material mat = block.getType();
|
||||||
if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId())
|
if (mat == Material.SIGN_POST || mat == Material.WALL_SIGN)
|
||||||
{
|
{
|
||||||
final String csign = ((Sign)block.getState()).getLine(0);
|
final String csign = ((Sign)block.getState()).getLine(0);
|
||||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.earth2me.essentials.Trade.OverflowType;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
//TODO: TL exceptions
|
//TODO: TL exceptions
|
||||||
|
@ -102,7 +103,7 @@ public class SignTrade extends EssentialsSign
|
||||||
{
|
{
|
||||||
final Trade trade = getTrade(sign, 2, AmountType.COST, false, ess);
|
final Trade trade = getTrade(sign, 2, AmountType.COST, false, ess);
|
||||||
if (trade.getItemStack() != null && player.getItemInHand() != null
|
if (trade.getItemStack() != null && player.getItemInHand() != null
|
||||||
&& trade.getItemStack().getTypeId() == player.getItemInHand().getTypeId()
|
&& trade.getItemStack().getType() == player.getItemInHand().getType()
|
||||||
&& trade.getItemStack().getDurability() == player.getItemInHand().getDurability()
|
&& trade.getItemStack().getDurability() == player.getItemInHand().getDurability()
|
||||||
&& trade.getItemStack().getEnchantments().equals(player.getItemInHand().getEnchantments()))
|
&& trade.getItemStack().getEnchantments().equals(player.getItemInHand().getEnchantments()))
|
||||||
{
|
{
|
||||||
|
@ -212,7 +213,7 @@ public class SignTrade extends EssentialsSign
|
||||||
throw new SignException(_("moreThanZero"));
|
throw new SignException(_("moreThanZero"));
|
||||||
}
|
}
|
||||||
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp"))
|
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp"))
|
||||||
&& getItemStack(split[1], amount, ess).getTypeId() == 0)
|
&& getItemStack(split[1], amount, ess).getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
throw new SignException(_("moreThanZero"));
|
throw new SignException(_("moreThanZero"));
|
||||||
}
|
}
|
||||||
|
@ -235,7 +236,7 @@ public class SignTrade extends EssentialsSign
|
||||||
throw new SignException(_("moreThanZero"));
|
throw new SignException(_("moreThanZero"));
|
||||||
}
|
}
|
||||||
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp"))
|
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp"))
|
||||||
&& getItemStack(split[1], stackamount, ess).getTypeId() == 0)
|
&& getItemStack(split[1], stackamount, ess).getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
throw new SignException(_("moreThanZero"));
|
throw new SignException(_("moreThanZero"));
|
||||||
}
|
}
|
||||||
|
@ -296,7 +297,7 @@ public class SignTrade extends EssentialsSign
|
||||||
{
|
{
|
||||||
amount -= amount % stackamount;
|
amount -= amount % stackamount;
|
||||||
}
|
}
|
||||||
if (notEmpty && (amount < 1 || stackamount < 1 || item.getTypeId() == 0 || amount < stackamount))
|
if (notEmpty && (amount < 1 || stackamount < 1 || item.getType() == Material.AIR || amount < stackamount))
|
||||||
{
|
{
|
||||||
throw new SignException(_("tradeSignEmpty"));
|
throw new SignException(_("tradeSignEmpty"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue