Food Dupe Fix
This commit is contained in:
parent
92436c8f9d
commit
8a9cc9ff14
@ -19,6 +19,7 @@
|
|||||||
<element id="module-output" name="Mineplex.Database" />
|
<element id="module-output" name="Mineplex.Database" />
|
||||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
|
||||||
|
<element id="module-output" name="Mineplex.PlayerCache" />
|
||||||
</root>
|
</root>
|
||||||
</artifact>
|
</artifact>
|
||||||
</component>
|
</component>
|
@ -12,6 +12,10 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class UtilItem
|
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<ItemContainer> matchItem(Player caller, String items, boolean inform)
|
public static LinkedList<ItemContainer> matchItem(Player caller, String items, boolean inform)
|
||||||
{
|
{
|
||||||
LinkedList<ItemContainer> matchList = new LinkedList<ItemContainer>();
|
LinkedList<ItemContainer> matchList = new LinkedList<ItemContainer>();
|
||||||
@ -136,4 +140,20 @@ public class UtilItem
|
|||||||
|
|
||||||
return item.getType() + ":" + item.getAmount() + ":" + item.getDurability() + ":" + data;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
29
Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java
Normal file
29
Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,8 @@ import java.io.File;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import mineplex.core.FoodDupeFix;
|
||||||
import org.omg.CORBA._PolicyStub;
|
import org.omg.CORBA._PolicyStub;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.BiomeBase;
|
import net.minecraft.server.v1_7_R4.BiomeBase;
|
||||||
@ -154,6 +156,7 @@ public class Arcade extends JavaPlugin
|
|||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
new CustomTagFix(this, packetHandler);
|
new CustomTagFix(this, packetHandler);
|
||||||
new TablistFix(this);
|
new TablistFix(this);
|
||||||
|
new FoodDupeFix(this);
|
||||||
|
|
||||||
//Updates
|
//Updates
|
||||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user