1
0
mirror of https://e.coding.net/circlecloud/MenuProtect.git synced 2024-11-21 10:48:46 +00:00

feat: 添加扫地大妈支持

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-21 17:09:01 +08:00
parent ebbe4c4f1e
commit 74e30a5295
4 changed files with 53 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId> <groupId>pw.yumc</groupId>
<artifactId>MenuProtect</artifactId> <artifactId>MenuProtect</artifactId>
<version>1.3</version> <version>1.3.1</version>
<name>MenuProtect</name> <name>MenuProtect</name>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
@ -57,7 +57,7 @@
<url>http://ci.yumc.pw/job/${project.artifactId}/</url> <url>http://ci.yumc.pw/job/${project.artifactId}/</url>
</ciManagement> </ciManagement>
<properties> <properties>
<update.description>1.3新版本 支持LoreCommand</update.description> <update.description>1.3.1添加扫地大妈检测</update.description>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT> <env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@ -81,6 +81,11 @@
<type>jar</type> <type>jar</type>
<version>1.9-R0.1-SNAPSHOT</version> <version>1.9-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>io.github.Cnly.WowSuchCleaner</groupId>
<artifactId>WowSuchCleaner</artifactId>
<version>1.6.5</version>
</dependency>
<dependency> <dependency>
<groupId>cn.citycraft</groupId> <groupId>cn.citycraft</groupId>
<artifactId>PluginHelper</artifactId> <artifactId>PluginHelper</artifactId>

View File

@ -4,10 +4,13 @@ import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.PluginHelper.config.FileConfig; import cn.citycraft.PluginHelper.config.FileConfig;
import pw.yumc.MenuProtect.listen.ProtectListener; import pw.yumc.MenuProtect.listen.ProtectListener;
import pw.yumc.MenuProtect.listen.WowSuchCleanerListener;
import pw.yumc.MenuProtect.utils.MarkUtil; import pw.yumc.MenuProtect.utils.MarkUtil;
public class MenuProtect extends JavaPlugin { public class MenuProtect extends JavaPlugin {
@ -27,6 +30,17 @@ public class MenuProtect extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
Bukkit.getPluginManager().registerEvents(new ProtectListener(), this); Bukkit.getPluginManager().registerEvents(new ProtectListener(), this);
final PluginManager pm = this.getServer().getPluginManager();
final Plugin wsc = pm.getPlugin("WowSuchCleaner");
if (wsc != null && wsc.isEnabled()) {
getLogger().info("发现 WowSuchCleaner 插件 开启相关功能...");
try {
Class.forName("io.github.Cnly.WowSuchCleaner.WowSuchCleaner.ItemPreCleanEvent");
pm.registerEvents(new WowSuchCleanerListener(), this);
} catch (final ClassNotFoundException e) {
getLogger().info("WowSuchCleaner 版本过低 可能造成悬浮物上架...");
}
}
this.getLogger().info("菜单物品保护已开启!"); this.getLogger().info("菜单物品保护已开启!");
} }

View File

@ -0,0 +1,29 @@
package pw.yumc.MenuProtect.listen;
import java.util.List;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import io.github.Cnly.WowSuchCleaner.WowSuchCleaner.ItemPreCleanEvent;
import pw.yumc.MenuProtect.utils.MarkUtil;
/**
*
* @since 2016年7月21日 下午4:57:35
* @author
*/
public class WowSuchCleanerListener implements Listener {
@EventHandler
public void onClear(final ItemPreCleanEvent e) {
final List<ItemStack> list = e.getItemsToAuction();
final List<ItemStack> needRemove = e.getItemsToAuction();
for (final ItemStack itemStack : list) {
if (MarkUtil.hasMark(itemStack)) {
needRemove.add(itemStack);
}
}
list.removeAll(needRemove);
}
}

View File

@ -4,17 +4,16 @@ main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}-git-${env.GIT_COMMIT} version: ${project.version}-git-${env.GIT_COMMIT}
author: 喵♂呜 author: 喵♂呜
website: ${ciManagement.url} website: ${ciManagement.url}
softdepend:
- WowSuchCleaner
commands: commands:
${project.artifactId}: ${project.artifactId}:
description: ${project.artifactId} - ${project.description} description: ${project.artifactId} - ${project.description}
usage: §b使用/${project.artifactId} help 查看帮助! usage: §b使用/${project.artifactId} help 查看帮助!
permission: ${project.artifactId}.reload permission: ${project.artifactId}.reload
permission-message: §c你没有 <permission> 的权限来执行此命令! permission-message: §c你没有 <permission> 的权限来执行此命令!
mp: mp: null
permissions: permissions:
${project.artifactId}.reload:
description: 重新载入插件!
default: op
${project.artifactId}.reload: ${project.artifactId}.reload:
description: 重新载入插件! description: 重新载入插件!
default: op default: op