1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

完善异步玩家背包检测流程...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2016-01-07 13:51:57 +08:00
parent 86d0eb796e
commit 79ea58412a
2 changed files with 22 additions and 4 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId> <groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId> <artifactId>QuickShop</artifactId>
<version>1.6.8</version> <version>1.6.9</version>
<description>快捷商店重置版本...</description> <description>快捷商店重置版本...</description>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
@ -55,7 +55,7 @@
<properties> <properties>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url> <jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
<env.BUILD_NUMBER>DEBUG</env.BUILD_NUMBER> <env.BUILD_NUMBER>DEBUG</env.BUILD_NUMBER>
<update.description>&amp;c删除所谓的&amp;4&quot;DDOS&quot;&amp;c模块&amp;e停止插件所有更新...&amp;a你们提交PullRequest我还是会合并的...</update.description> <update.description>&amp;a增加1.7版本兼容(&amp;e测试&amp;a) &amp;c完善异步背包检测流程 发现非法物品后自动扫描...</update.description>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<repositories> <repositories>

View File

@ -55,14 +55,12 @@ public class ProtectListener implements Listener {
if (MarkUtil.hasMark(ci)) { if (MarkUtil.hasMark(ci)) {
e.setCancelled(true); e.setCancelled(true);
} }
final Inventory src = e.getSource(); final Inventory src = e.getSource();
final Inventory me = e.getInitiator(); final Inventory me = e.getInitiator();
final Inventory des = e.getDestination(); final Inventory des = e.getDestination();
final Shop srcshop = getShop(src); final Shop srcshop = getShop(src);
final Shop meshop = getShop(me); final Shop meshop = getShop(me);
final Shop desshop = getShop(des); final Shop desshop = getShop(des);
if ((srcshop != null && meshop == null) || (meshop != null && desshop == null) || (srcshop != null && desshop != null && srcshop.getOwner().equalsIgnoreCase(desshop.getOwner()))) { if ((srcshop != null && meshop == null) || (meshop != null && desshop == null) || (srcshop != null && desshop != null && srcshop.getOwner().equalsIgnoreCase(desshop.getOwner()))) {
e.setCancelled(true); e.setCancelled(true);
} }
@ -136,8 +134,28 @@ public class ProtectListener implements Listener {
} }
} }
private void clearIllegalItem(final Player player) {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
final Inventory inv = player.getInventory();
int clearnum = 0;
for (final ItemStack itemStack : inv) {
if (MarkUtil.hasMark(itemStack)) {
inv.remove(itemStack);
clearnum++;
}
}
if (clearnum != 0) {
Bukkit.broadcastMessage(plugin.getConfigManager().getGuiTitle() + " §4提示 §d扫描完毕 §d已清理 §a" + player.getName() + " §c非法获取的物品 §4" + clearnum + " §c个物品...");
}
}
});
}
private void sendWarning(final Player p, final ItemStack ci, final String action) { private void sendWarning(final Player p, final ItemStack ci, final String action) {
Bukkit.broadcastMessage(plugin.getConfigManager().getGuiTitle() + " §4警告 " + p.getDisplayName() + " §c非法 " + action + " " + ci.getItemMeta().getDisplayName()); Bukkit.broadcastMessage(plugin.getConfigManager().getGuiTitle() + " §4警告 " + p.getDisplayName() + " §c非法 " + action + " " + ci.getItemMeta().getDisplayName());
Bukkit.broadcastMessage(plugin.getConfigManager().getGuiTitle() + " §4提示 §d系统 §d已清理 §a" + p.getName() + " §c非法获取的物品 §a并扫描玩家背包..."); Bukkit.broadcastMessage(plugin.getConfigManager().getGuiTitle() + " §4提示 §d系统 §d已清理 §a" + p.getName() + " §c非法获取的物品 §a并扫描玩家背包...");
clearIllegalItem(p);
} }
} }