From 2467855766e41d9196faeeed26a9942d68fc5dbc Mon Sep 17 00:00:00 2001 From: 502647092 Date: Mon, 23 Nov 2015 21:00:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE=E7=89=A9?= =?UTF-8?q?=E5=88=B7=E7=89=A9=E5=93=81=20=20=E5=BC=82=E6=AD=A5=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E8=A3=85=E5=A4=87...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- pom.xml | 4 +-- .../QuickShop/Listeners/ProtectListener.java | 30 ++++++++++++----- .../org/maxgamer/QuickShop/QuickShop.java | 6 ++-- src/main/resources/plugin.yml | 32 +++++++++---------- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index c06415f..9624f40 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.maxgamer QuickShop - 1.6.1 + 1.6.2 快捷商店重置版本... ${project.name} @@ -54,7 +54,7 @@ http://ci.citycraft.cn:8080 - &c更新LocalUtil &a新增更多武器翻译... + &c修复部分回收悬浮物的插件导致的刷物品 异步检测装备... UTF-8 diff --git a/src/main/java/org/maxgamer/QuickShop/Listeners/ProtectListener.java b/src/main/java/org/maxgamer/QuickShop/Listeners/ProtectListener.java index d32ec8a..2227fa6 100644 --- a/src/main/java/org/maxgamer/QuickShop/Listeners/ProtectListener.java +++ b/src/main/java/org/maxgamer/QuickShop/Listeners/ProtectListener.java @@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; import org.maxgamer.QuickShop.QuickShop; import org.maxgamer.QuickShop.Shop.Shop; import org.maxgamer.QuickShop.Util.MarkUtil; @@ -103,15 +104,28 @@ public class ProtectListener implements Listener { @EventHandler public void onPlayerHandlerItem(final PlayerItemHeldEvent e) { - final Player p = e.getPlayer(); - final ItemStack[] cis = p.getInventory().getArmorContents(); - for (final ItemStack itemStack : cis) { - if (MarkUtil.hasMark(itemStack)) { - Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §e§l穿戴 " + itemStack.getItemMeta().getDisplayName() + " §a已清理..."); - itemStack.setType(Material.AIR); + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + final Player p = e.getPlayer(); + final PlayerInventory inv = p.getInventory(); + final ItemStack[] cis = inv.getArmorContents(); + for (int i = 0; i < cis.length; i++) { + final ItemStack itemStack = cis[i]; + if (MarkUtil.hasMark(itemStack)) { + cis[i] = new ItemStack(Material.AIR); + Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §e§l穿戴 " + itemStack.getItemMeta().getDisplayName() + " §a已清理..."); + } + } + inv.setArmorContents(cis); + final int newslot = e.getNewSlot(); + final ItemStack newItem = inv.getItem(newslot); + if (MarkUtil.hasMark(newItem)) { + inv.setItem(newslot, new ItemStack(Material.AIR)); + Bukkit.broadcastMessage("§6[§b快捷商店§6] §4警告 " + p.getDisplayName() + " §c非法 §e§l使用 " + newItem.getItemMeta().getDisplayName() + " §a已清理..."); + } } - } - p.getInventory().setArmorContents(cis); + }); } @EventHandler diff --git a/src/main/java/org/maxgamer/QuickShop/QuickShop.java b/src/main/java/org/maxgamer/QuickShop/QuickShop.java index 2c5fd09..a433062 100644 --- a/src/main/java/org/maxgamer/QuickShop/QuickShop.java +++ b/src/main/java/org/maxgamer/QuickShop/QuickShop.java @@ -55,9 +55,9 @@ import cn.citycraft.PluginHelper.utils.LocalUtil; import cn.citycraft.PluginHelper.utils.VersionChecker; public class QuickShop extends JavaPlugin { - /** The active instance of QuickShop */ + /** 初始化 QuickShop 的接口 */ public static QuickShop instance; - /** The plugin default config */ + /** 插件的配置文件 */ public FileConfig config; // private HeroChatListener heroChatListener; // Listeners (These don't) @@ -110,8 +110,6 @@ public class QuickShop extends JavaPlugin { return economy; } - /** The plugin metrics from Hidendra */ - // public Metrics getMetrics(){ return metrics; } public int getShopLimit(final Player p) { int max = configManager.getLimitdefault(); for (final Entry entry : configManager.getLimits().entrySet()) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 01ddbf7..59e1bc7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -13,48 +13,48 @@ softdepend: website: ${jenkins.url}/job/${project.artifactId}/ commands: qs: - description: QuickShop command + description: QuickShop 命令 usage: §c未知的子命令 请输入 §b/qs help §c查看帮助! aliases: - quickshop - shop permissions: quickshop.create.sell: - description: Allows a player to sell from a shop + description: 允许玩家创建出售商店 default: op quickshop.create.buy: - description: Allows a player to buy from a shop + description: 允许玩家创建收购商店 default: op quickshop.create.double: - description: Allows a player to create a double shop + description: 允许玩家创建双箱商店 default: op quickshop.use: - description: Allows a player to buy/sell using other players shops + description: 允许玩家在其他商店交易 default: true quickshop.unlimited: - description: Allows a Staff Member to use /qs unlimited and make a shop infinite + description: 允许玩家使用/qs unlimited创建无限商店 quickshop.bypass.: - description: Allows a player to sell , even if its blacklisted + description: 允许玩家出售 , 即使物品在黑名单里 quickshop.other.destroy: - description: Allows a Staff Member to destroy other players shops if they are locked in the config + description: 允许玩家摧毁其他玩家的商店 quickshop.other.open: - description: Allows a Staff Member to open someone elses shop if they are locked in the config + description: 允许玩家打开其他玩家的商店 quickshop.other.price: - description: Allows a Staff Member to change the price of someone elses shop + description: 允许玩家修改商店的价格 quickshop.setowner: - description: Allows a Staff Member to change the owner of any shop + description: 允许管理员设置商店的所有者 quickshop.find: - description: Allows a player to locate the nearest shop of a specific item type. Works in a 3 chunk radius. + description: 允许玩家查找附近的商店 (限制在3个区块内工作) default: true quickshop.refill: - description: Allows a Staff Member to refill the shop theyre looking at with the given number of items. + description: 允许玩家填满商店库存 default: op quickshop.empty: - description: Allows a Staff Member to empty the shop theyre looking at of all items. + description: 允许玩家清空指定商店 default: op quickshop.debug: - description: Enables debug info to console + description: 能够从控制台收到调试信息 default: op quickshop.export: - description: Allows exporting database to mysql or sqlite + description: 允许导出数据到SQLite或者MySQL default: op \ No newline at end of file