mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-27 13:05:11 +01:00
Don't allow the modifying of farm items in an anvil.
This commit is contained in:
parent
e61e1bc6b3
commit
ba7b1eacf4
@ -24,10 +24,7 @@ import com.songoda.epicfarming.farming.levels.modules.Module;
|
||||
import com.songoda.epicfarming.farming.levels.modules.ModuleAutoBreeding;
|
||||
import com.songoda.epicfarming.farming.levels.modules.ModuleAutoButcher;
|
||||
import com.songoda.epicfarming.farming.levels.modules.ModuleAutoCollect;
|
||||
import com.songoda.epicfarming.listeners.BlockListeners;
|
||||
import com.songoda.epicfarming.listeners.EntityListeners;
|
||||
import com.songoda.epicfarming.listeners.InteractListeners;
|
||||
import com.songoda.epicfarming.listeners.UnloadListeners;
|
||||
import com.songoda.epicfarming.listeners.*;
|
||||
import com.songoda.epicfarming.settings.Settings;
|
||||
import com.songoda.epicfarming.storage.Storage;
|
||||
import com.songoda.epicfarming.storage.StorageRow;
|
||||
@ -192,6 +189,7 @@ public class EpicFarming extends SongodaPlugin {
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this), this);
|
||||
pluginManager.registerEvents(new UnloadListeners(this), this);
|
||||
pluginManager.registerEvents(new InventoryListeners(), this);
|
||||
|
||||
if (pluginManager.isPluginEnabled("FabledSkyBlock")) {
|
||||
try {
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.songoda.epicfarming.listeners;
|
||||
|
||||
import com.songoda.epicfarming.settings.Settings;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class InventoryListeners implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (event.getCurrentItem() == null) return;
|
||||
|
||||
if (event.getRawSlot() > event.getView().getTopInventory().getSize() - 1) return;
|
||||
|
||||
if (!event.getCurrentItem().hasItemMeta()) return;
|
||||
|
||||
if (event.getSlot() != 64537
|
||||
&& event.getInventory().getType() == InventoryType.ANVIL
|
||||
&& event.getAction() != InventoryAction.NOTHING
|
||||
&& event.getCurrentItem().getType() != Material.AIR) {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item.getType() == Settings.FARM_BLOCK_MATERIAL.getMaterial().getMaterial()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user