Make use of the new InventoryMoveEvent

This commit is contained in:
Acrobot 2013-03-24 20:57:54 +01:00
parent 1bc4fbcc78
commit 2448af7bcb
2 changed files with 29 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import com.Acrobot.ChestShop.Listeners.Block.BlockPlace;
import com.Acrobot.ChestShop.Listeners.Block.Break.ChestBreak;
import com.Acrobot.ChestShop.Listeners.Block.Break.SignBreak;
import com.Acrobot.ChestShop.Listeners.Block.SignCreate;
import com.Acrobot.ChestShop.Listeners.Item.ItemMoveListener;
import com.Acrobot.ChestShop.Listeners.ItemInfoListener;
import com.Acrobot.ChestShop.Listeners.Player.PlayerConnect;
import com.Acrobot.ChestShop.Listeners.Player.PlayerInteract;
@ -170,6 +171,7 @@ public class ChestShop extends JavaPlugin {
registerEvent(new ChestBreak());
registerEvent(new BlockPlace());
registerEvent(new ItemMoveListener());
registerEvent(new PlayerConnect());
registerEvent(new PlayerInteract());
registerEvent(new PlayerInventory());

View File

@ -0,0 +1,27 @@
package com.Acrobot.ChestShop.Listeners.Item;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
/**
* @author Acrobot
*/
public class ItemMoveListener implements Listener {
@EventHandler
public static void onItemMove(InventoryMoveItemEvent event) {
if (!(event.getSource().getHolder() instanceof Chest)) {
return;
}
if (!ChestShopSign.isShopChest(((BlockState) event.getSource().getHolder()).getBlock())) {
return;
}
event.setCancelled(true);
}
}