();
- for (int x=Math.min(a.getBlockX(), b.getBlockX()) ; x<=Math.max(a.getBlockX(), b.getBlockX()) ; x++)
- for (int y=Math.min(a.getBlockY(), b.getBlockY()) ; y<=Math.max(a.getBlockY(), b.getBlockY()) ; y++)
- for (int z=Math.min(a.getBlockZ(), b.getBlockZ()) ; z<=Math.max(a.getBlockZ(), b.getBlockZ()) ; z++)
+ for (int x = Math.min(a.getBlockX(), b.getBlockX()); x <= Math.max(a.getBlockX(), b.getBlockX()); x++)
+ for (int y = Math.min(a.getBlockY(), b.getBlockY()); y <= Math.max(a.getBlockY(), b.getBlockY()); y++)
+ for (int z = Math.min(a.getBlockZ(), b.getBlockZ()); z <= Math.max(a.getBlockZ(), b.getBlockZ()); z++)
{
- Block block = a.getWorld().getBlockAt(x,y,z);
+ Block block = a.getWorld().getBlockAt(x, y, z);
- if(ignoreAir)
+ if (ignoreAir)
{
- if (block.getType() != Material.AIR)
- blocks.add(block);
+ if (block.getType() != Material.AIR) blocks.add(block);
}
- else blocks.add(block);
+ else
+ blocks.add(block);
}
-
+
return blocks;
}
public static int getStepSoundId(Block block)
{
- if (block.getTypeId() != 35 && block.getTypeId() != 159 && block.getTypeId() != 160)
- return block.getTypeId();
+ if (block.getTypeId() != 35 && block.getTypeId() != 159 && block.getTypeId() != 160) return block.getTypeId();
switch (block.getData())
{
- case 0:
- return block.getTypeId();
- case 1:
- return 172;
- case 2:
- return 87;
- case 3:
- return 79;
- case 4:
- return 41;
- case 5:
- return 133;
- case 6:
- return 45;
- case 7:
- return 16;
- case 8:
- return 13;
- case 9:
- return 56;
- case 10:
- return 110;
- case 11:
- return 22;
- case 12:
- return 3;
- case 13:
- return 31;
- case 14:
- return 152;
- case 15:
- return 173;
-
- default:
- return block.getTypeId();
+ case 0:
+ return block.getTypeId();
+ case 1:
+ return 172;
+ case 2:
+ return 87;
+ case 3:
+ return 79;
+ case 4:
+ return 41;
+ case 5:
+ return 133;
+ case 6:
+ return 45;
+ case 7:
+ return 16;
+ case 8:
+ return 13;
+ case 9:
+ return 56;
+ case 10:
+ return 110;
+ case 11:
+ return 22;
+ case 12:
+ return 3;
+ case 13:
+ return 31;
+ case 14:
+ return 152;
+ case 15:
+ return 173;
+
+ default:
+ return block.getTypeId();
}
}
+
+ /**
+ * The location specified is the location of the foot block of the bed.
+ *
+ * ex:
+ *
+ * placeBed(location[0,0,0], NORTH);
+ *
+ * will result in two blocks appearing, at location[0,0,0](foot block) and
+ * location[0,0,-1](head block (pillow))
+ *
+ * allowFloating defines whether or not the bed is allowed to float (over
+ * water, lava, air, and anything other blocks that do not have bounds)
+ *
+ * if force is set to true, then the bed will be placed even if there are
+ * blocks obstructing it, on the other hand, if force is false, then the bed
+ * will only be placed if there is air in the location specified.
+ */
+ public static boolean placeBed(Location location, BlockFace direction, boolean allowFloating, boolean force)
+ {
+ if (!horizontals.contains(direction))
+ {
+ return false;
+ }
+
+ if (location == null)
+ {
+ return false;
+ }
+
+ if (location.getY() <= 0)
+ {
+ return false;
+ }
+
+ if (!allowFloating && UtilItem.isBoundless(location.getBlock().getRelative(BlockFace.DOWN).getType()))
+ {
+ return false;
+ }
+
+ BlockState head = location.getBlock().getRelative(direction).getState();
+ BlockState foot = location.getBlock().getState();
+
+ if (!force && (!UtilItem.isBoundless(head.getType()) || !UtilItem.isBoundless(foot.getType())))
+ {
+ return false;
+ }
+
+ System.out.println("<-bed-> head & foot are air");
+
+ head.setType(Material.BED_BLOCK);
+ foot.setType(Material.BED_BLOCK);
+
+ Bed bedHead = (Bed) head.getData();
+ Bed bedFoot = (Bed) foot.getData();
+
+ bedHead.setHeadOfBed(true);
+ bedFoot.setHeadOfBed(false);
+
+ bedHead.setFacingDirection(direction);
+ bedFoot.setFacingDirection(direction);
+
+ head.setData(bedHead);
+ foot.setData(bedFoot);
+ head.update(true, false);
+ foot.update(true, false);
+
+ System.out.println("<-bed-> alls guude");
+
+ return head.getBlock().getType().equals(Material.BED_BLOCK) && foot.getBlock().getType().equals(Material.BED_BLOCK);
+ }
+
+ public static boolean deleteBed(Location loc)
+ {
+ if (loc == null)
+ {
+ return false;
+ }
+
+ if (loc.getY() <= 0)
+ {
+ return false;
+ }
+
+ if (!loc.getBlock().getType().equals(Material.BED_BLOCK))
+ {
+ return false;
+ }
+
+ BlockState head = getBedHead(loc.getBlock()).getState();
+ BlockState foot = getBedFoot(loc.getBlock()).getState();
+
+ head.setType(Material.AIR);
+ head.setRawData((byte) 0);
+
+ foot.setType(Material.AIR);
+ foot.setRawData((byte) 0);
+
+ return head.update(true, false) && foot.update(true, false);
+ }
+
+ private static Block getBedHead(Block bed)
+ {
+ if (bed == null)
+ {
+ return null;
+ }
+
+ if (!bed.getType().equals(Material.BED_BLOCK))
+ {
+ return null;
+ }
+
+ if (getBed(bed).isHeadOfBed())
+ {
+ return bed;
+ }
+ else
+ {
+ return bed.getRelative(getBed(bed).getFacing()).getType().equals(Material.BED_BLOCK) ? bed.getRelative(getBed(bed).getFacing()) : null;
+ }
+ }
+
+ private static Block getBedFoot(Block bed)
+ {
+ if (bed == null)
+ {
+ return null;
+ }
+
+ if (!bed.getType().equals(Material.BED_BLOCK))
+ {
+ return null;
+ }
+
+ if (!getBed(bed).isHeadOfBed())
+ {
+ return bed;
+ }
+ else
+ {
+ return bed.getRelative(getBed(bed).getFacing().getOppositeFace()).getType().equals(Material.BED_BLOCK) ? bed.getRelative(getBed(bed).getFacing().getOppositeFace()) : null;
+ }
+ }
+
+ private static Bed getBed(Block bed)
+ {
+ if (bed == null)
+ {
+ return null;
+ }
+
+ if (!bed.getType().equals(Material.BED_BLOCK))
+ {
+ return null;
+ }
+
+ return (Bed) bed.getState().getData();
+ }
+
+ public static boolean isValidBed(Location bed)
+ {
+ if (bed == null)
+ {
+ return false;
+ }
+
+ if (bed.getY() <= 0)
+ {
+ return false;
+ }
+
+ if (!bed.getBlock().getType().equals(Material.BED_BLOCK))
+ {
+ return false;
+ }
+
+ return getBedHead(bed.getBlock()) != null && getBedFoot(bed.getBlock()) != null;
+ }
+
+ public static HashSet findConnectedBlocks(Block block, HashSet blocks, int limit)
+ {
+ if (blocks == null)
+ blocks = new HashSet();
+
+ //This is incase you recursively check an entire MC world
+ if (blocks.size() >= limit)
+ return blocks;
+
+ //Mark current node as searched
+ blocks.add(block);
+
+ //Search the node
+ for (Block neighbour : UtilBlock.getSurrounding(block, false))
+ {
+ if (neighbour.getType() == Material.AIR)
+ continue;
+
+ //If neighbour hasn't been searched, recursively search it!
+ if (!blocks.contains(neighbour))
+ findConnectedBlocks(neighbour, blocks, limit);
+ }
+
+ return blocks;
+ }
+
+ public static ArrayList blockToInventoryItemStacks(Block block)
+ {
+ ItemStack itemStack = new ItemStack(block.getType(), 1, block.getData());
+ ArrayList itemStacks = new ArrayList();
+ itemStacks.add(itemStack);
+
+ switch (block.getType())
+ {
+ case SAPLING:
+ itemStack.setDurability((short) 0);
+ break;
+ case WATER:
+ itemStack.setType(Material.WATER_BUCKET);
+ itemStack.setDurability((short) 0);
+ break;
+ case STATIONARY_WATER:
+ itemStack.setType(Material.WATER_BUCKET);
+ itemStack.setDurability((short) 0);
+ break;
+ case LAVA:
+ itemStack.setType(Material.LAVA_BUCKET);
+ itemStack.setDurability((short) 0);
+ break;
+ case STATIONARY_LAVA:
+ itemStack.setType(Material.LAVA_BUCKET);
+ itemStack.setDurability((short) 0);
+ break;
+ case LOG:
+ itemStack.setDurability((short) (itemStack.getDurability() % 4));
+ break;
+ case LEAVES:
+ itemStack.setDurability((short) (itemStack.getDurability() % 4));
+ break;
+ case DISPENSER:
+ itemStack.setDurability((short) 0);
+
+ Dispenser dispenser = (Dispenser) block.getState();
+
+ for (ItemStack is : dispenser.getInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case BED_BLOCK:
+ itemStack.setType(Material.BED);
+ itemStack.setDurability((short) 0);
+ break;
+ case POWERED_RAIL:
+ itemStack.setDurability((short) 0);
+ break;
+ case DETECTOR_RAIL:
+ itemStack.setDurability((short) 0);
+ break;
+ case PISTON_STICKY_BASE:
+ itemStack.setDurability((short) 0);
+ break;
+ case PISTON_BASE:
+ itemStack.setDurability((short) 0);
+ break;
+ case PISTON_EXTENSION:
+ itemStack.setType(Material.AIR);
+ itemStack.setDurability((short) 0);
+ break;
+ case PISTON_MOVING_PIECE:
+ itemStack.setType(Material.AIR);
+ itemStack.setDurability((short) 0);
+ break;
+ case DOUBLE_STEP:
+ itemStack.setType(Material.STEP);
+ itemStack.setAmount(2);
+ break;
+ case STEP:
+ itemStack.setDurability((short) (itemStack.getDurability() % 8));
+ break;
+ case TORCH:
+ itemStack.setDurability((short) 0);
+ break;
+ case FIRE:
+ itemStack.setType(Material.FIREBALL);
+ itemStack.setDurability((short) 0);
+ break;
+ case WOOD_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case CHEST:
+ itemStack.setDurability((short) 0);
+
+ Chest chest = (Chest) block.getState();
+
+ for (ItemStack is : chest.getBlockInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case REDSTONE_WIRE:
+ itemStack.setType(Material.REDSTONE);
+ itemStack.setDurability((short) 0);
+ break;
+ case CROPS:
+ itemStack.setType(Material.SEEDS);
+ itemStack.setDurability((short) 0);
+ break;
+ case SOIL:
+ itemStack.setType(Material.DIRT);
+ itemStack.setDurability((short) 0);
+ break;
+ case FURNACE:
+ itemStack.setDurability((short) 0);
+
+ Furnace furnace = (Furnace) block.getState();
+
+ for (ItemStack is : furnace.getInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case BURNING_FURNACE:
+ itemStack.setType(Material.FURNACE);
+ itemStack.setDurability((short) 0);
+
+ Furnace burningFurnace = (Furnace) block.getState();
+
+ for (ItemStack is : burningFurnace.getInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case SIGN_POST:
+ itemStack.setType(Material.SIGN);
+ itemStack.setDurability((short) 0);
+ break;
+ case WOODEN_DOOR:
+ itemStack.setType(Material.WOOD_DOOR);
+ itemStack.setDurability((short) 0);
+ break;
+ case LADDER:
+ itemStack.setDurability((short) 0);
+ break;
+ case RAILS:
+ itemStack.setDurability((short) 0);
+ break;
+ case COBBLESTONE_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case WALL_SIGN:
+ itemStack.setType(Material.SIGN);
+ itemStack.setDurability((short) 0);
+ break;
+ case LEVER:
+ itemStack.setDurability((short) 0);
+ break;
+ case STONE_PLATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case IRON_DOOR_BLOCK:
+ itemStack.setType(Material.IRON_DOOR);
+ itemStack.setDurability((short) 0);
+ break;
+ case WOOD_PLATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case GLOWING_REDSTONE_ORE:
+ itemStack.setType(Material.REDSTONE_ORE);
+ break;
+ case REDSTONE_TORCH_OFF:
+ itemStack.setType(Material.REDSTONE_TORCH_ON);
+ itemStack.setDurability((short) 0);
+ break;
+ case REDSTONE_TORCH_ON:
+ itemStack.setDurability((short) 0);
+ break;
+ case STONE_BUTTON:
+ itemStack.setDurability((short) 0);
+ break;
+ case SNOW:
+ itemStack.setAmount(1 + itemStack.getDurability());
+ itemStack.setDurability((short) 0);
+ break;
+ case CACTUS:
+ itemStack.setDurability((short) 0);
+ break;
+ case SUGAR_CANE_BLOCK:
+ itemStack.setType(Material.SUGAR_CANE);
+ itemStack.setDurability((short) 0);
+ break;
+ case JUKEBOX:
+ itemStack.setDurability((short) 0);
+
+ Jukebox jukebox = (Jukebox) block.getState();
+
+ if (jukebox.getPlaying() != Material.AIR)
+ itemStacks.add(new ItemStack(jukebox.getPlaying()));
+
+ break;
+ case PORTAL:
+ itemStack.setType(Material.AIR);
+ itemStack.setDurability((short) 0);
+ break;
+ case CAKE_BLOCK:
+ itemStack.setType(Material.CAKE);
+ itemStack.setDurability((short) 0);
+ break;
+ case DIODE_BLOCK_OFF:
+ itemStack.setType(Material.DIODE);
+ itemStack.setDurability((short) 0);
+ break;
+ case DIODE_BLOCK_ON:
+ itemStack.setType(Material.DIODE);
+ itemStack.setDurability((short) 0);
+ break;
+ case TRAP_DOOR:
+ itemStack.setDurability((short) 0);
+ break;
+ case HUGE_MUSHROOM_1:
+ itemStack.setDurability((short) 0);
+ break;
+ case HUGE_MUSHROOM_2:
+ itemStack.setDurability((short) 0);
+ break;
+ case PUMPKIN_STEM:
+ itemStack.setType(Material.PUMPKIN_SEEDS);
+ itemStack.setDurability((short) 0);
+ break;
+ case MELON_STEM:
+ itemStack.setType(Material.MELON_SEEDS);
+ itemStack.setDurability((short) 0);
+ break;
+ case VINE:
+ itemStack.setDurability((short) 0);
+ break;
+ case FENCE_GATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case BRICK_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case SMOOTH_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case NETHER_BRICK_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case NETHER_WARTS:
+ itemStack.setType(Material.NETHER_STALK);
+ itemStack.setDurability((short) 0);
+ break;
+ case BREWING_STAND:
+ itemStack.setType(Material.BREWING_STAND_ITEM);
+ itemStack.setDurability((short) 0);
+
+ BrewingStand brewingStand = (BrewingStand) block.getState();
+
+ for (ItemStack is : brewingStand.getInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case CAULDRON:
+ itemStack.setType(Material.CAULDRON_ITEM);
+ itemStack.setDurability((short) 0);
+
+ if (block.getData() != 0)
+ itemStacks.add(new ItemStack(Material.WATER_BUCKET));
+
+ break;
+ case ENDER_PORTAL:
+ itemStack.setType(Material.AIR);
+ itemStack.setDurability((short) 0);
+ break;
+ case ENDER_PORTAL_FRAME:
+ itemStack.setDurability((short) 0);
+
+ if ((block.getData() & 0x4) != 0)
+ itemStacks.add(new ItemStack(Material.EYE_OF_ENDER));
+
+ break;
+ case REDSTONE_LAMP_ON:
+ itemStack.setType(Material.REDSTONE_LAMP_OFF);
+ break;
+ case WOOD_DOUBLE_STEP:
+ itemStack.setType(Material.WOOD_STEP);
+ itemStack.setAmount(2);
+ break;
+ case WOOD_STEP:
+ itemStack.setDurability((short) (itemStack.getDurability() % 8));
+ break;
+ case COCOA:
+ itemStack.setType(Material.INK_SACK);
+ itemStack.setDurability((short) 3);
+ break;
+ case SANDSTONE_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case ENDER_CHEST:
+ itemStack.setDurability((short) 0);
+ break;
+ case TRIPWIRE_HOOK:
+ itemStack.setDurability((short) 0);
+ break;
+ case TRIPWIRE:
+ itemStack.setType(Material.STRING);
+ itemStack.setDurability((short) 0);
+ break;
+ case SPRUCE_WOOD_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case BIRCH_WOOD_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case JUNGLE_WOOD_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case COMMAND:
+ itemStack.setDurability((short) 0);
+ break;
+ case FLOWER_POT:
+ itemStack.setType(Material.FLOWER_POT_ITEM);
+ itemStack.setDurability((short) 0);
+
+ //The FlowerPot class is outdated and doesn't work so we do some NBT checking
+ TileEntityFlowerPot tefp = (TileEntityFlowerPot) ((CraftWorld) block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
+
+ NBTTagCompound c = new NBTTagCompound();
+ tefp.b(c);
+
+ ItemStack blockInPot = new ItemStack(Material.AIR);
+
+ if (c.hasKey("Item"))
+ {
+ MinecraftKey mk = new MinecraftKey(c.getString("Item"));
+ blockInPot = CraftItemStack.asNewCraftStack(Item.REGISTRY.get(mk));
+ }
+
+ if (c.hasKey("Data"))
+ blockInPot.setDurability(c.getShort("Data"));
+
+ if (blockInPot.getType() != Material.AIR)
+ itemStacks.add(blockInPot);
+
+ break;
+ case CARROT:
+ itemStack.setType(Material.CARROT_ITEM);
+ itemStack.setDurability((short) 0);
+ break;
+ case POTATO:
+ itemStack.setType(Material.POTATO_ITEM);
+ itemStack.setDurability((short) 0);
+ break;
+ case WOOD_BUTTON:
+ itemStack.setDurability((short) 0);
+ break;
+ case SKULL:
+ itemStack.setType(Material.SKULL_ITEM);
+
+ Skull skull = (Skull) block.getState();
+ itemStack.setDurability((short) skull.getSkullType().ordinal());
+
+ if (skull.getSkullType() == SkullType.PLAYER && skull.hasOwner())
+ {
+ SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
+ skullMeta.setOwner(skull.getOwner());
+ itemStack.setItemMeta(skullMeta);
+ }
+
+ break;
+ case TRAPPED_CHEST:
+ itemStack.setDurability((short) 0);
+
+ Chest trappedChest = (Chest) block.getState();
+
+ for (ItemStack is : trappedChest.getBlockInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case GOLD_PLATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case IRON_PLATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case REDSTONE_COMPARATOR_OFF:
+ itemStack.setType(Material.REDSTONE_COMPARATOR);
+ itemStack.setDurability((short) 0);
+ break;
+ case REDSTONE_COMPARATOR_ON:
+ itemStack.setType(Material.REDSTONE_COMPARATOR);
+ itemStack.setDurability((short) 0);
+ break;
+ case DAYLIGHT_DETECTOR:
+ itemStack.setDurability((short) 0);
+ break;
+ case HOPPER:
+ itemStack.setDurability((short) 0);
+
+ Hopper hopper = (Hopper) block.getState();
+
+ for (ItemStack is : hopper.getInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case QUARTZ_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case ACTIVATOR_RAIL:
+ itemStack.setDurability((short) 0);
+ break;
+ case DROPPER:
+ itemStack.setDurability((short) 0);
+
+ Dropper dropper = (Dropper) block.getState();
+
+ for (ItemStack is : dropper.getInventory().getContents())
+ {
+ if (is == null)
+ continue;
+
+ itemStacks.add(is);
+ }
+
+ break;
+ case LEAVES_2:
+ itemStack.setDurability((short) (itemStack.getDurability() % 4));
+ break;
+ case LOG_2:
+ itemStack.setDurability((short) (itemStack.getDurability() % 4));
+ break;
+ case ACACIA_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case DARK_OAK_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case IRON_TRAPDOOR:
+ itemStack.setDurability((short) 0);
+ break;
+ case HAY_BLOCK:
+ itemStack.setDurability((short) 0);
+ break;
+ case STANDING_BANNER:
+ itemStack.setType(Material.BANNER);
+
+ Banner banner = (Banner) block.getState();
+ itemStack.setDurability(banner.getBaseColor().getDyeData());
+
+ BannerMeta bannerMeta = (BannerMeta) itemStack.getItemMeta();
+ bannerMeta.setBaseColor(bannerMeta.getBaseColor());
+ bannerMeta.setPatterns(banner.getPatterns());
+ itemStack.setItemMeta(bannerMeta);
+
+ break;
+ case WALL_BANNER:
+ itemStack.setType(Material.BANNER);
+
+ Banner wallBanner = (Banner) block.getState();
+ itemStack.setDurability(wallBanner.getBaseColor().getDyeData());
+
+ BannerMeta wallBannerMeta = (BannerMeta) itemStack.getItemMeta();
+ wallBannerMeta.setBaseColor(wallBannerMeta.getBaseColor());
+ wallBannerMeta.setPatterns(wallBanner.getPatterns());
+ itemStack.setItemMeta(wallBannerMeta);
+
+ break;
+ case DAYLIGHT_DETECTOR_INVERTED:
+ itemStack.setType(Material.DAYLIGHT_DETECTOR);
+ itemStack.setDurability((short) 0);
+ break;
+ case RED_SANDSTONE_STAIRS:
+ itemStack.setDurability((short) 0);
+ break;
+ case DOUBLE_STONE_SLAB2:
+ itemStack.setType(Material.STONE_SLAB2);
+ itemStack.setAmount(2);
+ break;
+ case STONE_SLAB2:
+ itemStack.setDurability((short) (itemStack.getDurability() % 8));
+ break;
+ case SPRUCE_FENCE_GATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case BIRCH_FENCE_GATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case JUNGLE_FENCE_GATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case DARK_OAK_FENCE_GATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case ACACIA_FENCE_GATE:
+ itemStack.setDurability((short) 0);
+ break;
+ case SPRUCE_DOOR:
+ itemStack.setType(Material.SPRUCE_DOOR_ITEM);
+ itemStack.setDurability((short) 0);
+ break;
+ case BIRCH_DOOR:
+ itemStack.setType(Material.BIRCH_DOOR_ITEM);
+ itemStack.setDurability((short) 0);
+ break;
+ case JUNGLE_DOOR:
+ itemStack.setType(Material.JUNGLE_DOOR_ITEM);
+ itemStack.setDurability((short) 0);
+ break;
+ case ACACIA_DOOR:
+ itemStack.setType(Material.ACACIA_DOOR_ITEM);
+ itemStack.setDurability((short) 0);
+ break;
+ case DARK_OAK_DOOR:
+ itemStack.setType(Material.DARK_OAK_DOOR_ITEM);
+ itemStack.setDurability((short) 0);
+ break;
+ }
+
+ return itemStacks;
+ }
}
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java
index 6d5867e27..566be1092 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java
@@ -33,6 +33,7 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
+import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@@ -531,10 +532,27 @@ public class UtilEnt
}
public static boolean isGrounded(Entity ent)
+ {
+
+ if(!(ent instanceof Player)) {
+ return ent.isOnGround();
+ }
+
+ AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox().shrink(0.05, 0, 0.05);
+ Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.05, box.c);
+ Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.05, box.f);
+
+ for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){
+ if(UtilBlock.solid(b)) return true;
+ }
+ return false;
+ }
+
+ public static boolean isGrounded(Entity ent, Location loc)
{
AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox();
- Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c);
- Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f);
+ Location bottom_corner_1 = new Location(ent.getWorld(), box.a, loc.getY()-0.1, box.c);
+ Location bottom_corner_2 = new Location(ent.getWorld(), box.d, loc.getY()-0.1, box.f);
for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){
if(UtilBlock.solid(b)) return true;
@@ -639,6 +657,11 @@ public class UtilEnt
return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec));
}
+ public static boolean CreatureLook(Entity ent, Vector target)
+ {
+ return CreatureLook(ent, UtilAlg.GetPitch(target), UtilAlg.GetYaw(target));
+ }
+
public static void setFakeHead(Entity ent, boolean fakeHead)
{
net.minecraft.server.v1_8_R3.Entity ec = ((CraftEntity) ent).getHandle();
@@ -781,6 +804,20 @@ public class UtilEnt
return null;
}
+
+ public static void setAI(LivingEntity entity, boolean ai)
+ {
+ if(entity instanceof ArmorStand)
+ {
+ ((ArmorStand)entity).setGravity(ai);
+ return;
+ }
+ CraftEntity e = (CraftEntity)entity;
+ if(e.getHandle() instanceof EntityInsentient)
+ {
+ ((EntityInsentient)e.getHandle()).k(!ai);
+ }
+ }
public static boolean inWater(LivingEntity ent)
{
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java
index 79059c454..bd5346696 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java
@@ -16,7 +16,8 @@ public class UtilEvent
L_BLOCK,
R,
R_AIR,
- R_BLOCK
+ R_BLOCK,
+ ANY
}
public static boolean isAction(PlayerInteractEvent event, ActionType action)
@@ -39,6 +40,9 @@ public class UtilEvent
if (action == ActionType.R_BLOCK)
return (event.getAction() == Action.RIGHT_CLICK_BLOCK);
+ if (action == ActionType.ANY)
+ return event.getAction() != Action.PHYSICAL;
+
return false;
}
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFile.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFile.java
new file mode 100644
index 000000000..5429f0107
--- /dev/null
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilFile.java
@@ -0,0 +1,310 @@
+package mineplex.core.common.util;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+public class UtilFile
+{
+ public static void writePlainFile(File file, String text) throws FileNotFoundException
+ {
+ PrintWriter writer = new PrintWriter(file);
+ writer.print(text);
+ writer.close();
+ }
+
+ /**
+ * Will read the specified file, and return the contents, or a null value,
+ * if an exception is thrown. Will handle all exceptions, and simply ignore
+ * them and return null. No stack trace printed or anything.
+ */
+ public static String readIgnoreErrors(File file)
+ {
+ try
+ {
+ return readToStr(file);
+ }
+ catch (IOException exception)
+ {
+ return null;
+ }
+ }
+
+ public static String readToStr(File file) throws IOException
+ {
+ return new String(readAllBytes(file));
+ }
+
+ public static byte[] readAllBytes(File file) throws IOException
+ {
+ return Files.readAllBytes(Paths.get(file.toURI()));
+ }
+
+ public static void writePlainFile(String file, String text) throws FileNotFoundException
+ {
+ writePlainFile(new File(file), text);
+ }
+
+ /**
+ * Will read the specified file, and return the contents, or a null value,
+ * if an exception is thrown. Will handle all exceptions, and simply ignore
+ * them and return null. No stack trace printed or anything.
+ */
+ public static String readIgnoreErrors(String file)
+ {
+ return readIgnoreErrors(new File(file));
+ }
+
+ public static String readToStr(String file) throws IOException
+ {
+ return readToStr(new File(file));
+ }
+
+ public static byte[] readAllBytes(String file) throws IOException
+ {
+ return readAllBytes(new File(file));
+ }
+
+ public static void writeDataFile(File file, DataFileChunk... chunks) throws IOException
+ {
+ DataOutputStream stream = new DataOutputStream(new FileOutputStream(file));
+ for (DataFileChunk chunk : chunks)
+ {
+ chunk.writeTo(stream);
+ }
+ stream.close();
+ }
+
+ public static DataFileReader beginReading(String file) throws FileNotFoundException
+ {
+ return beginReading(new File(file));
+ }
+
+ public static DataFileReader beginReading(File file) throws FileNotFoundException
+ {
+ return new DataFileReader(file);
+ }
+
+ public static void writeDataFile(String file, DataFileChunk... chunks) throws IOException
+ {
+ writeDataFile(new File(file), chunks);
+ }
+
+ public static class DataFileChunk
+ {
+ private ChunkType _type;
+ private Object _value;
+
+ public DataFileChunk(ChunkType type, Object value)
+ {
+ if (type == null)
+ {
+ throw new RuntimeException("ChunkType can NOT be null.");
+ }
+
+ _type = type;
+
+ if (!_type.isValid(value))
+ {
+ throw new RuntimeException("Invalid value provided for the specified ChunkType.");
+ }
+
+ _value = value;
+ }
+
+ public void writeTo(DataOutputStream stream) throws IOException
+ {
+ _type.writeTo(stream, _value);
+ }
+ }
+
+ public static enum ChunkType
+ {
+ STRING(new ChunkImpl()
+ {
+ public void writeTo(DataOutputStream stream, Object value) throws IOException
+ {
+ String str = (String) value;
+
+ INTEGER.writeTo(stream, str.length());
+ for (char b : str.toCharArray())
+ {
+ CHAR.writeTo(stream, b);
+ }
+ }
+
+ public boolean isValid(Object value)
+ {
+ return value.getClass().equals(String.class);
+ }
+
+ public Object readFrom(DataInputStream stream) throws IOException
+ {
+ int length = (int) INTEGER.readFrom(stream);
+
+ StringBuilder string = new StringBuilder();
+
+ for (int i = 0; i < length; i++)
+ {
+ string.append(CHAR.readFrom(stream));
+ }
+
+ return string.toString();
+ }
+ }),
+ DOUBLE(new ChunkImpl()
+ {
+ public void writeTo(DataOutputStream stream, Object value) throws IOException
+ {
+ double number = (double) value;
+
+ stream.writeDouble(number);
+ }
+
+ public boolean isValid(Object value)
+ {
+ return value.getClass().equals(Double.class);
+ }
+
+ public Object readFrom(DataInputStream stream) throws IOException
+ {
+ return stream.readDouble();
+ }
+ }),
+ INTEGER(new ChunkImpl()
+ {
+ public void writeTo(DataOutputStream stream, Object value) throws IOException
+ {
+ int number = (int) value;
+
+ stream.writeInt(number);
+ }
+
+ public boolean isValid(Object value)
+ {
+ return value.getClass().equals(Integer.class);
+ }
+
+ public Object readFrom(DataInputStream stream) throws IOException
+ {
+ return stream.readInt();
+ }
+ }),
+ BYTE(new ChunkImpl()
+ {
+ public void writeTo(DataOutputStream stream, Object value) throws IOException
+ {
+ byte number = (byte) value;
+
+ stream.writeByte(number);
+ }
+
+ public boolean isValid(Object value)
+ {
+ return value.getClass().equals(Byte.class);
+ }
+
+ public Object readFrom(DataInputStream stream) throws IOException
+ {
+ return stream.readByte();
+ }
+ }),
+ CHAR(new ChunkImpl()
+ {
+ public void writeTo(DataOutputStream stream, Object value) throws IOException
+ {
+ char number = (char) value;
+
+ stream.writeChar(number);
+ }
+
+ public boolean isValid(Object value)
+ {
+ return value.getClass().equals(Character.class);
+ }
+
+ public Object readFrom(DataInputStream stream) throws IOException
+ {
+ return stream.readChar();
+ }
+ }),
+ LONG(new ChunkImpl()
+ {
+ public void writeTo(DataOutputStream stream, Object value) throws IOException
+ {
+ long number = (long) value;
+
+ stream.writeLong(number);
+ }
+
+ public boolean isValid(Object value)
+ {
+ return value.getClass().equals(Long.class);
+ }
+
+ public Object readFrom(DataInputStream stream) throws IOException
+ {
+ return stream.readLong();
+ }
+ });
+
+ private ChunkImpl _impl;
+
+ ChunkType(ChunkImpl impl)
+ {
+ _impl = impl;
+ }
+
+ protected void writeTo(DataOutputStream stream, Object value) throws IOException
+ {
+ _impl.writeTo(stream, value);
+ }
+
+ protected boolean isValid(Object value)
+ {
+ return value != null && _impl.isValid(value);
+ }
+
+ public Object readFrom(DataInputStream stream) throws IOException
+ {
+ return _impl.readFrom(stream);
+ }
+ }
+
+ public static class DataFileReader
+ {
+ private DataInputStream _stream;
+
+ public DataFileReader(File file) throws FileNotFoundException
+ {
+ _stream = new DataInputStream(new FileInputStream(file));
+ }
+
+ public Object readChunk(ChunkType type) throws IOException
+ {
+ return type.readFrom(_stream);
+ }
+
+ public void close() throws IOException
+ {
+ _stream.close();
+ }
+ }
+
+ protected interface ChunkImpl
+ {
+ void writeTo(DataOutputStream stream, Object value) throws IOException;
+
+ Object readFrom(DataInputStream stream) throws IOException;
+
+ boolean isValid(Object value);
+ }
+
+}
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java
index a1028c25f..88139390a 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java
@@ -13,7 +13,44 @@ public class UtilGear
private static HashSet pickSet = new HashSet();
private static HashSet diamondSet = new HashSet();
private static HashSet goldSet = new HashSet();
-
+ private static HashSet _armorSet = new HashSet();
+
+ public static boolean isArmor(ItemStack item)
+ {
+ if (item == null)
+ return false;
+
+ if (_armorSet.isEmpty())
+ {
+ _armorSet.add(Material.LEATHER_HELMET);
+ _armorSet.add(Material.LEATHER_CHESTPLATE);
+ _armorSet.add(Material.LEATHER_LEGGINGS);
+ _armorSet.add(Material.LEATHER_BOOTS);
+
+ _armorSet.add(Material.GOLD_HELMET);
+ _armorSet.add(Material.GOLD_CHESTPLATE);
+ _armorSet.add(Material.GOLD_LEGGINGS);
+ _armorSet.add(Material.GOLD_BOOTS);
+
+ _armorSet.add(Material.CHAINMAIL_HELMET);
+ _armorSet.add(Material.CHAINMAIL_CHESTPLATE);
+ _armorSet.add(Material.CHAINMAIL_LEGGINGS);
+ _armorSet.add(Material.CHAINMAIL_BOOTS);
+
+ _armorSet.add(Material.IRON_HELMET);
+ _armorSet.add(Material.IRON_CHESTPLATE);
+ _armorSet.add(Material.IRON_LEGGINGS);
+ _armorSet.add(Material.IRON_BOOTS);
+
+ _armorSet.add(Material.DIAMOND_HELMET);
+ _armorSet.add(Material.DIAMOND_CHESTPLATE);
+ _armorSet.add(Material.DIAMOND_LEGGINGS);
+ _armorSet.add(Material.DIAMOND_BOOTS);
+ }
+
+ return _armorSet.contains(item.getType());
+ }
+
public static boolean isAxe(ItemStack item)
{
if (item == null)
@@ -126,6 +163,10 @@ public class UtilGear
{
goldSet.add(Material.GOLD_SWORD);
goldSet.add(Material.GOLD_AXE);
+ goldSet.add(Material.GOLD_HELMET);
+ goldSet.add(Material.GOLD_CHESTPLATE);
+ goldSet.add(Material.GOLD_LEGGINGS);
+ goldSet.add(Material.GOLD_BOOTS);
}
return goldSet.contains(item.getType());
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java
index 625edf4d1..c82d37f9f 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java
@@ -1,48 +1,448 @@
package mineplex.core.common.util;
-import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
-import mineplex.core.common.structs.ItemContainer;
-
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-public class UtilItem
-{
- private static final Material[] FOOD_LIST = { Material.APPLE, Material.BAKED_POTATO, Material.BREAD, Material.CARROT, Material.CARROT_ITEM, Material.COOKED_CHICKEN,
- Material.COOKED_FISH, Material.GRILLED_PORK, Material.COOKIE, Material.GOLDEN_APPLE, Material.GOLDEN_CARROT, Material.MELON, Material.MUSHROOM_SOUP, Material.POISONOUS_POTATO,
- Material.PUMPKIN_PIE, Material.RAW_BEEF, Material.RAW_CHICKEN, Material.RAW_FISH, Material.PORK, Material.ROTTEN_FLESH, Material.SPIDER_EYE, Material.COOKED_BEEF};
+import mineplex.core.common.structs.ItemContainer;
+public class UtilItem
+{
+ public static Map> _materials = new HashMap<>();
+
+ static
+ {
+ // Blocks
+
+ _materials.put(Material.AIR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.STONE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.GRASS, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.DIRT, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.COBBLESTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE));
+ _materials.put(Material.WOOD, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD));
+ _materials.put(Material.SAPLING, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.BEDROCK, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.WATER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIQUID, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.STATIONARY_WATER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIQUID, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.LAVA, EnumSet.of(ItemCategory.LIQUID, ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.STATIONARY_LAVA, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIQUID, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.SAND, EnumSet.of(ItemCategory.BLOCK, ItemCategory.PHYSICS));
+ _materials.put(Material.GRAVEL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.PHYSICS));
+ _materials.put(Material.GOLD_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.GOLD));
+ _materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
+ _materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
+ _materials.put(Material.COAL_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
+ _materials.put(Material.LOG, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD, ItemCategory.LOG));
+ _materials.put(Material.LEAVES, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LEAVES));
+ _materials.put(Material.SPONGE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
+ _materials.put(Material.LAPIS_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE));
+ _materials.put(Material.LAPIS_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.COMPACT_BLOCK));
+ _materials.put(Material.DISPENSER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
+ _materials.put(Material.SANDSTONE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.NOTE_BLOCK, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.BED_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.POWERED_RAIL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.DETECTOR_RAIL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.PISTON_STICKY_BASE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.WEB, EnumSet.of(ItemCategory.BLOCK, ItemCategory.MOVEMENT_MODIFYING, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.LONG_GRASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.DEAD_BUSH, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.PISTON_BASE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.PISTON_EXTENSION, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.WOOL, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.PISTON_MOVING_PIECE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.YELLOW_FLOWER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.RED_ROSE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.BROWN_MUSHROOM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.RED_MUSHROOM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.GOLD_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.COMPACT_BLOCK));
+ _materials.put(Material.IRON_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.COMPACT_BLOCK));
+ _materials.put(Material.DOUBLE_STEP, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.STEP, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.BRICK, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.TNT, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.BOOKSHELF, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.MOSSY_COBBLESTONE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.OBSIDIAN, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.TORCH, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING, ItemCategory.BOUNDLESS));
+ _materials.put(Material.FIRE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.MOB_SPAWNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.WOOD_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.CHEST, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GUI));
+ _materials.put(Material.REDSTONE_WIRE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS, ItemCategory.REDSTONE));
+ _materials.put(Material.DIAMOND_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.DIAMOND));
+ _materials.put(Material.DIAMOND_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.COMPACT_BLOCK, ItemCategory.DIAMOND));
+ _materials.put(Material.WORKBENCH, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
+ _materials.put(Material.CROPS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.SOIL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.FURNACE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
+ _materials.put(Material.BURNING_FURNACE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING, ItemCategory.GUI));
+ _materials.put(Material.SIGN_POST, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.WOODEN_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.LADDER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.CLIMBABLE));
+ _materials.put(Material.RAILS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.COBBLESTONE_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.WALL_SIGN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.LEVER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.STONE_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.IRON_DOOR_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.WOOD_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.REDSTONE_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.REDSTONE));
+ _materials.put(Material.GLOWING_REDSTONE_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.REDSTONE));
+ _materials.put(Material.REDSTONE_TORCH_OFF, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE, ItemCategory.BOUNDLESS));
+ _materials.put(Material.REDSTONE_TORCH_ON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE, ItemCategory.BOUNDLESS, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.STONE_BUTTON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.SNOW, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.ICE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.MOVEMENT_MODIFYING));
+ _materials.put(Material.SNOW_BLOCK, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.CACTUS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.CLAY, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.SUGAR_CANE_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.BOUNDLESS, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.JUKEBOX, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.PUMPKIN, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.NETHERRACK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.NETHER));
+ _materials.put(Material.SOUL_SAND, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.NETHER));
+ _materials.put(Material.GLOWSTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING, ItemCategory.NETHER));
+ _materials.put(Material.PORTAL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING, ItemCategory.BOUNDLESS));
+ _materials.put(Material.JACK_O_LANTERN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.CAKE_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.DIODE_BLOCK_OFF, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE));
+ _materials.put(Material.DIODE_BLOCK_ON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE));
+ _materials.put(Material.STAINED_GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
+ _materials.put(Material.TRAP_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.MONSTER_EGGS, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.SMOOTH_BRICK, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.HUGE_MUSHROOM_1, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.HUGE_MUSHROOM_2, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.IRON_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.THIN_GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
+ _materials.put(Material.MELON_BLOCK, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.PUMPKIN_STEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.MELON_STEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.VINE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS, ItemCategory.CLIMBABLE));
+ _materials.put(Material.FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.BRICK_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.SMOOTH_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.MYCEL, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.WATER_LILY, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.NETHER_BRICK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.NETHER));
+ _materials.put(Material.NETHER_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.NETHER));
+ _materials.put(Material.NETHER_BRICK_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.NETHER));
+ _materials.put(Material.NETHER_WARTS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS, ItemCategory.NETHER));
+ _materials.put(Material.ENCHANTMENT_TABLE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.BREWING_STAND, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.CAULDRON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.ENDER_PORTAL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.ENDER_PORTAL_FRAME, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.ENDER_STONE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.DRAGON_EGG, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.REDSTONE_LAMP_OFF, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE));
+ _materials.put(Material.REDSTONE_LAMP_ON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.WOOD_DOUBLE_STEP, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.WOOD_STEP, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.COCOA, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.SANDSTONE_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.EMERALD_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE));
+ _materials.put(Material.ENDER_CHEST, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.TRIPWIRE_HOOK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS, ItemCategory.REDSTONE));
+ _materials.put(Material.TRIPWIRE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.EMERALD_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.COMPACT_BLOCK));
+ _materials.put(Material.SPRUCE_WOOD_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.BIRCH_WOOD_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.JUNGLE_WOOD_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.COMMAND, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
+ _materials.put(Material.BEACON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.COBBLE_WALL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.FLOWER_POT, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.CARROT, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.POTATO, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.WOOD_BUTTON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.SKULL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.ANVIL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GUI));
+ _materials.put(Material.TRAPPED_CHEST, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GUI));
+ _materials.put(Material.GOLD_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.IRON_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.REDSTONE_COMPARATOR_OFF, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE));
+ _materials.put(Material.REDSTONE_COMPARATOR_ON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE));
+ _materials.put(Material.DAYLIGHT_DETECTOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.REDSTONE_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.REDSTONE));
+ _materials.put(Material.QUARTZ_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.NETHER));
+ _materials.put(Material.HOPPER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GUI));
+ _materials.put(Material.QUARTZ_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.COMPACT_BLOCK, ItemCategory.NETHER));
+ _materials.put(Material.QUARTZ_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.NETHER));
+ _materials.put(Material.ACTIVATOR_RAIL, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+ _materials.put(Material.DROPPER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
+ _materials.put(Material.STAINED_CLAY, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.STAINED_GLASS_PANE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
+ _materials.put(Material.LEAVES_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LEAVES));
+ _materials.put(Material.LOG_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD, ItemCategory.LOG));
+ _materials.put(Material.ACACIA_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.DARK_OAK_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.HAY_BLOCK, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.CARPET, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.HARD_CLAY, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.COAL_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.COMPACT_BLOCK));
+ _materials.put(Material.PACKED_ICE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.MOVEMENT_MODIFYING));
+ _materials.put(Material.DOUBLE_PLANT, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS));
+
+ _materials.put(Material.SLIME_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.BARRIER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.IRON_TRAPDOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.PRISMARINE, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.SEA_LANTERN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING));
+ _materials.put(Material.STANDING_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.WALL_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.DAYLIGHT_DETECTOR_INVERTED, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.RED_SANDSTONE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE));
+ _materials.put(Material.RED_SANDSTONE_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.DOUBLE_STONE_SLAB2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.STONE));
+ _materials.put(Material.STONE_SLAB2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.STONE, ItemCategory.TRANSLUCENT));
+ _materials.put(Material.SPRUCE_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.BIRCH_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.JUNGLE_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.DARK_OAK_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.ACACIA_FENCE_GATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.SPRUCE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.BIRCH_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.JUNGLE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.SPRUCE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.BIRCH_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.JUNGLE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.ACACIA_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.DARK_OAK_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+
+
+ _materials.put(Material.DARK_OAK_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.ACACIA_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+ _materials.put(Material.DARK_OAK_DOOR_ITEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD));
+
+ // Items
+
+ _materials.put(Material.PRISMARINE_SHARD, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.PRISMARINE_CRYSTALS, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.RABBIT, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE));
+ _materials.put(Material.COOKED_RABBIT, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.RABBIT_STEW, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.RABBIT_FOOT, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.RABBIT_HIDE, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.ARMOR_STAND, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE));
+ _materials.put(Material.COOKED_MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.BANNER, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SPRUCE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
+ _materials.put(Material.BIRCH_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
+ _materials.put(Material.JUNGLE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
+ _materials.put(Material.ACACIA_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
+
+
+ _materials.put(Material.IRON_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.SHOVEL));
+ _materials.put(Material.IRON_PICKAXE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.PICKAXE));
+ _materials.put(Material.IRON_AXE, EnumSet.of(ItemCategory.AXE, ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.FLINT_AND_STEEL, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.APPLE, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.BOW, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.ARROW, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.COAL, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.DIAMOND, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND));
+ _materials.put(Material.IRON_INGOT, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON));
+ _materials.put(Material.GOLD_INGOT, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD));
+ _materials.put(Material.IRON_SWORD, EnumSet.of(ItemCategory.SWORD, ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.WOOD_SWORD, EnumSet.of(ItemCategory.SWORD, ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.WOOD_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.TOOL, ItemCategory.SHOVEL));
+ _materials.put(Material.WOOD_PICKAXE, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.TOOL, ItemCategory.PICKAXE));
+ _materials.put(Material.WOOD_AXE, EnumSet.of(ItemCategory.AXE, ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.STONE_SWORD, EnumSet.of(ItemCategory.SWORD, ItemCategory.ITEM, ItemCategory.STONE, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.STONE_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.STONE, ItemCategory.TOOL, ItemCategory.SHOVEL));
+ _materials.put(Material.STONE_PICKAXE, EnumSet.of(ItemCategory.ITEM, ItemCategory.STONE, ItemCategory.TOOL, ItemCategory.PICKAXE));
+ _materials.put(Material.STONE_AXE, EnumSet.of(ItemCategory.AXE, ItemCategory.ITEM, ItemCategory.STONE, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.DIAMOND_SWORD, EnumSet.of(ItemCategory.SWORD, ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.DIAMOND_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.TOOL, ItemCategory.SHOVEL));
+ _materials.put(Material.DIAMOND_PICKAXE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.TOOL, ItemCategory.PICKAXE));
+ _materials.put(Material.DIAMOND_AXE, EnumSet.of(ItemCategory.AXE, ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.TOOL, ItemCategory.WEAPON));
+ _materials.put(Material.STICK, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
+ _materials.put(Material.BOWL, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD));
+ _materials.put(Material.MUSHROOM_SOUP, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.GOLD_SWORD, EnumSet.of(ItemCategory.SWORD, ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.GOLD_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.TOOL, ItemCategory.SHOVEL));
+ _materials.put(Material.GOLD_PICKAXE, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.TOOL, ItemCategory.PICKAXE));
+ _materials.put(Material.GOLD_AXE, EnumSet.of(ItemCategory.AXE, ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.WEAPON, ItemCategory.TOOL));
+ _materials.put(Material.STRING, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.FEATHER, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SULPHUR, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.WOOD_HOE, EnumSet.of(ItemCategory.ITEM, ItemCategory.TOOL, ItemCategory.WOOD, ItemCategory.HOE));
+ _materials.put(Material.STONE_HOE, EnumSet.of(ItemCategory.ITEM, ItemCategory.TOOL, ItemCategory.STONE, ItemCategory.HOE));
+ _materials.put(Material.IRON_HOE, EnumSet.of(ItemCategory.ITEM, ItemCategory.TOOL, ItemCategory.IRON, ItemCategory.HOE));
+ _materials.put(Material.DIAMOND_HOE, EnumSet.of(ItemCategory.ITEM, ItemCategory.TOOL, ItemCategory.DIAMOND, ItemCategory.HOE));
+ _materials.put(Material.GOLD_HOE, EnumSet.of(ItemCategory.ITEM, ItemCategory.TOOL, ItemCategory.GOLD, ItemCategory.HOE));
+ _materials.put(Material.SEEDS, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.WHEAT, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.BREAD, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.LEATHER_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.LEATHER, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
+ _materials.put(Material.LEATHER_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.LEATHER, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
+ _materials.put(Material.LEATHER_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.LEATHER, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
+ _materials.put(Material.LEATHER_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.LEATHER, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
+ _materials.put(Material.CHAINMAIL_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.CHAINMAIL, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
+ _materials.put(Material.CHAINMAIL_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.CHAINMAIL, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
+ _materials.put(Material.CHAINMAIL_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.CHAINMAIL, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
+ _materials.put(Material.CHAINMAIL_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.CHAINMAIL, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
+ _materials.put(Material.IRON_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
+ _materials.put(Material.IRON_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
+ _materials.put(Material.IRON_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
+ _materials.put(Material.IRON_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
+ _materials.put(Material.DIAMOND_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
+ _materials.put(Material.DIAMOND_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
+ _materials.put(Material.DIAMOND_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
+ _materials.put(Material.DIAMOND_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
+ _materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
+ _materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
+ _materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
+ _materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
+ _materials.put(Material.FLINT, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
+ _materials.put(Material.GRILLED_PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.PAINTING, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.GOLDEN_APPLE, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.SIGN, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.WOOD_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.BUCKET, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.WATER_BUCKET, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.LAVA_BUCKET, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
+ _materials.put(Material.SADDLE, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.IRON_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.REDSTONE, EnumSet.of(ItemCategory.ITEM, ItemCategory.REDSTONE));
+ _materials.put(Material.SNOW_BALL, EnumSet.of(ItemCategory.ITEM, ItemCategory.THROWABLE));
+ _materials.put(Material.BOAT, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
+ _materials.put(Material.LEATHER, EnumSet.of(ItemCategory.ITEM, ItemCategory.LEATHER));
+ _materials.put(Material.MILK_BUCKET, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.CLAY_BRICK, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.CLAY_BALL, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SUGAR_CANE, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.PAPER, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.BOOK, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SLIME_BALL, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.STORAGE_MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
+ _materials.put(Material.POWERED_MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
+ _materials.put(Material.EGG, EnumSet.of(ItemCategory.ITEM, ItemCategory.THROWABLE));
+ _materials.put(Material.COMPASS, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.FISHING_ROD, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.WATCH, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.GLOWSTONE_DUST, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.RAW_FISH, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
+ _materials.put(Material.COOKED_FISH, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.INK_SACK, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.BONE, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SUGAR, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.CAKE, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.BED, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.DIODE, EnumSet.of(ItemCategory.ITEM, ItemCategory.REDSTONE, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.COOKIE, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.MAP, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SHEARS, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.MELON, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.PUMPKIN_SEEDS, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.MELON_SEEDS, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.RAW_BEEF, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
+ _materials.put(Material.COOKED_BEEF, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.RAW_CHICKEN, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
+ _materials.put(Material.COOKED_CHICKEN, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.ROTTEN_FLESH, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.ENDER_PEARL, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.BLAZE_ROD, EnumSet.of(ItemCategory.ITEM, ItemCategory.NETHER));
+ _materials.put(Material.GHAST_TEAR, EnumSet.of(ItemCategory.ITEM, ItemCategory.NETHER));
+ _materials.put(Material.GOLD_NUGGET, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.NETHER_STALK, EnumSet.of(ItemCategory.ITEM, ItemCategory.NETHER));
+ _materials.put(Material.POTION, EnumSet.of(ItemCategory.ITEM, ItemCategory.POTABLE));
+ _materials.put(Material.GLASS_BOTTLE, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SPIDER_EYE, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.FERMENTED_SPIDER_EYE, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.BLAZE_POWDER, EnumSet.of(ItemCategory.ITEM, ItemCategory.NETHER));
+ _materials.put(Material.MAGMA_CREAM, EnumSet.of(ItemCategory.ITEM, ItemCategory.NETHER));
+ _materials.put(Material.BREWING_STAND_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.CAULDRON_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.EYE_OF_ENDER, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.SPECKLED_MELON, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.MONSTER_EGG, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.EXP_BOTTLE, EnumSet.of(ItemCategory.ITEM, ItemCategory.THROWABLE));
+ _materials.put(Material.FIREBALL, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.BOOK_AND_QUILL, EnumSet.of(ItemCategory.ITEM, ItemCategory.GUI));
+ _materials.put(Material.WRITTEN_BOOK, EnumSet.of(ItemCategory.ITEM, ItemCategory.GUI));
+ _materials.put(Material.EMERALD, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.ITEM_FRAME, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.FLOWER_POT_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.CARROT_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.POTATO_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
+ _materials.put(Material.BAKED_POTATO, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.POISONOUS_POTATO, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.EMPTY_MAP, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.GOLDEN_CARROT, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.SKULL_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.CARROT_STICK, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.NETHER_STAR, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.PUMPKIN_PIE, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
+ _materials.put(Material.FIREWORK, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.FIREWORK_CHARGE, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.ENCHANTED_BOOK, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.REDSTONE_COMPARATOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.REDSTONE, ItemCategory.ITEM_BLOCK));
+ _materials.put(Material.NETHER_BRICK_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.NETHER));
+ _materials.put(Material.QUARTZ, EnumSet.of(ItemCategory.ITEM, ItemCategory.NETHER));
+ _materials.put(Material.EXPLOSIVE_MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
+ _materials.put(Material.HOPPER_MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
+ _materials.put(Material.IRON_BARDING, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON));
+ _materials.put(Material.GOLD_BARDING, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD));
+ _materials.put(Material.DIAMOND_BARDING, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND));
+ _materials.put(Material.LEASH, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.NAME_TAG, EnumSet.of(ItemCategory.ITEM));
+ _materials.put(Material.COMMAND_MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE));
+ _materials.put(Material.GOLD_RECORD, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.GREEN_RECORD, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_3, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_4, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_5, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_6, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_7, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_8, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_9, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_10, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_11, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ _materials.put(Material.RECORD_12, EnumSet.of(ItemCategory.ITEM, ItemCategory.MUSIC_DISC));
+ }
+
public static LinkedList matchItem(Player caller, String items, boolean inform)
{
LinkedList matchList = new LinkedList();
-
+
String failList = "";
-
- //Mass Search
+
+ // Mass Search
for (String cur : items.split(","))
{
ItemContainer match = searchItem(caller, cur, inform);
-
+
if (match != null)
matchList.add(match);
-
+
else
- failList += cur + " " ;
+ failList += cur + " ";
}
-
+
if (inform && failList.length() > 0)
{
failList = failList.substring(0, failList.length() - 1);
- UtilPlayer.message(caller, F.main("Item(s) Search", "" +
- C.mBody + " Invalid [" +
- C.mElem + failList +
- C.mBody + "]."));
+ UtilPlayer.message(caller, F.main("Item(s) Search", "" + C.mBody + " Invalid [" + C.mElem + failList + C.mBody + "]."));
}
-
+
return matchList;
}
@@ -54,76 +454,61 @@ public class UtilItem
{
String[] arg = args.split(":");
- //Get Selected Name
+ // Get Selected Name
String name = null;
- if (arg.length > 2)
- name = arg[2].replaceAll("_", " ");
-
- //By Name
- if (cur.toString().equalsIgnoreCase(args))
- return new ItemContainer(cur, (byte)0, name);
-
- if (cur.toString().toLowerCase().contains(args.toLowerCase()))
- matchList.add(new ItemContainer(cur, (byte)0, name));
+ if (arg.length > 2) name = arg[2].replaceAll("_", " ");
- //By ID:Data:Name
+ // By Name
+ if (cur.toString().equalsIgnoreCase(args)) return new ItemContainer(cur, (byte) 0, name);
- //ID
+ if (cur.toString().toLowerCase().contains(args.toLowerCase())) matchList.add(new ItemContainer(cur, (byte) 0, name));
+
+ // By ID:Data:Name
+
+ // ID
int id = 0;
try
{
- if (arg.length > 0)
- id = Integer.parseInt(arg[0]);
+ if (arg.length > 0) id = Integer.parseInt(arg[0]);
}
- catch (Exception e)
+ catch (Exception e)
{
continue;
}
- if (id != cur.getId())
- continue;
+ if (id != cur.getId()) continue;
- //Data
+ // Data
byte data = 0;
try
{
- if (arg.length > 1)
- data = Byte.parseByte(arg[1]);
+ if (arg.length > 1) data = Byte.parseByte(arg[1]);
}
- catch (Exception e)
+ catch (Exception e)
{
continue;
}
-
+
return new ItemContainer(cur, data, name);
}
-
- //No / Non-Unique
+
+ // No / Non-Unique
if (matchList.size() != 1)
{
- if (!inform)
- return null;
+ if (!inform) return null;
+
+ // Inform
+ UtilPlayer.message(caller, F.main("Item Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + args + C.mBody + "]."));
- //Inform
- UtilPlayer.message(caller, F.main("Item Search", "" +
- C.mCount + matchList.size() +
- C.mBody + " matches for [" +
- C.mElem + args +
- C.mBody + "]."));
-
if (matchList.size() > 0)
{
String matchString = "";
for (ItemContainer cur : matchList)
matchString += F.elem(cur.Type.toString()) + ", ";
+
+ if (matchString.length() > 1) matchString = matchString.substring(0, matchString.length() - 2);
- if (matchString.length() > 1)
- matchString = matchString.substring(0 , matchString.length() - 2);
-
- UtilPlayer.message(caller, F.main("Item Search", "" +
- C.mBody + "Matches [" +
- C.mElem + matchString +
- C.mBody + "]."));
+ UtilPlayer.message(caller, F.main("Item Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "]."));
}
return null;
@@ -135,25 +520,600 @@ public class UtilItem
public static String itemToStr(ItemStack item)
{
String data = "0";
- if (item.getData() != null)
- data = item.getData().getData() + "";
+ if (item.getData() != null) data = item.getData().getData() + "";
return item.getType() + ":" + item.getAmount() + ":" + item.getDurability() + ":" + data;
}
-
+
+ /**
+ * @param item - the item to be checked for material type
+ * @param material - the material to check if it matches
+ * @return true, if {@code item} is non-null and its material type matches
+ * {@code material}.
+ */
+ public static boolean matchesMaterial(ItemStack item, Material material)
+ {
+ return item != null && item.getType() == material;
+ }
+
public static boolean isFood(ItemStack item)
{
- return item == null ? false : isFood(item.getType());
+ return isEdible(item);
}
-
+
public static boolean isFood(Material material)
{
- for (Material food : FOOD_LIST)
- {
- if (food.equals(material))
- return true;
- }
+ return isEdible(material);
+ }
+
+ public static boolean isSword(ItemStack stack)
+ {
+ return isEdible(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isSword(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.SWORD));
+ }
+
+ public static boolean isEdible(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.EDIBLE));
+ }
+
+ public static boolean isEdible(ItemStack stack)
+ {
+ return isEdible(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isPotable(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.POTABLE));
+ }
+
+ public static boolean isPotable(ItemStack stack)
+ {
+ return isPotable(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isAxe(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.AXE));
+ }
+
+ public static boolean isAxe(ItemStack stack)
+ {
+ return isAxe(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isWeapon(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.WEAPON));
+ }
+
+ public static boolean isWeapon(ItemStack stack)
+ {
+ return isWeapon(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isHelmet(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.ARMOR_HELMET));
+ }
+
+ public static boolean isHelmet(ItemStack stack)
+ {
+ return isHelmet(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isChestplate(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.ARMOR_CHESTPLATE));
+ }
+
+ public static boolean isChestplate(ItemStack stack)
+ {
+ return isChestplate(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isLeggings(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.ARMOR_LEGGINGS));
+ }
+
+ public static boolean isLeggings(ItemStack stack)
+ {
+ return isLeggings(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isBoots(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.ARMOR_BOOTS));
+ }
+
+ public static boolean isBoots(ItemStack stack)
+ {
+ return isBoots(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isBlock(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.BLOCK));
+ }
+
+ public static boolean isBlock(ItemStack stack)
+ {
+ return isBlock(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isLiquid(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.LIQUID));
+ }
+
+ public static boolean isLiquid(ItemStack stack)
+ {
+ return isLiquid(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isBoundless(Material material)
+ {
+ return (_materials.get(material).contains(ItemCategory.BOUNDLESS));
+ }
+
+ public static boolean isBoundless(ItemStack stack)
+ {
+ return isBoundless(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isTranslucent(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.TRANSLUCENT));
+ }
+
+ public static boolean isTranslucent(ItemStack stack)
+ {
+ return isTranslucent(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isOre(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.ORE));
+ }
+
+ public static boolean isOre(ItemStack stack)
+ {
+ return isOre(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isCompactBlock(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.COMPACT_BLOCK));
+ }
+
+ public static boolean isCompactBlock(ItemStack stack)
+ {
+ return isCompactBlock(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isGlassProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.GLASS));
+ }
+
+ public static boolean isGlassProduct(ItemStack stack)
+ {
+ return isGlassProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean doesModifyMovement(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.MOVEMENT_MODIFYING));
+ }
+
+ public static boolean doesModifyMovement(ItemStack stack)
+ {
+ return doesModifyMovement(stack == null ? null : stack.getType());
+ }
+
+ public static boolean doesEmitLight(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.LIGHT_EMITTING));
+ }
+
+ public static boolean doesEmitLight(ItemStack stack)
+ {
+ return doesEmitLight(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isRedstoneComponent(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.REDSTONE));
+ }
+
+ public static boolean isRedstoneComponent(ItemStack stack)
+ {
+ return isRedstoneComponent(stack == null ? null : stack.getType());
+ }
+
+ public static boolean doesHaveGUI(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.GUI));
+ }
+
+ public static boolean doesHaveGUI(ItemStack stack)
+ {
+ return doesHaveGUI(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isClimbable(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.CLIMBABLE));
+ }
+
+ public static boolean isClimbable(ItemStack stack)
+ {
+ return isClimbable(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isLeatherProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.LEATHER));
+ }
+
+ public static boolean isLeatherProduct(ItemStack stack)
+ {
+ return isLeatherProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isGoldProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.GOLD));
+ }
+
+ public static boolean isGoldProduct(ItemStack stack)
+ {
+ return isGoldProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isIronProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.IRON));
+ }
+
+ public static boolean isIronProduct(ItemStack stack)
+ {
+ return isIronProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isDiamondProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.DIAMOND));
+ }
+
+ public static boolean isDiamondProduct(ItemStack stack)
+ {
+ return isDiamondProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isStoneProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.STONE));
+ }
+
+ public static boolean isStoneProduct(ItemStack stack)
+ {
+ return isStoneProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isWoodProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.WOOD));
+ }
+
+ public static boolean isWoodProduct(ItemStack stack)
+ {
+ return isWoodProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isChainmailProduct(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.CHAINMAIL));
+ }
+
+ public static boolean isChainmailProduct(ItemStack stack)
+ {
+ return isChainmailProduct(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isThrowable(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.THROWABLE));
+ }
+
+ public static boolean isThrowable(ItemStack stack)
+ {
+ return isThrowable(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isVehicle(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.VEHICLE));
+ }
+
+ public static boolean isVehicle(ItemStack stack)
+ {
+ return isVehicle(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isItem(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.ITEM));
+ }
+
+ public static boolean isItem(ItemStack stack)
+ {
+ return isItem(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isLog(Material material)
+ {
+ return material == null ? false : (_materials.get(material).contains(ItemCategory.LOG));
+ }
+
+ public static boolean isLog(ItemStack stack)
+ {
+ return isLog(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isLeaf(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.LEAVES));
+ }
+
+ public static boolean isLeaf(ItemStack stack)
+ {
+ return isLeaf(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isTool(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.TOOL));
+ }
+
+ public static boolean isTool(ItemStack stack)
+ {
+ return isTool(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isAffectedByPhysics(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.PHYSICS));
+ }
+
+ public static boolean isAffectedByPhysics(ItemStack stack)
+ {
+ return isAffectedByPhysics(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isFromNether(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.NETHER));
+ }
+
+ public static boolean isFromNether(ItemStack stack)
+ {
+ return isFromNether(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isFoodRaw(Material material)
+ {
+ return material == null ? false : (_materials.get(material).contains(ItemCategory.RAW_FOOD));
+ }
+
+ public static boolean isFoodRaw(ItemStack stack)
+ {
+ return isFoodRaw(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isMusicDisc(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.MUSIC_DISC));
+ }
+
+ public static boolean isMusicDisc(ItemStack stack)
+ {
+ return isMusicDisc(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isSpade(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.SHOVEL));
+ }
+
+ public static boolean isSpade(ItemStack stack)
+ {
+ return isSpade(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isPickaxe(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.PICKAXE));
+ }
+
+ public static boolean isPickaxe(ItemStack stack)
+ {
+ return isPickaxe(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isHoe(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.HOE));
+ }
+
+ public static boolean isHoe(ItemStack stack)
+ {
+ return isHoe(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isItemBlock(Material material)
+ {
+ return material == null ? false : (_materials.get(material).contains(ItemCategory.ITEM_BLOCK));
+ }
+
+ public static boolean isItemBlock(ItemStack stack)
+ {
+ return isItemBlock(stack == null ? null : stack.getType());
+ }
+
+ public static boolean isArmor(Material material)
+ {
+ return material == null ? false : (contains(material, ItemCategory.ARMOR));
+ }
+
+ public static boolean isArmor(ItemStack stack)
+ {
+ return isArmor(stack == null ? null : stack.getType());
+ }
- return false;
+ private static boolean contains(Material material, ItemCategory category)
+ {
+ EnumSet set = _materials.get(material);
+ return set == null ? false : set.contains(category);
+ }
+
+ public static List listIn(ItemCategory... attr)
+ {
+ List attributes = new ArrayList<>(attr.length);
+ Collections.addAll(attributes, attr);
+
+ List list = new ArrayList<>();
+ for (Entry> mat : _materials.entrySet())
+ {
+ if (mat.getValue().containsAll(attributes))
+ {
+ list.add(mat.getKey());
+ }
+ }
+
+ attributes.clear();
+ attributes = null;
+
+ return list;
+ }
+
+ public enum ItemCategory
+ {
+ EDIBLE,
+ POTABLE,
+ ORE,
+ GLASS,
+ COMPACT_BLOCK,
+ GUI,
+ LIGHT_EMITTING,
+ REDSTONE,
+ TRANSLUCENT,
+ BOUNDLESS,
+ LIQUID,
+ MOVEMENT_MODIFYING,
+ CLIMBABLE,
+ THROWABLE,
+ PHYSICS,
+ NETHER,
+ RAW_FOOD,
+ MUSIC_DISC,
+ VEHICLE,
+ TOOL,
+ GOLD,
+ IRON,
+ DIAMOND,
+ STONE,
+ WOOD,
+ LEATHER,
+ CHAINMAIL,
+ ARMOR,
+ ARMOR_HELMET,
+ ARMOR_CHESTPLATE,
+ ARMOR_LEGGINGS,
+ ARMOR_BOOTS,
+ WEAPON,
+ SWORD,
+ AXE,
+ SHOVEL,
+ PICKAXE,
+ HOE,
+ ITEM,
+ BLOCK,
+ ITEM_BLOCK,
+ LOG,
+ LEAVES;
+ }
+
+ public enum ArmorMaterial
+ {
+ DIAMOND,
+ IRON,
+ GOLD,
+ LEATHER,
+ CHAINMAIL;
+
+ public static ArmorMaterial of(Material armor)
+ {
+ if (!isArmor(armor))
+ {
+ return null;
+ }
+
+ if (isDiamondProduct(armor))
+ {
+ return DIAMOND;
+ }
+
+ if (isIronProduct(armor))
+ {
+ return IRON;
+ }
+
+ if (isGoldProduct(armor))
+ {
+ return GOLD;
+ }
+
+ if (isLeatherProduct(armor))
+ {
+ return LEATHER;
+ }
+
+ if (isChainmailProduct(armor))
+ {
+ return CHAINMAIL;
+ }
+
+ return null;
+ }
+
+ public ItemCategory asCategory()
+ {
+ switch (this)
+ {
+ case DIAMOND:
+ return ItemCategory.DIAMOND;
+ case IRON:
+ return ItemCategory.IRON;
+ case GOLD:
+ return ItemCategory.GOLD;
+ case LEATHER:
+ return ItemCategory.LEATHER;
+ case CHAINMAIL:
+ return ItemCategory.CHAINMAIL;
+ default:
+ return null;
+ }
+ }
+ }
+
+ public static boolean isIndexed(Material material)
+ {
+ return _materials.containsKey(material);
}
}
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java
index 72ce23304..3d48c098f 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java
@@ -2,7 +2,7 @@ package mineplex.core.common.util;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
+import java.util.List;
import java.util.Locale;
import java.util.Random;
@@ -12,31 +12,36 @@ import org.bukkit.util.Vector;
public class UtilMath
{
- public static double trim(int degree, double d)
+ public static double trim(int degree, double d)
{
String format = "#.#";
- for (int i=1 ; i T randomElement(T[] array) {
- if (array.length == 0)
- return null;
+ public static T randomElement(T[] array)
+ {
+ if (array.length == 0) return null;
return array[random.nextInt(array.length)];
}
+
+ public static T randomElement(List list)
+ {
+ if (list.isEmpty()) return null;
+ return list.get(random.nextInt(list.size()));
+ }
+
+ public static double clamp(double num, double min, double max)
+ {
+ return num < min ? min : (num > max ? max : num);
+ }
+
+ public static long clamp(long num, long min, long max)
+ {
+ return num < min ? min : (num > max ? max : num);
+ }
+
+ public static int clamp(int num, int min, int max)
+ {
+ return num < min ? min : (num > max ? max : num);
+ }
}
-
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java
index ec6587bcf..d7896c943 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java
@@ -1,14 +1,12 @@
package mineplex.core.common.util;
-import java.lang.reflect.Field;
-
-import mineplex.core.common.util.UtilParticle.ViewDist;
-import net.minecraft.server.v1_8_R3.EnumParticle;
-import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
-
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
+import org.bukkit.util.Vector;
+
+import net.minecraft.server.v1_8_R3.EnumParticle;
+import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
public class UtilParticle
{
@@ -95,7 +93,7 @@ public class UtilParticle
LARGE_EXPLODE(EnumParticle.EXPLOSION_LARGE, "largeexplode", "Explosion", Material.FIREBALL, (byte) 0),
LARGE_SMOKE(EnumParticle.SMOKE_LARGE, "largesmoke", "Black Smoke", Material.INK_SACK, (byte) 0),
-
+
SMOKE(EnumParticle.SMOKE_NORMAL, "smoke", "Smoke", Material.INK_SACK, (byte) 0),
LAVA(EnumParticle.LAVA, "lava", "Lava Debris", Material.LAVA, (byte) 0),
@@ -242,7 +240,29 @@ public class UtilParticle
return packet;
}
+
+ public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY,
+ float offsetZ, float speed, int count, ViewDist dist)
+ {
+ PlayParticle(type, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
+ }
+ public static void PlayParticleToAll(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist)
+ {
+ PlayParticle(type, location, (float) offset.getX(), (float) offset.getY(), (float) offset.getZ(), speed, count, dist, UtilServer.getPlayers());
+ }
+
+ public static void PlayParticle(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist, Player... players)
+ {
+ PlayParticle(type, location, (float) offset.getX(), (float) offset.getY(), (float) offset.getZ(), speed, count, dist, players);
+ }
+
+ public static void PlayParticleToAll(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
+ float speed, int count, ViewDist dist)
+ {
+ PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
+ }
+
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players)
{
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
index 7b1b49599..af1712362 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
@@ -4,13 +4,12 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Random;
import java.util.UUID;
-import net.minecraft.server.v1_8_R3.EntityPlayer;
-import net.minecraft.server.v1_8_R3.Packet;
-import net.minecraft.server.v1_8_R3.PlayerConnection;
-
import org.bukkit.ChatColor;
+import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
@@ -21,10 +20,23 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
+import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
+import net.minecraft.server.v1_8_R3.EntityPlayer;
+import net.minecraft.server.v1_8_R3.Packet;
+import net.minecraft.server.v1_8_R3.PlayerConnection;
+
public class UtilPlayer
{
+ private static Random RANDOM = new Random();
+
+ // A mapping of player names (Keys) to the system time when they last changed active Hotbar Slot
+ private static Map _hotbarUpdates = new HashMap();
+
+ // The amount of time (in milliseconds) after changin hotbars that you can block
+ public static final long BLOCKING_HOTBAR_DELAY = 100;
+
private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max)
{
final double epsilon = 0.0001f;
@@ -154,6 +166,30 @@ public class UtilPlayer
return hit;
}
+ /**
+ * @param player - the player to be checked for blocking status
+ * @return true, if the {@code player} is blocking and has not recently
+ * changed hotbar slots (within {@value BLOCKING_HOTBAR_DELAY} milliseconds), false otherwise.
+ */
+ public static boolean isBlocking(Player player)
+ {
+ String name = player.getName();
+ long lastUpdate = _hotbarUpdates.containsKey(name) ? _hotbarUpdates.get(name) : 0;;
+ long duration = System.currentTimeMillis() - lastUpdate;
+
+ return player.isBlocking();// && UtilItem.isSword(player.getItemInHand())
+ //&& duration >= BLOCKING_HOTBAR_DELAY;
+ }
+
+ /**
+ * Mark the {@code player} as having changed hotbar slots.
+ * @param player - the player to be marked
+ */
+ public static void onHotbarChange(Player player)
+ {
+ _hotbarUpdates.put(player.getName(), System.currentTimeMillis());
+ }
+
/**
* AviodAllies doesn't work. Leaving as a param as it sounds like something you may want in the future.
*/
@@ -392,7 +428,12 @@ public class UtilPlayer
return matchList;
}
- public static LinkedList getNearby(Location loc, double maxDist)
+ public static List getNearby(Location loc, double maxDist)
+ {
+ return getNearby(loc, maxDist, false);
+ }
+
+ public static List getNearby(Location loc, double maxDist, boolean onlySurvival)
{
LinkedList nearbyMap = new LinkedList();
@@ -404,8 +445,10 @@ public class UtilPlayer
if (cur.isDead())
continue;
- double dist = loc.toVector().subtract(cur.getLocation().toVector()).length();
+ if (onlySurvival && cur.getGameMode() != GameMode.SURVIVAL)
+ continue;
+ double dist = loc.distance(cur.getLocation());
if (dist > maxDist)
continue;
@@ -453,7 +496,7 @@ public class UtilPlayer
return best;
}
- public static Player getClosest(Location loc, Entity ignore)
+ public static Player getClosest(Location loc, Entity... ignore)
{
Player best = null;
double bestDist = 0;
@@ -466,8 +509,14 @@ public class UtilPlayer
if (cur.isDead())
continue;
- if (ignore != null && ignore.equals(cur))
- continue;
+ if (ignore != null)
+ {
+ for (int i = 0; i < ignore.length; i++)
+ {
+ if (cur.equals(ignore[i]))
+ continue;
+ }
+ }
double dist = UtilMath.offset(cur.getLocation(), loc);
@@ -498,6 +547,14 @@ public class UtilPlayer
if (log)
System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]");
}
+
+ public static void kick(Collection players, String module, String message, boolean log)
+ {
+ for (Player player : players)
+ {
+ kick(player, module, message, log);
+ }
+ }
public static HashMap getInRadius(Location loc, double dR)
{
@@ -527,7 +584,7 @@ public class UtilPlayer
continue;
//Get lower offset (eye to eye, eye to feet)
- double offset = Math.min(UtilMath.offset(player.getEyeLocation(), cur.getEyeLocation()),
+ double offset = Math.min(UtilMath.offset(player.getEyeLocation(), cur.getEyeLocation()),
UtilMath.offset(player.getEyeLocation(), cur.getLocation()));
if (offset < distance && UtilAlg.isTargetInPlayerPyramid(player, cur, angleLimit))
@@ -590,6 +647,23 @@ public class UtilPlayer
return (((CraftEntity) player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0;
}
+ public static void clearInventory(Player player)
+ {
+ player.getInventory().clear();
+ player.getInventory().setHelmet(null);
+ player.getInventory().setChestplate(null);
+ player.getInventory().setLeggings(null);
+ player.getInventory().setBoots(null);
+ }
+
+ public static void clearPotionEffects(Player player)
+ {
+ for (PotionEffect effect : player.getActivePotionEffects())
+ {
+ player.removePotionEffect(effect.getType());
+ }
+ }
+
public static void sendPacket(Player player, Packet... packets)
{
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
@@ -603,6 +677,18 @@ public class UtilPlayer
}
}
+ /**
+ * Get a random player within maxDist of the target location
+ * @param location The center location to look for the player
+ * @param maxDist The max distance from location that the player can be
+ * @return A random player that is within maxDist of location, or null if no players apply
+ */
+ public static Player getRandomTarget(Location location, double maxDist)
+ {
+ List nearby = getNearby(location, maxDist, true);
+ return nearby.size() > 0 ? nearby.get(RANDOM.nextInt(nearby.size())) : null;
+ }
+
public static boolean isSpectator(Entity player)
{
if (player instanceof Player)
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java
index bfb69d72c..c56faa15a 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java
@@ -1,5 +1,11 @@
package mineplex.core.common.util;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.Sound;
@@ -12,6 +18,25 @@ public class UtilServer
return getServer().getOnlinePlayers().toArray(new Player[0]);
}
+ public static List getSortedPlayers()
+ {
+ return getSortedPlayers(new Comparator()
+ {
+ @Override
+ public int compare(Player o1, Player o2)
+ {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ }
+
+ public static List getSortedPlayers(Comparator comparator)
+ {
+ ArrayList players = new ArrayList(getServer().getOnlinePlayers());
+ Collections.sort(players, comparator);
+ return players;
+ }
+
public static Server getServer()
{
return Bukkit.getServer();
@@ -23,6 +48,12 @@ public class UtilServer
UtilPlayer.message(cur, message);
}
+ public static void broadcast(LinkedList messages)
+ {
+ for (Player cur : getPlayers())
+ UtilPlayer.message(cur, messages);
+ }
+
public static void broadcastSpecial(String event, String message)
{
for (Player cur : getPlayers())
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java
index 9b6044b4e..f3c1ab8b1 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java
@@ -1,6 +1,13 @@
package mineplex.core.common.util;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.bukkit.Material;
import org.bukkit.entity.*;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.SkullMeta;
public class UtilSkull
{
@@ -25,6 +32,19 @@ public class UtilSkull
return 3;
}
+ public static ItemStack getPlayerHead(String playerName, String itemName, List itemLore)
+ {
+ boolean displayHead = !playerName.isEmpty();
+ ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, displayHead ? (byte) 3 : 0);
+ SkullMeta meta = ((SkullMeta) skull.getItemMeta());
+ if (displayHead)
+ meta.setOwner(playerName);
+ meta.setDisplayName(itemName);
+ meta.setLore(itemLore);
+ skull.setItemMeta(meta);
+ return skull;
+ }
+
public static boolean isPlayerHead(byte data)
{
return data == 3;
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java
index 4372b6fba..8bbac15bc 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java
@@ -3,6 +3,7 @@ package mineplex.core.common.util;
import java.util.Collection;
import org.apache.commons.lang.WordUtils;
+import org.bukkit.Material;
public class UtilText {
public static String listToString(Collection inputList, boolean comma) {
@@ -95,4 +96,18 @@ public class UtilText {
public static String[] wrap(String text, int lineLength, boolean wrapLongerWords) {
return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0");
}
+
+ public static String repeat(String txt, int times)
+ {
+ return new String(new byte[times]).replace("\0", txt);
+ }
+
+ public static boolean plural(int x){
+ return x <= 0 ? true : x > 1;
+ }
+
+ public static String trim(int maxLength, String s) {
+ return s.length() <= maxLength ? s : s.substring(0, maxLength);
+ }
+
}
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java
index af77ee996..908272bc6 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java
@@ -44,12 +44,33 @@ public class UtilTime
public enum TimeUnit
{
- FIT,
- DAYS,
- HOURS,
- MINUTES,
- SECONDS,
- MILLISECONDS
+ FIT(1),
+ DAYS(86400000),
+ HOURS(3600000),
+ MINUTES(60000),
+ SECONDS(1000),
+ MILLISECONDS(1);
+
+ private long _ms;
+
+ TimeUnit(long ms)
+ {
+ _ms = ms;
+ }
+
+ public long getMilliseconds()
+ {
+ return _ms;
+ }
+ }
+
+ /**
+ * Convert from one TimeUnit to a different one
+ */
+ public static long convert(long time, TimeUnit from, TimeUnit to)
+ {
+ long milleseconds = time * from.getMilliseconds();
+ return milleseconds / to.getMilliseconds();
}
public static String since(long epoch)
@@ -103,7 +124,7 @@ public class UtilTime
if (type == TimeUnit.DAYS) text = (num = UtilMath.trim(trim, time / 86400000d)) + " Day";
else if (type == TimeUnit.HOURS) text = (num = UtilMath.trim(trim, time / 3600000d)) + " Hour";
else if (type == TimeUnit.MINUTES) text = (num = UtilMath.trim(trim, time / 60000d)) + " Minute";
- else if (type == TimeUnit.SECONDS) text = (int) (num = (int) UtilMath.trim(trim, time / 1000d)) + " Second";
+ else if (type == TimeUnit.SECONDS) text = (int) (num = (int) UtilMath.trim(trim, time / 1000d)) + " Second";
else text = (int) (num = (int) UtilMath.trim(trim, time)) + " Millisecond";
}
else
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilUI.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilUI.java
new file mode 100644
index 000000000..54c190729
--- /dev/null
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilUI.java
@@ -0,0 +1,36 @@
+package mineplex.core.common.util;
+
+public class UtilUI
+{
+ public static int[] getIndicesFor(int items, int startingLine, int newLinePadding)
+ {
+ return getIndicesFor(items, startingLine, 5, newLinePadding);
+ }
+
+ public static int[] getIndicesFor(int items, int startingLine)
+ {
+ return getIndicesFor(items, startingLine, 5, 0);
+ }
+
+ public static int[] getIndicesFor(int items, int startingLine, int itemsPerLine, int newLinePadding)
+ {
+ itemsPerLine = UtilMath.clamp(itemsPerLine, 1, 5);
+
+ int[] indices = new int[items];
+
+ int lines = (int) Math.ceil(items / ((double) itemsPerLine));
+ for (int line = 0; line < lines; line++)
+ {
+ int itemsInCurLine = line == lines - 1 ? items - (line * itemsPerLine) : itemsPerLine;
+ int startIndex = (startingLine * 9) + ((newLinePadding * 9) * line) + 9 * line - itemsInCurLine + 5;
+
+ for (int item = 0; item < itemsInCurLine; item++)
+ {
+ indices[(line * itemsPerLine) + item] = startIndex + (item * 2);
+ }
+ }
+
+ return indices;
+ }
+
+}
diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java
index af3aa4f91..c2a3c40ab 100644
--- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java
+++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java
@@ -7,6 +7,7 @@ import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
+import org.bukkit.block.Block;
import org.bukkit.util.Vector;
public class UtilWorld
@@ -45,7 +46,55 @@ public class UtilWorld
return null;
}
}
-
+
+ public static String blockToStr(Block block)
+ {
+ if (block == null)
+ return "";
+
+ return block.getWorld().getName() + "," +
+ block.getX() + "," +
+ block.getY() + "," +
+ block.getZ();
+ }
+
+ public static String blockToStrClean(Block block)
+ {
+ if (block == null)
+ return "";
+
+ return "(" + block.getX() + "," +
+ block.getY() + "," +
+ block.getZ() + ")";
+ }
+
+ public static Block strToBlock(String string)
+ {
+ if (string.length() == 0)
+ return null;
+
+ String[] parts = string.split(",");
+
+ try
+ {
+ for (World cur : UtilServer.getServer().getWorlds())
+ {
+ if (cur.getName().equalsIgnoreCase(parts[0]))
+ {
+ int x = Integer.parseInt(parts[1]);
+ int y = Integer.parseInt(parts[2]);
+ int z = Integer.parseInt(parts[3]);
+ return cur.getBlockAt(x, y, z);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ }
+
+ return null;
+ }
+
public static String locToStr(Location loc)
{
if (loc == null)
@@ -65,6 +114,14 @@ public class UtilWorld
return "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")";
}
+ public static String vecToStrClean(Vector loc)
+ {
+ if (loc == null)
+ return "Null";
+
+ return "(" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ")";
+ }
+
public static Location strToLoc(String string)
{
if (string.length() == 0)
diff --git a/Plugins/Mineplex.Core/Mineplex.Core.iml b/Plugins/Mineplex.Core/Mineplex.Core.iml
index 1714de4b9..06f039df9 100644
--- a/Plugins/Mineplex.Core/Mineplex.Core.iml
+++ b/Plugins/Mineplex.Core/Mineplex.Core.iml
@@ -13,12 +13,12 @@
+
-
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java
index df327ad09..5db2cfd80 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java
@@ -300,7 +300,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ // Lets delete it
int id = _entityMap.get(owner.getName()).get(metaPacket.a);
- UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[]
+ verifier.bypassProcess(new PacketPlayOutEntityDestroy(new int[]
{
id
}));
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java
index 5c07e698c..3c01d37a3 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java
@@ -34,6 +34,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
+import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@@ -47,7 +48,7 @@ public class CoreClientManager extends MiniPlugin
private AccountRepository _repository;
private NautHashMap _clientList;
private HashSet _duplicateLoginGlitchPreventionList;
-
+
private NautHashMap _loginProcessors = new NautHashMap();
private LinkedList _querylessLoginProcessors = new LinkedList();
@@ -572,4 +573,10 @@ public class CoreClientManager extends MiniPlugin
return client.GetRank().has(rank);
}
+
+ public int getCachedClientAccountId(UUID uuid)
+ {
+ PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
+ return playerInfo == null ? -1 : playerInfo.getAccountId();
+ }
}
\ No newline at end of file
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java
index 2f278165b..7c7db7911 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/account/ILoginProcessor.java
@@ -10,4 +10,4 @@ public interface ILoginProcessor
void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException;
String getQuery(int accountId, String uuid, String name);
-}
+}
\ No newline at end of file
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockDataRunnable.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockDataRunnable.java
new file mode 100644
index 000000000..99feb9645
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockDataRunnable.java
@@ -0,0 +1,75 @@
+package mineplex.core.blockrestore;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import mineplex.core.common.block.BlockData;
+
+public class BlockDataRunnable implements Runnable
+{
+ private JavaPlugin _plugin;
+ private boolean _started;
+ private BukkitTask _task;
+ private List _changedBlocks;
+ private Runnable _onComplete;
+ private int _blocksPerTick;
+ private Iterator _blockIterator;
+
+ public BlockDataRunnable(JavaPlugin plugin, Iterator blockIterator, int blocksPerTick, Runnable onComplete)
+ {
+ _plugin = plugin;
+ _changedBlocks = new ArrayList();
+ _started = false;
+ _blocksPerTick = blocksPerTick;
+ _onComplete = onComplete;
+ _blockIterator = blockIterator;
+ }
+
+ public void start()
+ {
+ if (!_started)
+ {
+ _task = Bukkit.getScheduler().runTaskTimer(_plugin, this, 1, 1);
+ _started = true;
+ }
+ }
+
+ public void pause()
+ {
+ if (_started)
+ {
+ _task.cancel();
+ _started = false;
+ }
+ }
+
+ public void setBlocksPerTick(int blocksPerTick)
+ {
+ _blocksPerTick = blocksPerTick;
+ }
+
+ @Override
+ public void run()
+ {
+ for (int i = 0; i < _blocksPerTick; i++)
+ {
+ if (_blockIterator.hasNext())
+ {
+ BlockData data = _blockIterator.next();
+ data.restore();
+ }
+ else
+ {
+ // We are done
+ _task.cancel();
+ _onComplete.run();
+ return;
+ }
+ }
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java
index 3f4621a66..cbffb8a05 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import mineplex.core.MiniPlugin;
import mineplex.core.updater.event.UpdateEvent;
@@ -26,28 +27,40 @@ import org.bukkit.plugin.java.JavaPlugin;
public class BlockRestore extends MiniPlugin
{
private HashMap _blocks = new HashMap();
+ private LinkedList _restoreMaps;
public BlockRestore(JavaPlugin plugin)
{
super("Block Restore", plugin);
+
+ _restoreMaps = new LinkedList();
}
@EventHandler(priority=EventPriority.LOW)
- public void BlockBreak(BlockBreakEvent event)
+ public void blockBreak(BlockBreakEvent event)
{
- if (Contains(event.getBlock()))
+ if (contains(event.getBlock()))
+ {
+ BlockRestoreData data = _blocks.get(event.getBlock());
+ if (data != null && data.isRestoreOnBreak())
+ {
+ _blocks.remove(event.getBlock());
+ data.restore();
+ }
+
+ event.setCancelled(true);
+ }
+ }
+
+ @EventHandler(priority=EventPriority.LOW)
+ public void blockPlace(BlockPlaceEvent event)
+ {
+ if (contains(event.getBlockPlaced()))
event.setCancelled(true);
}
@EventHandler(priority=EventPriority.LOW)
- public void BlockPlace(BlockPlaceEvent event)
- {
- if (Contains(event.getBlockPlaced()))
- event.setCancelled(true);
- }
-
- @EventHandler(priority=EventPriority.LOW)
- public void Piston(BlockPistonExtendEvent event)
+ public void piston(BlockPistonExtendEvent event)
{
if (event.isCancelled())
return;
@@ -60,7 +73,7 @@ public class BlockRestore extends MiniPlugin
if (push.getType() == Material.AIR)
return;
- if (Contains(push))
+ if (contains(push))
{
push.getWorld().playEffect(push.getLocation(), Effect.STEP_SOUND, push.getTypeId());
event.setCancelled(true);
@@ -70,7 +83,7 @@ public class BlockRestore extends MiniPlugin
}
@EventHandler
- public void ExpireBlocks(UpdateEvent event)
+ public void expireBlocks(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
@@ -86,15 +99,16 @@ public class BlockRestore extends MiniPlugin
_blocks.remove(cur);
}
- public void Restore(Block block)
+ public boolean restore(Block block)
{
- if (!Contains(block))
- return;
+ if (!contains(block))
+ return false;
_blocks.remove(block).restore();
+ return true;
}
- public void RestoreAll()
+ public void restoreAll()
{
for (BlockRestoreData data : _blocks.values())
data.restore();
@@ -102,7 +116,7 @@ public class BlockRestore extends MiniPlugin
_blocks.clear();
}
- public HashSet RestoreBlockAround(Material type, Location location, int radius)
+ public HashSet restoreBlockAround(Material type, Location location, int radius)
{
HashSet restored = new HashSet();
@@ -128,27 +142,36 @@ public class BlockRestore extends MiniPlugin
return restored;
}
-
- public void Add(Block block, int toID, byte toData, long expireTime)
+ public void add(Block block, int toID, byte toData, long expireTime)
{
- Add(block, toID, toData, block.getTypeId(), block.getData(), expireTime);
- }
-
- public void Add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime)
- {
- if (!Contains(block)) GetBlocks().put(block, new BlockRestoreData(block, toID, toData, fromID, fromData, expireTime, 0));
- else GetData(block).update(toID, toData, expireTime);
+ add(block, toID, toData, expireTime, false);
}
- public void Snow(Block block, byte heightAdd, byte heightMax, long expireTime, long meltDelay, int heightJumps)
+ public void add(Block block, int toID, byte toData, long expireTime, boolean restoreOnBreak)
+ {
+ add(block, toID, toData, block.getTypeId(), block.getData(), expireTime, restoreOnBreak);
+ }
+
+ public void add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime)
+ {
+ add(block, toID, toData, fromID, fromData, expireTime, false);
+ }
+
+ public void add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime, boolean restoreOnBreak)
+ {
+ if (!contains(block)) getBlocks().put(block, new BlockRestoreData(block, toID, toData, fromID, fromData, expireTime, 0, restoreOnBreak));
+ else getData(block).update(toID, toData, expireTime);
+ }
+
+ public void snow(Block block, byte heightAdd, byte heightMax, long expireTime, long meltDelay, int heightJumps)
{
//Fill Above
- if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && GetData(block) != null)
+ if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && getData(block) != null)
{
- GetData(block).update(78, heightAdd, expireTime, meltDelay);
+ getData(block).update(78, heightAdd, expireTime, meltDelay);
- if (heightJumps > 0) Snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, heightJumps-1);
- if (heightJumps == -1) Snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, -1);
+ if (heightJumps > 0) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, heightJumps - 1);
+ if (heightJumps == -1) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, -1);
return;
}
@@ -188,30 +211,59 @@ public class BlockRestore extends MiniPlugin
heightAdd = 0;
//Snow
- if (!Contains(block))
- GetBlocks().put(block, new BlockRestoreData(block, 78, (byte)Math.max(0, heightAdd-1), block.getTypeId(), block.getData(), expireTime, meltDelay));
+ if (!contains(block))
+ getBlocks().put(block, new BlockRestoreData(block, 78, (byte) Math.max(0, heightAdd - 1), block.getTypeId(), block.getData(), expireTime, meltDelay, false));
else
- GetData(block).update(78, heightAdd, expireTime, meltDelay);
+ getData(block).update(78, heightAdd, expireTime, meltDelay);
}
- public boolean Contains(Block block)
+ public boolean contains(Block block)
{
- if (GetBlocks().containsKey(block))
+ if (getBlocks().containsKey(block))
return true;
+
+ for (BlockRestoreMap restoreMap : _restoreMaps)
+ {
+ if (restoreMap.contains(block))
+ return true;
+ }
+
return false;
}
- public BlockRestoreData GetData(Block block)
+ public BlockRestoreData getData(Block block)
{
if (_blocks.containsKey(block))
return _blocks.get(block);
return null;
}
- public HashMap GetBlocks()
+ public HashMap getBlocks()
{
return _blocks;
}
-
+ public BlockRestoreMap createMap()
+ {
+ BlockRestoreMap map = new BlockRestoreMap(this);
+ _restoreMaps.add(map);
+ return map;
+ }
+
+ protected void removeMap(BlockRestoreMap blockRestore)
+ {
+ _restoreMaps.remove(blockRestore);
+ }
+
+ @Override
+ public void disable()
+ {
+ // Clear all restore maps
+ for (BlockRestoreMap restoreMap : _restoreMaps)
+ {
+ restoreMap.restoreInstant();
+ }
+
+ restoreAll();
+ }
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java
index a9417c831..9a22c4358 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreData.java
@@ -25,7 +25,9 @@ public class BlockRestoreData
protected HashMap _pad = new HashMap();
- public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay)
+ protected boolean _restoreOnBreak;
+
+ public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay, boolean restoreOnBreak)
{
_block = block;
@@ -41,6 +43,8 @@ public class BlockRestoreData
_meltDelay = meltDelay;
_meltLast = System.currentTimeMillis();
+ _restoreOnBreak = restoreOnBreak;
+
//Set
set();
}
@@ -151,6 +155,11 @@ public class BlockRestoreData
_block.setTypeIdAndData(_toID, _toData, true);
}
+ public boolean isRestoreOnBreak()
+ {
+ return _restoreOnBreak;
+ }
+
public void restore()
{
_block.setTypeIdAndData(_fromID, _fromData, true);
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java
new file mode 100644
index 000000000..fb123e315
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java
@@ -0,0 +1,181 @@
+package mineplex.core.blockrestore;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+
+import mineplex.core.common.block.BlockData;
+
+public class BlockRestoreMap
+{
+ private BlockRestore _blockRestore;
+ // The rate at which we restore blocks
+ private int _blocksPerTick;
+ // Easy access to all the blocks we have modified
+ private HashSet _changedBlocks;
+ // A hashmap for each level, so we can quickly restore top down
+ private HashMap[] _blocks;
+
+ protected BlockRestoreMap(BlockRestore blockRestore)
+ {
+ this(blockRestore, 50);
+ }
+
+ protected BlockRestoreMap(BlockRestore blockRestore, int blocksPerTick)
+ {
+ _blockRestore = blockRestore;
+ _blocksPerTick = blocksPerTick;
+ _changedBlocks = new HashSet();
+ _blocks = new HashMap[256];
+
+ // Populate Array
+ for (int i = 0; i < 256; i++)
+ {
+ _blocks[i] = new HashMap();
+ }
+ }
+
+ public void addBlockData(BlockData blockData)
+ {
+ Block block = blockData.Block;
+
+ if (!_blocks[block.getY()].containsKey(block))
+ _blocks[block.getY()].put(block, blockData);
+
+ _changedBlocks.add(blockData.Block);
+ }
+
+ public void set(Block block, Material material)
+ {
+ set(block, material, (byte) 0);
+ }
+
+ public void set(Block block, Material material, byte toData)
+ {
+ set(block, material.getId(), toData);
+ }
+
+ public void set(Block block, int toId, byte toData)
+ {
+ addBlockData(new BlockData(block));
+
+ block.setTypeIdAndData(toId, toData, false);
+ }
+
+ public boolean contains(Block block)
+ {
+ return _changedBlocks.contains(block);
+ }
+
+ public HashSet getChangedBlocks()
+ {
+ return _changedBlocks;
+ }
+
+ /**
+ * Restore all the blocks changed in this BlockRestoreMap
+ * NOTE: You should not use the same BlockRestoreMap instance after you run restore.
+ * You must initialize a new BlockRestoreMap from BlockRestore
+ */
+ public void restore()
+ {
+ // The idea behind this is that the runnable will restore blocks over time
+ // If the server happens to shutdown while the runnable is running, we will still
+ // restore all our blocks with restoreInstant (as called by BlockRestore)
+ BlockDataRunnable runnable = new BlockDataRunnable(_blockRestore.getPlugin(), new RestoreIterator(), _blocksPerTick, new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ clearMaps();
+ _blockRestore.removeMap(BlockRestoreMap.this);
+ }
+ });
+ runnable.start();
+ }
+
+ private void clearMaps()
+ {
+ for (int i = 0; i < 256; i++)
+ {
+ _blocks[i].clear();
+ }
+
+ _changedBlocks.clear();
+ }
+
+ public void restoreInstant()
+ {
+ for (int i = 0; i < 256; i++)
+ {
+ HashMap map = _blocks[i];
+ for (BlockData data : map.values())
+ {
+ data.restore();
+ }
+ }
+
+ clearMaps();
+ }
+
+ public int getBlocksPerTick()
+ {
+ return _blocksPerTick;
+ }
+
+ public void setBlocksPerTick(int blocksPerTick)
+ {
+ _blocksPerTick = blocksPerTick;
+ }
+
+ private class RestoreIterator implements Iterator
+ {
+ private Iterator _currentIterator;
+ private int _currentIndex;
+
+ public RestoreIterator()
+ {
+ _currentIndex = 255;
+ updateIterator();
+ }
+
+ private void updateIterator()
+ {
+ _currentIterator = _blocks[_currentIndex].values().iterator();
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ while (!_currentIterator.hasNext() && _currentIndex > 0)
+ {
+ _currentIndex--;
+ updateIterator();
+ }
+
+ return _currentIterator.hasNext();
+ }
+
+ @Override
+ public BlockData next()
+ {
+ while (!_currentIterator.hasNext() && _currentIndex > 0)
+ {
+ _currentIndex--;
+ updateIterator();
+ }
+
+ return _currentIterator.next();
+ }
+
+ @Override
+ public void remove()
+ {
+ _currentIterator.remove();
+ }
+ }
+
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
index 922911a59..71ee2abe0 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
@@ -732,7 +732,7 @@ public class BonusManager extends MiniClientPlugin implements I
if (gold > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold")));
- _donationManager.RewardGold(new Callback()
+ _donationManager.rewardGold(new Callback()
{
@Override
public void run(Boolean data)
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java
index dd274ce22..7a717c725 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java
@@ -76,7 +76,7 @@ public abstract class CommandBase implements ICom
return null;
}
- protected List getMatches(String start, List possibleMatches)
+ protected List getMatches(String start, Collection possibleMatches)
{
List matches = new ArrayList();
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java
index 3b24248d9..2ed930507 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java
@@ -43,6 +43,14 @@ public class MountPage extends ShopPageBase
if (slot == 26)
slot = 28;
}
+
+ addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
+ {
+ public void onClick(Player player, ClickType clickType)
+ {
+ getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
+ }
+ });
}
protected void addMount(Mount> mount, int slot)
@@ -76,12 +84,5 @@ public class MountPage extends ShopPageBase
setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), (mount.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
- addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
- {
- public void onClick(Player player, ClickType clickType)
- {
- getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
- }
- });
}
}
\ No newline at end of file
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java
index bb33f50b0..f5bc05d1b 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java
@@ -83,7 +83,7 @@ public class Creature extends MiniPlugin
return;
}
- CreatureSpawnCustomEvent customEvent = new CreatureSpawnCustomEvent(event.getLocation());
+ CreatureSpawnCustomEvent customEvent = new CreatureSpawnCustomEvent(event.getLocation(), event.getSpawnReason());
_plugin.getServer().getPluginManager().callEvent(customEvent);
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/event/CreatureSpawnCustomEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/event/CreatureSpawnCustomEvent.java
index 95b19fbc7..477a3f0bc 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/creature/event/CreatureSpawnCustomEvent.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/event/CreatureSpawnCustomEvent.java
@@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
public class CreatureSpawnCustomEvent extends Event implements Cancellable
{
@@ -11,10 +12,12 @@ public class CreatureSpawnCustomEvent extends Event implements Cancellable
private boolean _cancelled = false;
private Location _location;
+ private SpawnReason _reason;
- public CreatureSpawnCustomEvent(Location location)
+ public CreatureSpawnCustomEvent(Location location, SpawnReason reason)
{
_location = location;
+ _reason = reason;
}
public HandlerList getHandlers()
@@ -43,4 +46,9 @@ public class CreatureSpawnCustomEvent extends Event implements Cancellable
{
return _location;
}
+
+ public SpawnReason getReason()
+ {
+ return _reason;
+ }
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java
index 2d083f5f3..f96d1b04d 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java
@@ -1,5 +1,6 @@
package mineplex.core.database;
+import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -46,7 +47,7 @@ public abstract class RepositoryBase implements Listener
public void run()
{
initialize();
- update();
+ update();
}
});
@@ -69,7 +70,7 @@ public abstract class RepositoryBase implements Listener
{
return DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
}
-
+
/**
* Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool!
* @see Connection#close()
@@ -88,7 +89,7 @@ public abstract class RepositoryBase implements Listener
return null;
}
}
-
+
/**
* Execute a query against the repository.
* @param query - the concatenated query to execute in string form.
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java
index d2ed8e55b..4b39e5a77 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java
@@ -607,6 +607,22 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
entry.getKey().setEntity(entity);
+ boolean cancel = entry.getValue().length == 0;
+
+ for (Player player : entry.getValue())
+ {
+ if (player == owner)
+ {
+ cancel = true;
+ break;
+ }
+ }
+
+ if (cancel)
+ {
+ packetInfo.setCancelled(true);
+ }
+
disguise(entry.getKey(), false, entry.getValue());
}
}
@@ -864,8 +880,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
- undisguise(event.getPlayer());
-
for (DisguiseBase disguise : _disguisePlayerMap.keySet())
{
_disguisePlayerMap.get(disguise).remove(event.getPlayer());
@@ -875,6 +889,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
_lastRabbitHop.get(disguise).remove(event.getPlayer().getEntityId());
}
+
+ undisguise(event.getPlayer());
}
private void prepareChunk(Location loc)
@@ -1046,8 +1062,12 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
_movePacketMap.remove(entity.getEntityId());
_moveTempMap.remove(entity.getEntityId());
- _blockedNames.remove(((Player) entity).getName());
-
+
+ if (entity instanceof Player)
+ {
+ _blockedNames.remove(((Player) entity).getName());
+ }
+
refreshTrackers(entity, players.toArray(new Player[0]));
if (_bedPackets && disguise instanceof DisguisePlayer && ((DisguisePlayer) disguise).getSleepingDirection() != null)
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java
new file mode 100644
index 000000000..abda09d1c
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCaveSpider.java
@@ -0,0 +1,37 @@
+package mineplex.core.disguise.disguises;
+
+import org.bukkit.entity.EntityType;
+
+public class DisguiseCaveSpider extends DisguiseMonster
+{
+
+ public DisguiseCaveSpider(org.bukkit.entity.Entity entity)
+ {
+ super(EntityType.CAVE_SPIDER, entity);
+
+ DataWatcher.a(16, new Byte((byte) 0));
+ }
+
+ public boolean bT()
+ {
+ return (DataWatcher.getByte(16) & 0x01) != 0;
+ }
+
+ public void a(boolean flag)
+ {
+ byte b0 = DataWatcher.getByte(16);
+
+ if (flag)
+ b0 = (byte) (b0 | 0x1);
+ else
+ b0 = (byte) (b0 & 0xFFFFFFFE);
+
+ DataWatcher.watch(16, Byte.valueOf(b0));
+ }
+
+ protected String getHurtSound()
+ {
+ return "mob.spider.say";
+ }
+
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java
new file mode 100644
index 000000000..bd2ced0fd
--- /dev/null
+++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java
@@ -0,0 +1,38 @@
+package mineplex.core.disguise.disguises;
+
+import org.bukkit.entity.*;
+
+public class DisguiseGuardian extends DisguiseCreature
+{
+ public DisguiseGuardian(org.bukkit.entity.Entity entity)
+ {
+ super(EntityType.GUARDIAN, entity);
+ DataWatcher.a(16, 0);
+ DataWatcher.a(17, 0);
+ }
+
+ public void setTarget(int target)
+ {
+ DataWatcher.watch(17, target);
+ }
+
+ public void setElder(boolean elder)
+ {
+ DataWatcher.watch(16, Integer.valueOf(DataWatcher.getInt(16) | 4));
+ }
+
+ public boolean isElder()
+ {
+ return (this.DataWatcher.getInt(16) & 4) != 0;
+ }
+
+ protected String getHurtSound()
+ {
+ if (isElder())
+ {
+ return "mob.guardian.elder.hit";
+ }
+
+ return "mob.guardian.hit";
+ }
+}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java
index acffc12b4..54209e7db 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java
@@ -44,6 +44,7 @@ public class DonationManager extends MiniDbClientPlugin
@Override
public void addCommands()
{
+ // TODO: Re-add commands? Where are command implementations, seen as missing at the moment.
addCommand(new GemCommand(this));
addCommand(new CoinCommand(this));
addCommand(new GoldCommand(this));
@@ -62,7 +63,7 @@ public class DonationManager extends MiniDbClientPlugin
//_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
}
- public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final boolean coinPurchase, final int cost, boolean oneTimePurchase)
+ public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost, boolean oneTimePurchase)
{
final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(name) : null;
@@ -86,14 +87,14 @@ public class DonationManager extends MiniDbClientPlugin
if (donor != null)
{
donor.AddUnknownSalesPackagesOwned(packageName);
- donor.DeductCost(cost, coinPurchase ? CurrencyType.Coins : CurrencyType.Gems);
+ donor.DeductCost(cost, currencyType);
}
}
if (callback != null)
callback.run(response);
}
- }, name, accountId, packageName, coinPurchase, cost);
+ }, name, accountId, packageName, currencyType, cost);
}
public void PurchaseKnownSalesPackage(final Callback callback, final String name, final UUID uuid, final int cost, final int salesPackageId)
@@ -295,12 +296,17 @@ public class DonationManager extends MiniDbClientPlugin
_coinQueue.clear();
}
- public void RewardGold(Callback callback, String caller, String name, int accountId, int amount)
+ public void rewardGold(Callback callback, String caller, Player player, int amount)
{
- RewardGold(callback, caller, name, accountId, amount, true);
+ rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), amount);
+ }
+
+ public void rewardGold(Callback callback, String caller, String name, int accountId, int amount)
+ {
+ rewardGold(callback, caller, name, accountId, amount, true);
}
- public void RewardGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal)
+ public void rewardGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal)
{
_repository.rewardGold(new Callback()
{
@@ -324,7 +330,7 @@ public class DonationManager extends MiniDbClientPlugin
}
if (callback != null)
- callback.run(true);
+ callback.run(success);
}
}, caller, name, accountId, amount);
}
@@ -349,37 +355,55 @@ public class DonationManager extends MiniDbClientPlugin
}
@EventHandler
- public void UpdateGoldQueue(UpdateEvent event)
+ public void updateGoldQueue(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOWER)
return;
for (Player player : _goldQueue.keySet())
{
- String caller = null;
- int total = 0;
-
- for (String curCaller : _goldQueue.get(player).keySet())
- {
- caller = curCaller;
- total += _goldQueue.get(player).get(curCaller);
- }
-
- if (caller == null)
- continue;
-
- //Actually Add Gold
- RewardGold(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
-
- System.out.println("Queue Added [" + player + "] with Gold [" + total + "] for [" + caller + "]");
-
- //Clean
- _goldQueue.get(player).clear();
+ updateGoldQueue(null, player);
}
//Clean
_goldQueue.clear();
}
+
+ public void updateGoldQueue(final Callback callback, final Player player)
+ {
+ String tempCaller = null;
+ int tempTotal = 0;
+
+ for (String curCaller : _goldQueue.get(player).keySet())
+ {
+ tempCaller = curCaller;
+ tempTotal += _goldQueue.get(player).get(curCaller);
+ }
+
+ final String caller = tempCaller;
+ final int total = tempTotal;
+
+ if (caller == null)
+ return;
+
+ if (player.isOnline() && player.isValid())
+ rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
+ else
+ {
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
+ {
+ public void run()
+ {
+ rewardGold(callback, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false);
+ }
+ });
+ }
+
+ System.out.println("Queue Added [" + player + "] with Gold [" + total + "] for [" + caller + "]");
+
+ //Clean
+ _goldQueue.get(player).clear();
+ }
public void applyKits(String playerName)
{
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java
index e984d3432..7145b3dab 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java
@@ -77,6 +77,10 @@ public class Donor
_coins -= cost;
_update = true;
break;
+ case Gold:
+ _gold -= cost;
+ _update = true;
+ break;
default:
break;
}
@@ -90,6 +94,8 @@ public class Donor
return _gems;
case Coins:
return _coins;
+ case Gold:
+ return _gold;
case Tokens:
return 0;
default:
@@ -145,7 +151,8 @@ public class Donor
public void addGold(int amount)
{
- _gold += amount;
+ _gold = Math.max(0, _gold + amount);
+
}
public List getCoinTransactions()
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java
index 36095de1b..953b2c840 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java
@@ -73,7 +73,7 @@ public class GoldCommand extends CommandBase
private void rewardGold(final Player caller, final Player target, final String targetName, final int accountId, final int gold)
{
- Plugin.RewardGold(new Callback()
+ Plugin.rewardGold(new Callback()
{
public void run(Boolean completed)
{
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java
index 43d5b23b4..910f03c63 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java
@@ -1,11 +1,15 @@
package mineplex.core.donation.repository;
+import java.sql.CallableStatement;
+import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Types;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
+import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.Callback;
import mineplex.core.database.DBPool;
import mineplex.core.database.DatabaseRunnable;
@@ -69,12 +73,12 @@ public class DonationRepository extends RepositoryBase
}), "Error purchasing known sales package in DonationRepository : ");
}
- public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final boolean coinPurchase, final int cost)
+ public void PurchaseUnknownSalesPackage(final Callback callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost)
{
final UnknownPurchaseToken token = new UnknownPurchaseToken();
token.AccountName = name;
token.SalesPackageName = packageName;
- token.CoinPurchase = coinPurchase;
+ token.CoinPurchase = currencyType == CurrencyType.Coins;
token.Cost = cost;
token.Premium = false;
@@ -84,11 +88,15 @@ public class DonationRepository extends RepositoryBase
{
if (response == TransactionResponse.Success)
{
- if (coinPurchase)
+ if (currencyType == CurrencyType.Coins)
{
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnInt("id", accountId));
//executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost));
}
+ else if (currencyType == CurrencyType.Gold)
+ {
+ executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", -cost), new ColumnInt("id", accountId));
+ }
}
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
@@ -185,16 +193,12 @@ public class DonationRepository extends RepositoryBase
{
public void run()
{
- if (executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) < 1)
- {
- callback.run(false);
- }
- else
- callback.run(true);
+ boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0;
+ callback.run(success);
}
}), "Error updating player gold amount in DonationRepository : ");
}
-
+
@Override
protected void initialize()
{
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java
index b53fccd66..ab9c70d52 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java
@@ -29,6 +29,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
+import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
@@ -134,7 +135,7 @@ public class Explosion extends MiniPlugin
else
{
int heightDiff = cur.getLocation().getBlockY() - event.getEntity().getLocation().getBlockY();
- _blockRestore.Add(cur, 0, (byte)0, (long) (20000 + (heightDiff*3000) + Math.random()*2900));
+ _blockRestore.add(cur, 0, (byte) 0, (long) (20000 + (heightDiff * 3000) + Math.random() * 2900));
}
}
@@ -175,6 +176,7 @@ public class Explosion extends MiniPlugin
if (Math.random() > Math.min(0.975, chance))
{
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
+ fall.setDropItem(false);
Vector vec = UtilAlg.getTrajectory(fEnt, fall);
if (vec.getY() < 0) vec.setY(vec.getY() * -1);
@@ -207,6 +209,13 @@ public class Explosion extends MiniPlugin
}, 1);
}
+ @EventHandler
+ public void ExplosionChangeBlock(EntityChangeBlockEvent event)
+ {
+ if (_explosionBlocks.contains(event.getEntity()))
+ event.setCancelled(true);
+ }
+
@EventHandler
public void ExplosionBlockUpdate(UpdateEvent event)
{
@@ -239,7 +248,7 @@ public class Explosion extends MiniPlugin
{
if (_temporaryDebris)
{
- _blockRestore.Add(block, cur.getBlockId(), cur.getBlockData(), 10000);
+ _blockRestore.add(block, cur.getBlockId(), cur.getBlockData(), 10000);
}
else
{
@@ -256,14 +265,6 @@ public class Explosion extends MiniPlugin
}
}
- @EventHandler
- public void ExplosionItemSpawn(ItemSpawnEvent event)
- {
- for (FallingBlock block : _explosionBlocks)
- if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1)
- event.setCancelled(true);
- }
-
@EventHandler(priority = EventPriority.LOW)
public void ExplosionBlocks(EntityExplodeEvent event)
{
@@ -347,6 +348,7 @@ public class Explosion extends MiniPlugin
if (Math.random() > Math.min(0.98, chance))
{
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
+ fall.setDropItem(false);
Vector vec = UtilAlg.getTrajectory(fLoc, fall.getLocation());
if (vec.getY() < 0) vec.setY(vec.getY() * -1);
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFirework.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFirework.java
index 80a89bb76..114fbeeff 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFirework.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemFirework.java
@@ -30,7 +30,7 @@ public class ItemFirework extends ItemGadget
},
-1,
Material.FIREWORK, (byte)0,
- 250, new Ammo("Fireworks", "50 Fireworks", Material.FIREWORK, (byte)0, new String[] { C.cWhite + "50 Fireworks for you to launch!" }, 500, 50));
+ 500, new Ammo("Fireworks", "50 Fireworks", Material.FIREWORK, (byte)0, new String[] { C.cWhite + "50 Fireworks for you to launch!" }, 500, 50));
}
@Override
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java
index ea3a786ba..0692aa661 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemMelonLauncher.java
@@ -140,7 +140,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
{
Item melon = melonIterator.next();
- if (melon.isDead() || !melon.isValid() || melon.getTicksLived() > 400)
+ if (melon.isDead() || !melon.isValid() || melon.getTicksLived() > 100)
{
melonIterator.remove();
melon.remove();
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java
index 28700ac7f..ba0fd0d76 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java
@@ -164,7 +164,7 @@ public class ItemPaintbrush extends ItemGadget
continue;
//Color
- Manager.getBlockRestore().Add(block, 35, _brushColor.get(player.getName()), 30000);
+ Manager.getBlockRestore().add(block, 35, _brushColor.get(player.getName()), 30000);
//Join Dots
if (_brushPrevious.containsKey(player.getName()))
@@ -178,7 +178,7 @@ public class ItemPaintbrush extends ItemGadget
if (fixBlock.getType() != Material.WOOL)
continue;
- Manager.getBlockRestore().Add(fixBlock, 35, _brushColor.get(player.getName()), 30000);
+ Manager.getBlockRestore().add(fixBlock, 35, _brushColor.get(player.getName()), 30000);
}
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemTNT.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemTNT.java
index 91ac32a93..0bf3531b7 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemTNT.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemTNT.java
@@ -61,7 +61,7 @@ public class ItemTNT extends ItemGadget
if (!_tnt.remove(event.getEntity()))
return;
- HashMap players = UtilPlayer.getInRadius(event.getLocation(), 10);
+ HashMap players = UtilPlayer.getInRadius(event.getLocation(), 8);
for (Player player : players.keySet())
{
if (Manager.collideEvent(this, player))
@@ -70,7 +70,7 @@ public class ItemTNT extends ItemGadget
double mult = players.get(player);
//Knockback
- UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 3 * mult, false, 0, 0.5 + 2 * mult, 10, true);
+ UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 1 * mult, false, 0, 0.5 + 0.5 * mult, 10, true);
}
// Simulating explosion to prevent water from being evaporated.
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBat.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBat.java
index 3b0bfe79d..22cf5855e 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBat.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBat.java
@@ -85,7 +85,7 @@ public class MorphBat extends MorphGadget implements IThrown
if (!UtilEvent.isAction(event, ActionType.L))
return;
- if (!Recharge.Instance.use(player, GetName(), 100, false, false))
+ if (!Recharge.Instance.use(player, GetName(), 100, false, false, "Cosmetics"))
return;
//Effect
@@ -106,7 +106,7 @@ public class MorphBat extends MorphGadget implements IThrown
if (!IsActive(player))
return;
- if (!Recharge.Instance.use(player, "Poop", 4000, true, false))
+ if (!Recharge.Instance.use(player, "Poop", 4000, true, false, "Cosmetics"))
return;
//Action
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphChicken.java
index 2ebb73f20..6e3be5fce 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphChicken.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphChicken.java
@@ -76,7 +76,7 @@ public class MorphChicken extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
- if (!Recharge.Instance.use(player, GetName(), 100, false, false))
+ if (!Recharge.Instance.use(player, GetName(), 100, false, false, "Cosmetics"))
return;
Vector offset = player.getLocation().getDirection();
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java
index 07d1ae671..96dcda738 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCow.java
@@ -57,7 +57,7 @@ public class MorphCow extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
- if (!Recharge.Instance.use(player, GetName(), 2500, false, false))
+ if (!Recharge.Instance.use(player, GetName(), 2500, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, 1f, 1f);
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java
index 5cbc89f29..8c9419476 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java
@@ -119,7 +119,7 @@ public class MorphCreeper extends MorphGadget
double mult = players.get(other);
//Knockback
- UtilAction.velocity(other, UtilAlg.getTrajectory(player.getLocation(), other.getLocation()), 1 + 1.5 * mult, false, 0, 0.5 + 1 * mult, 3, true);
+ UtilAction.velocity(other, UtilAlg.getTrajectory(player.getLocation(), other.getLocation()), 1 + 1 * mult, false, 0, 0.6 + 0.6 * mult, 3, true);
}
}
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphEnderman.java
index d336a2dbb..72c6518d6 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphEnderman.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphEnderman.java
@@ -78,7 +78,7 @@ public class MorphEnderman extends MorphGadget
player.setAllowFlight(false);
//Set Recharge
- Recharge.Instance.use(player, GetName(), 2000, false, false);
+ Recharge.Instance.use(player, GetName(), 2000, false, false, "Cosmetics");
//Smoke Trail
Block lastSmoke = player.getLocation().getBlock();
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java
index 44662f5a1..d42b43023 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java
@@ -73,7 +73,7 @@ public class MorphPig extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
- if (!Recharge.Instance.use(player, GetName(), 400, false, false))
+ if (!Recharge.Instance.use(player, GetName(), 400, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float)(0.75 + Math.random() * 0.5));
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSlime.java
index 12f9a3eca..4737cf7ad 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSlime.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphSlime.java
@@ -83,7 +83,7 @@ public class MorphSlime extends MorphGadget
if (!UtilEnt.isGrounded(player))
return;
- if (!Recharge.Instance.use(player, GetName(), 1000, false, false))
+ if (!Recharge.Instance.use(player, GetName(), 1000, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.SLIME_ATTACK, 1f, 1f);
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java
index 26d1bd925..ed61f6511 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphTitan.java
@@ -1,35 +1,242 @@
package mineplex.core.gadget.gadgets;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Zombie;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.util.Vector;
+
+import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
+import mineplex.core.common.util.MapUtil;
+import mineplex.core.common.util.UtilAction;
+import mineplex.core.common.util.UtilAlg;
+import mineplex.core.common.util.UtilEnt;
+import mineplex.core.common.util.UtilEvent;
+import mineplex.core.common.util.UtilParticle;
+import mineplex.core.common.util.UtilParticle.ParticleType;
+import mineplex.core.common.util.UtilParticle.ViewDist;
+import mineplex.core.common.util.UtilPlayer;
+import mineplex.core.common.util.UtilServer;
+import mineplex.core.common.util.UtilEvent.ActionType;
+import mineplex.core.disguise.disguises.DisguiseBase;
+import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
+import mineplex.core.recharge.Recharge;
+import mineplex.core.recharge.RechargedEvent;
+import mineplex.core.updater.UpdateType;
+import mineplex.core.updater.event.UpdateEvent;
public class MorphTitan extends MorphGadget
{
+ private HashMap