1
0
mirror of https://e.coding.net/circlecloud/GuiShopManager.git synced 2024-11-16 01:08:52 +00:00

fix can't open shop while click air...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-07-10 20:02:32 +08:00
parent 769fd577ec
commit bc9aafb687

View File

@ -1,110 +1,107 @@
package org.black_ixx.bossshop.addon.guishopmanager; package org.black_ixx.bossshop.addon.guishopmanager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.black_ixx.bossshop.addon.guishopmanager.GuiShopManager; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventHandler; import org.bukkit.event.Listener;
import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack; public class PlayerListener implements Listener, Reloadable {
private GuiShopManager plugin;
public class PlayerListener implements Listener, Reloadable { private boolean drop;
private GuiShopManager plugin; private boolean move;
private boolean drop; private boolean place;
private boolean move; private boolean death;
private boolean place; private boolean respawn;
private boolean death;
private boolean respawn; public PlayerListener(GuiShopManager plugin) {
this.plugin = plugin;
public PlayerListener(GuiShopManager plugin) { loadSettings(plugin);
this.plugin = plugin; }
loadSettings(plugin);
} private void loadSettings(GuiShopManager plugin) {
ConfigurationSection s = plugin.getConfig().getConfigurationSection("Settings");
private void loadSettings(GuiShopManager plugin) {
ConfigurationSection s = plugin.getConfig().getConfigurationSection("Settings"); this.drop = s.getBoolean("AllowDropItems");
this.move = s.getBoolean("AllowMoveItems");
this.drop = s.getBoolean("AllowDropItems"); this.place = s.getBoolean("AllowPlaceItems");
this.move = s.getBoolean("AllowMoveItems"); this.death = s.getBoolean("DropItemsOnDeath");
this.place = s.getBoolean("AllowPlaceItems"); this.respawn = s.getBoolean("GetItemsOnRespawn");
this.death = s.getBoolean("DropItemsOnDeath"); }
this.respawn = s.getBoolean("GetItemsOnRespawn");
} @EventHandler(ignoreCancelled = true)
public void onDeath(PlayerDeathEvent event) {
@EventHandler(ignoreCancelled = true) if (!this.death) {
public void onDeath(PlayerDeathEvent event) { List<ItemStack> toRemove = new ArrayList<ItemStack>();
if (!this.death) {
List<ItemStack> toRemove = new ArrayList<ItemStack>(); for (ItemStack i : event.getDrops()) {
if (this.plugin.getGSMItems().isShopItem(i)) {
for (ItemStack i : event.getDrops()) { toRemove.add(i);
if (this.plugin.getGSMItems().isShopItem(i)) { }
toRemove.add(i);
} }
} for (ItemStack i : toRemove) {
event.getDrops().remove(i);
for (ItemStack i : toRemove) { }
event.getDrops().remove(i); toRemove.clear();
} }
toRemove.clear(); }
}
} @EventHandler(ignoreCancelled = true)
public void onDrop(PlayerDropItemEvent event) {
@EventHandler(ignoreCancelled = true) if ((!this.drop)
public void onDrop(PlayerDropItemEvent event) { && (this.plugin.getGSMItems().isShopItem(event.getItemDrop().getItemStack()))) {
if ((!this.drop) event.setCancelled(true);
&& (this.plugin.getGSMItems().isShopItem(event.getItemDrop().getItemStack()))) { }
event.setCancelled(true); }
}
} public void onInteract(PlayerInteractEvent event) {
this.plugin.getGSMItems().playerClicked(event);
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) }
public void onInteract(PlayerInteractEvent event) {
this.plugin.getGSMItems().playerClicked(event); @EventHandler(ignoreCancelled = true)
} public void onJoin(PlayerJoinEvent event) {
this.plugin.getGSMItems().giveJoinItems(event.getPlayer());
@EventHandler(ignoreCancelled = true) }
public void onJoin(PlayerJoinEvent event) {
this.plugin.getGSMItems().giveJoinItems(event.getPlayer()); @EventHandler(ignoreCancelled = true)
} public void onMove(InventoryClickEvent event) {
if (event.getWhoClicked().isOp())
@EventHandler(ignoreCancelled = true) return;
public void onMove(InventoryClickEvent event) { if (!this.move) {
if (event.getWhoClicked().isOp()) if (this.plugin.getGSMItems().isShopItem(event.getCurrentItem())
return; || this.plugin.getGSMItems().isShopItem(event.getCursor())) {
if (!this.move) { event.setCancelled(true);
if (this.plugin.getGSMItems().isShopItem(event.getCurrentItem()) }
|| this.plugin.getGSMItems().isShopItem(event.getCursor())) { }
event.setCancelled(true); }
}
} @EventHandler(ignoreCancelled = true)
} public void onPlace(BlockPlaceEvent event) {
if ((!this.place) && (this.plugin.getGSMItems().isShopItem(event.getItemInHand()))) {
@EventHandler(ignoreCancelled = true) event.setCancelled(true);
public void onPlace(BlockPlaceEvent event) { }
if ((!this.place) && (this.plugin.getGSMItems().isShopItem(event.getItemInHand()))) { }
event.setCancelled(true);
} @EventHandler
} public void onRespawn(PlayerRespawnEvent event) {
if (this.respawn) {
@EventHandler this.plugin.getGSMItems().giveJoinItems(event.getPlayer());
public void onRespawn(PlayerRespawnEvent event) { }
if (this.respawn) { }
this.plugin.getGSMItems().giveJoinItems(event.getPlayer());
} @Override
} public void reload(GuiShopManager plugin) {
loadSettings(plugin);
@Override }
public void reload(GuiShopManager plugin) {
loadSettings(plugin);
}
} }