();
- 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)
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 8fe95f040..cb2397a72 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
@@ -541,6 +541,18 @@ public class UtilEnt
}
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, 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;
+ }
+ return false;
+ }
public static void PlayDamageSound(LivingEntity damagee)
{
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..0a7a56bdc 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,400 @@
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.DIRT, EnumSet.of(ItemCategory.BLOCK));
+ _materials.put(Material.GRASS, 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));
+
+ // Items
+
+ _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 +406,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 +472,589 @@ 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)
+ 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 : (_materials.get(material).contains(ItemCategory.SWORD));
+ }
+
+ public static boolean isEdible(Material material)
+ {
+ return material == null ? false : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(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 : (_materials.get(material).contains(ItemCategory.ARMOR));
+ }
+
+ public static boolean isArmor(ItemStack stack)
+ {
+ return isArmor(stack == null ? null : stack.getType());
+ }
+
+ 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 (food.equals(material))
- return true;
+ 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;
+ }
}
-
- return false;
}
}
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..fc2be0bf7 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
@@ -95,7 +95,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,6 +242,12 @@ 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 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..d5c8f563e 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,14 @@ 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;
+ }
+
}
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/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..411c81029 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());
}
}
@@ -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/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/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/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java
index 79a5cbff9..c1603431f 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java
@@ -8,6 +8,7 @@ public enum GameDisplay
//Mini
BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1),
Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.EXTRA, 2),
+ BossBattles("Boss Battles", Material.SKULL_ITEM, (byte) 0, GameCategory.EVENT, 55),
Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3),
CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4),
ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6),
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java
index 856b7322a..b598e19c3 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemStackFactory.java
@@ -708,6 +708,11 @@ public class ItemStackFactory extends MiniPlugin
return CreateStack(type.getId(), data, amount, (short)0, name, new String[] {}, null);
}
+ public ItemStack CreateStack(Material type, byte data, int amount, String name, boolean unbreakable)
+ {
+ return CreateStack(type.getId(), data, amount, (short)0, name, new String[] {}, null, unbreakable);
+ }
+
public ItemStack CreateStack(int id, byte data, int amount, String name)
{
return CreateStack(id, data, amount, (short)0, name, new String[] {}, null);
@@ -763,6 +768,11 @@ public class ItemStackFactory extends MiniPlugin
return CreateStack(type.getId(), data, amount, (short)0, name, ArrayToList(lore), owner);
}
+ public ItemStack CreateStack(Material type, byte data, int amount, String name, String[] lore, String owner, boolean unbreakable)
+ {
+ return CreateStack(type.getId(), data, amount, (short)0, name, ArrayToList(lore), owner, unbreakable);
+ }
+
public ItemStack CreateStack(int id, byte data, int amount, String name, String[] lore, String owner)
{
return CreateStack(id, data, amount, (short)0, name, ArrayToList(lore), owner);
@@ -778,15 +788,26 @@ public class ItemStackFactory extends MiniPlugin
return CreateStack(id, data, amount, damage, name, ArrayToList(lore), owner);
}
+ public ItemStack CreateStack(int id, byte data, int amount, short damage, String name, String[] lore, String owner, boolean unbreakable)
+ {
+ return CreateStack(id, data, amount, damage, name, ArrayToList(lore), owner, unbreakable);
+ }
+
+
public ItemStack CreateStack(Material type, byte data, int amount, short damage, String name, List lore, String owner)
{
return CreateStack(type.getId(), data, amount, damage, name, lore, owner);
}
+ public ItemStack CreateStack(int id, byte data, int amount, short damage, String name, List lore, String owner)
+ {
+ return CreateStack(id, data, amount, damage, name, lore, owner, true);
+ }
+
//XXX Owner Variant End
@SuppressWarnings("deprecation")
- public ItemStack CreateStack(int id, byte data, int amount, short damage, String name, List lore, String owner)
+ public ItemStack CreateStack(int id, byte data, int amount, short damage, String name, List lore, String owner, boolean unbreakable)
{
ItemStack stack;
if (data == 0)
@@ -855,16 +876,45 @@ public class ItemStackFactory extends MiniPlugin
stack.setItemMeta(itemMeta);
//Unbreakable
- if (stack.getType().getMaxDurability() > 1)
+ if (unbreakable)
{
- ItemMeta meta = stack.getItemMeta();
- meta.spigot().setUnbreakable(true);
- stack.setItemMeta(meta);
+ if (stack.getType().getMaxDurability() > 1)
+ {
+ ItemMeta meta = stack.getItemMeta();
+ meta.spigot().setUnbreakable(true);
+ stack.setItemMeta(meta);
+ }
}
return stack;
}
+ public void addOwnerLore(ItemStack item, String owner)
+ {
+ if (owner != null)
+ {
+ ItemMeta itemMeta = item.getItemMeta();
+
+ String[] tokens = owner.split(" ");
+
+ String[] ownerLore = new String[tokens.length + 2];
+
+ ownerLore[0] = C.cGray + "Owner: " + C.cAqua + tokens[0];
+
+ if (ownerLore.length >= 3)
+ ownerLore[1] = C.cGray + "Source: " + C.cAqua + tokens[1];
+
+ ownerLore[ownerLore.length - 2] = C.cGray + "Created: " + C.cAqua + UtilTime.date();
+
+ ownerLore[ownerLore.length - 1] = "";
+
+ if (itemMeta.getLore() != null) itemMeta.setLore(CombineLore(itemMeta.getLore(), ArrayToList(ownerLore)));
+ else itemMeta.setLore(ArrayToList(ownerLore));
+
+ item.setItemMeta(itemMeta);
+ }
+ }
+
private List CombineLore(List A, List B)
{
for (String b : B)
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java
index da8736f6d..5e971bf50 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java
@@ -174,8 +174,7 @@ public class NpcManager extends MiniPlugin
public Npc getNpcByEntity(Entity entity)
{
- if (entity == null)
- return null;
+ if (entity == null) return null;
return getNpcByEntityUUID(entity.getUniqueId());
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java
index 5de1e1525..e17daf159 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java
@@ -13,7 +13,7 @@ public class AddCommand extends CommandBase
{
public AddCommand(NpcManager plugin)
{
- super(plugin, Rank.DEVELOPER, "add");
+ super(plugin, Rank.JNR_DEV, "add");
}
@Override
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java
index 71dce58c0..f6a698add 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java
@@ -12,7 +12,7 @@ public class DeleteCommand extends CommandBase
{
public DeleteCommand(NpcManager plugin)
{
- super(plugin, Rank.DEVELOPER, "del");
+ super(plugin, Rank.JNR_DEV, "del");
}
@Override
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java
index 5e66eee21..81bd78c4a 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java
@@ -10,7 +10,7 @@ public class NpcCommand extends MultiCommandBase
{
public NpcCommand(NpcManager plugin)
{
- super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "npc");
+ super(plugin, Rank.JNR_DEV, "npc");
AddCommand(new AddCommand(plugin));
AddCommand(new DeleteCommand(plugin));
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java
index 5d6027624..44f2086be 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketHandler.java
@@ -56,7 +56,7 @@ public class PacketHandler extends MiniPlugin
{
if (!_packetHandlers.containsKey(packetInfo.getPacket().getClass()))
{
- // aSystem.err.print("Received packet " + packetInfo.getPacket().getClass() + " but am not listening for it!");
+ System.err.print("Received packet " + packetInfo.getPacket().getClass() + " but am not listening for it!");
return true;
}
@@ -79,6 +79,7 @@ public class PacketHandler extends MiniPlugin
public void onPlayerQuit(PlayerQuitEvent event)
{
((CraftPlayer) event.getPlayer()).getHandle().playerConnection.PacketVerifier.setPacketVerifier(null);
+ _playerVerifierMap.remove(event.getPlayer());
}
public PacketVerifier getPacketVerifier(Player player)
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java
index dcf6403e0..b79283d76 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java
@@ -86,6 +86,9 @@ public class PartyManager extends MiniPlugin
@EventHandler
public void serverTransfer(ServerTransferEvent event)
{
+ if (event.isDraggedByParty())
+ return;
+
Party party = _partyLeaderMap.get(event.getPlayer().getName());
if (party != null)
@@ -100,7 +103,7 @@ public class PartyManager extends MiniPlugin
{
if (player != event.getPlayer())
{
- _portal.sendPlayerToServer(player, event.getServer(), false);
+ _portal.sendPlayerToServer(player, event.getServer(), true);
}
}
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java
index 70ab28680..d5a24913f 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java
@@ -80,19 +80,16 @@ public class Portal extends MiniPlugin
public void sendPlayerToServer(Player player, String serverName)
{
- sendPlayerToServer(player, serverName, true);
+ sendPlayerToServer(player, serverName, false);
}
- public void sendPlayerToServer(final Player player, final String serverName, boolean callEvent)
+ public void sendPlayerToServer(final Player player, final String serverName, boolean draggedByParty)
{
if (_connectingPlayers.contains(player.getName()))
return;
-
- if (callEvent)
- {
- ServerTransferEvent event = new ServerTransferEvent(player, serverName);
- Bukkit.getPluginManager().callEvent(event);
- }
+
+ ServerTransferEvent event = new ServerTransferEvent(player, serverName, draggedByParty);
+ Bukkit.getPluginManager().callEvent(event);
final boolean override = serverName.equalsIgnoreCase("Lobby");
final Rank playerRank = _clientManager.Get(player).GetRank();
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java
index 69ddf086f..94262b8d7 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/ServerTransferEvent.java
@@ -10,11 +10,18 @@ public class ServerTransferEvent extends Event
private static final HandlerList _handlers = new HandlerList();
private Player _player;
private String _server;
+ private boolean _draggedByParty;
- public ServerTransferEvent(Player player, String server)
+ public ServerTransferEvent(Player player, String server, boolean draggedByParty)
{
_player = player;
_server = server;
+ _draggedByParty = draggedByParty;
+ }
+
+ public boolean isDraggedByParty()
+ {
+ return _draggedByParty;
}
public HandlerList getHandlers()
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java
index c69ab7bed..82eec02d1 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java
@@ -13,6 +13,7 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
+import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@@ -32,6 +33,7 @@ public class PreferencesManager extends MiniDbClientPlugin
{
private PreferencesRepository _repository;
private PreferencesShop _shop;
+ private ExclusivePreferencesShop _exclusiveShop;
private NautHashMap _saveBuffer = new NautHashMap();
@@ -42,7 +44,10 @@ public class PreferencesManager extends MiniDbClientPlugin
super("Preferences", plugin, clientManager);
_repository = new PreferencesRepository(plugin);
- _shop = new PreferencesShop(this, clientManager, donationManager);
+ _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager);
+ _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop);
+
+ _exclusiveShop.setPreferencesShop(_shop);
addCommand(new PreferencesCommand(this));
}
@@ -131,6 +136,6 @@ public class PreferencesManager extends MiniDbClientPlugin
@Override
public String getQuery(int accountId, String uuid, String name)
{
- return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
+ return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
}
}
diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java
index 44852c23e..7449c83c9 100644
--- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java
+++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java
@@ -14,11 +14,18 @@ import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnVarChar;
public class PreferencesRepository extends RepositoryBase
-{
- //private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
+{
+ // private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS
+ // accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256),
+ // games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1,
+ // showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1,
+ // privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL
+ // DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL
+ // DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL
+ // NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
- private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ? WHERE uuid=?;";
-
+ private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ? WHERE uuid=?;";
+
public PreferencesRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
@@ -27,9 +34,9 @@ public class PreferencesRepository extends RepositoryBase
@Override
protected void initialize()
{
- //executeUpdate(CREATE_ACCOUNT_TABLE);
+ // executeUpdate(CREATE_ACCOUNT_TABLE);
}
-
+
@Override
protected void update()
{
@@ -37,11 +44,7 @@ public class PreferencesRepository extends RepositoryBase
public void saveUserPreferences(NautHashMap preferences)
{
- try
- (
- Connection connection = getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
- )
+ try (Connection connection = getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);)
{
for (Entry