diff --git a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml index ca2ed67aa..619cdf3df 100644 --- a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml +++ b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml @@ -19,6 +19,7 @@ + \ No newline at end of file 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 1c874c58b..625edf4d1 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 @@ -12,6 +12,10 @@ 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}; + public static LinkedList matchItem(Player caller, String items, boolean inform) { LinkedList matchList = new LinkedList(); @@ -136,4 +140,20 @@ public class UtilItem return item.getType() + ":" + item.getAmount() + ":" + item.getDurability() + ":" + data; } + + public static boolean isFood(ItemStack item) + { + return item == null ? false : isFood(item.getType()); + } + + public static boolean isFood(Material material) + { + for (Material food : FOOD_LIST) + { + if (food.equals(material)) + return true; + } + + return false; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java b/Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java new file mode 100644 index 000000000..b17e76e8e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java @@ -0,0 +1,29 @@ +package mineplex.core; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.common.util.UtilItem; + +public class FoodDupeFix extends MiniPlugin +{ + public FoodDupeFix(JavaPlugin plugin) + { + super("Food Dupe Fix", plugin); + } + + // Use Highest priority so event.getItem isn't changed + @EventHandler(priority = EventPriority.HIGHEST) + public void fixFoodDupe(PlayerItemConsumeEvent event) + { + if (UtilItem.isFood(event.getItem())) + { + if (!event.getItem().equals(event.getPlayer().getItemInHand())) + { + event.setCancelled(true); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index d38023f34..71fa876f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -4,6 +4,8 @@ import java.io.File; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.FoodDupeFix; import org.omg.CORBA._PolicyStub; import net.minecraft.server.v1_7_R4.BiomeBase; @@ -154,6 +156,7 @@ public class Arcade extends JavaPlugin new MemoryFix(this); new CustomTagFix(this, packetHandler); new TablistFix(this); + new FoodDupeFix(this); //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);