Skip to content

Commit

Permalink
update 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiar committed Apr 29, 2022
1 parent 7d8babc commit 953a808
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,26 @@

public class CommandEvent implements Listener {

private FileConfiguration config;
private final FileConfiguration config;
Map<String, String> commandBypasses = new HashMap<>();
final String genbypass = "cmdblock.bypass.*";
boolean block = true;

public CommandEvent(Main pl) {
this.config = pl.getConfig();
}

List<String> cmds = config.getStringList("allowed-cmds");
List<String> staffcmds = config.getStringList("single-allowed-cmds");
String blockmsg = config.getString("blocked-command-message");
boolean BlockEnable = config.getBoolean("enabled");
String prefix = config.getString("prefix");
Map<String, String> commandBypasses = new HashMap<>();
final String genbypass = "cmdblock.bypass.*";
boolean block = true;


@EventHandler
public void CmdEvent(PlayerCommandPreprocessEvent event){
if (BlockEnable) {
if (config.getBoolean("enabled")) {
if (event.getPlayer().hasPermission(genbypass)) {
return;
}
String msg = blockmsg.replace("%prefix%",prefix).replace("%player%",event.getPlayer().getDisplayName()).replace("%command%",event.getMessage());
for (String staffalcmds : staffcmds) {
for (String staffalcmds : config.getStringList("single-allowed-cmds")) {
commandBypasses.put(staffalcmds, "cmdblock.bypass." + staffalcmds.substring(1));
}
for (String alcmd : cmds) {
for (String alcmd : config.getStringList("allowed-cmds")) {
if (StringUtils.startsWithIgnoreCase(event.getMessage(), alcmd)) {
block = false;
break;
Expand All @@ -54,7 +48,7 @@ public void CmdEvent(PlayerCommandPreprocessEvent event){
}
if (block) {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&',msg));
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&',config.getString("blocked-command-message").replace("%prefix%",config.getString("prefix")).replace("%player%",event.getPlayer().getDisplayName()).replace("%command%",event.getMessage())));
}
}
}
Expand Down

0 comments on commit 953a808

Please sign in to comment.