-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProhibitcommand-whes1015.java
More file actions
38 lines (29 loc) · 1.11 KB
/
Prohibitcommand-whes1015.java
File metadata and controls
38 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.command;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.player.PlayerCommandPreprocessEvent;
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.utils.Config;
import cn.nukkit.utils.TextFormat;
public class whes1015 extends PluginBase implements Listener {
private static whes1015 plugin;
private Config c;
@Override
public void onEnable() {
this.getLogger().info(TextFormat.BLUE + "ProhibitCommand whes1015 working! "+"V 1.0.0");
this.getServer().getPluginManager().registerEvents(this, this);
saveDefaultConfig();
}
@EventHandler
public void PlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent e) {
c = getConfig();
String cmd = e.getMessage().toLowerCase().replaceAll("\\s+","");
for (String str : c.getStringList("commands")) {
if (cmd.startsWith(str)) {
e.setCancelled(true);
e.getPlayer().sendMessage(TextFormat.RED+"該指令被禁止");
return;
}
}
}
}