From afe178b2c246ad41e95e0b9338958943574ab9c1 Mon Sep 17 00:00:00 2001 From: 9378062 Date: Fri, 8 Apr 2022 09:36:52 -0400 Subject: [PATCH] i forgor to register the service. also removed useless arraylist --- .../cmdblocker/CommandBlockerManager.java | 30 +++++++++---------- .../dev/plex/services/ServiceManager.java | 6 ++-- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java b/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java index 43fa5f7..ebfcbc4 100644 --- a/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java +++ b/src/main/java/dev/plex/cmdblocker/CommandBlockerManager.java @@ -25,26 +25,24 @@ public class CommandBlockerManager for (String cmd : raw) { - List pieces = new ArrayList<>(); - int lastDelim = cmd.lastIndexOf(':'); String cmdWithoutMsg = cmd.substring(0, lastDelim); String[] rawPieces = cmdWithoutMsg.split(":", 3); - pieces.add(rawPieces[0].toLowerCase()); // type - pieces.add(rawPieces[1].toLowerCase()); // rank - pieces.add(rawPieces[2]); // RegEx or match - pieces.add(cmd.substring(lastDelim + 1)); // Message (w/o : in it) + String rawType = rawPieces[0].toLowerCase(); + String rawRank = rawPieces[1].toLowerCase(); + String regexOrMatch = rawPieces[2]; + String message = cmd.substring(lastDelim + 1); - if (pieces.get(3).equals("_")) + if (message.equals("_")) { - pieces.set(3, PlexUtils.messageString("commandBlocked")); + message = PlexUtils.messageString("commandBlocked"); } Rank rank; - switch (pieces.get(1)) + switch (rawRank) { case "i": rank = Rank.IMPOSTOR; @@ -68,21 +66,21 @@ public class CommandBlockerManager rank = Rank.EXECUTIVE; } - if (pieces.get(0).equals("r")) + if (rawType.equals("r")) { - blockedCommands.add(new RegexCommand(Pattern.compile(pieces.get(2), Pattern.CASE_INSENSITIVE), rank, pieces.get(3))); + blockedCommands.add(new RegexCommand(Pattern.compile(regexOrMatch, Pattern.CASE_INSENSITIVE), rank, message)); } - else if (pieces.get(0).equals("m")) + else if (rawType.equals("m")) { - String blockedArgs = pieces.get(2).substring(pieces.get(2).indexOf(' ') + 1); - PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(pieces.get(2).substring(0, pieces.get(2).indexOf(' '))); + String blockedArgs = regexOrMatch.substring(regexOrMatch.indexOf(' ') + 1); + PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(regexOrMatch.substring(0, regexOrMatch.indexOf(' '))); if (pluginCommand != null) { - blockedCommands.add(new MatchCommand(pluginCommand.getName() + " " + blockedArgs, rank, pieces.get(3))); + blockedCommands.add(new MatchCommand(pluginCommand.getName() + " " + blockedArgs, rank, message)); List aliases = pluginCommand.getAliases(); for (String alias : aliases) { - blockedCommands.add(new MatchCommand(alias + " " + blockedArgs, rank, pieces.get(3))); + blockedCommands.add(new MatchCommand(alias + " " + blockedArgs, rank, message)); } } } diff --git a/src/main/java/dev/plex/services/ServiceManager.java b/src/main/java/dev/plex/services/ServiceManager.java index f822215..fc73390 100644 --- a/src/main/java/dev/plex/services/ServiceManager.java +++ b/src/main/java/dev/plex/services/ServiceManager.java @@ -2,10 +2,7 @@ package dev.plex.services; import com.google.common.collect.Lists; import dev.plex.Plex; -import dev.plex.services.impl.AutoWipeService; -import dev.plex.services.impl.BanService; -import dev.plex.services.impl.GameRuleService; -import dev.plex.services.impl.UpdateCheckerService; +import dev.plex.services.impl.*; import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitTask; @@ -21,6 +18,7 @@ public class ServiceManager registerService(new GameRuleService()); registerService(new UpdateCheckerService()); registerService(new AutoWipeService()); + registerService(new CmdBlockerService()); } public void startServices()