Clans: Fix map inventory moving
This commit is contained in:
parent
3dcf489ea6
commit
cd55eba2be
@ -28,11 +28,11 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClansUtility;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.Block;
|
||||
import net.minecraft.server.v1_7_R4.Blocks;
|
||||
import net.minecraft.server.v1_7_R4.MaterialMapColor;
|
||||
import net.minecraft.server.v1_7_R4.PersistentCollection;
|
||||
import net.minecraft.util.com.google.common.base.Objects;
|
||||
import net.minecraft.util.com.google.common.collect.HashMultiset;
|
||||
import net.minecraft.util.com.google.common.collect.Iterables;
|
||||
import net.minecraft.util.com.google.common.collect.Multisets;
|
||||
@ -57,7 +57,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
@ -471,21 +473,32 @@ public class ItemMapManager extends MiniPlugin
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void mapMoveInventories(InventoryClickEvent event)
|
||||
public void preventMapMoveInventories(InventoryClickEvent event)
|
||||
{
|
||||
ItemStack item = event.getCurrentItem();
|
||||
Inventory inv = event.getClickedInventory();
|
||||
|
||||
if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId
|
||||
|| item.getDurability() > _mapId + 100)
|
||||
if (inv == null)
|
||||
return;
|
||||
|
||||
if (event.getClickedInventory() == null || event.getClickedInventory().getHolder() instanceof Player)
|
||||
// Yeah, the loop looks a little weird..
|
||||
for (ItemStack item : new ItemStack[]
|
||||
{
|
||||
event.getCurrentItem(), event.getCursor()
|
||||
})
|
||||
{
|
||||
if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId
|
||||
|| item.getDurability() > _mapId + 100)
|
||||
continue;
|
||||
|
||||
if (inv.getHolder() instanceof Player ? !event.isShiftClick() : Objects.equal(event.getCurrentItem(), item))
|
||||
continue;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
UtilPlayer.message(event.getWhoClicked(),
|
||||
F.main("Inventory", "You cannot move " + F.item("Clans Map") + " between inventories."));
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
UtilPlayer.message(event.getWhoClicked(),
|
||||
F.main("Inventory", "You cannot move " + F.item("Clans Map") + " between inventories."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user