mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
i forgor
to register the service. also removed useless arraylist
This commit is contained in:
parent
92eb900f22
commit
afe178b2c2
@ -25,26 +25,24 @@ public class CommandBlockerManager
|
|||||||
|
|
||||||
for (String cmd : raw)
|
for (String cmd : raw)
|
||||||
{
|
{
|
||||||
List<String> pieces = new ArrayList<>();
|
|
||||||
|
|
||||||
int lastDelim = cmd.lastIndexOf(':');
|
int lastDelim = cmd.lastIndexOf(':');
|
||||||
|
|
||||||
String cmdWithoutMsg = cmd.substring(0, lastDelim);
|
String cmdWithoutMsg = cmd.substring(0, lastDelim);
|
||||||
String[] rawPieces = cmdWithoutMsg.split(":", 3);
|
String[] rawPieces = cmdWithoutMsg.split(":", 3);
|
||||||
|
|
||||||
pieces.add(rawPieces[0].toLowerCase()); // type
|
String rawType = rawPieces[0].toLowerCase();
|
||||||
pieces.add(rawPieces[1].toLowerCase()); // rank
|
String rawRank = rawPieces[1].toLowerCase();
|
||||||
pieces.add(rawPieces[2]); // RegEx or match
|
String regexOrMatch = rawPieces[2];
|
||||||
pieces.add(cmd.substring(lastDelim + 1)); // Message (w/o : in it)
|
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;
|
Rank rank;
|
||||||
|
|
||||||
switch (pieces.get(1))
|
switch (rawRank)
|
||||||
{
|
{
|
||||||
case "i":
|
case "i":
|
||||||
rank = Rank.IMPOSTOR;
|
rank = Rank.IMPOSTOR;
|
||||||
@ -68,21 +66,21 @@ public class CommandBlockerManager
|
|||||||
rank = Rank.EXECUTIVE;
|
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);
|
String blockedArgs = regexOrMatch.substring(regexOrMatch.indexOf(' ') + 1);
|
||||||
PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(pieces.get(2).substring(0, pieces.get(2).indexOf(' ')));
|
PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(regexOrMatch.substring(0, regexOrMatch.indexOf(' ')));
|
||||||
if (pluginCommand != null)
|
if (pluginCommand != null)
|
||||||
{
|
{
|
||||||
blockedCommands.add(new MatchCommand(pluginCommand.getName() + " " + blockedArgs, rank, pieces.get(3)));
|
blockedCommands.add(new MatchCommand(pluginCommand.getName() + " " + blockedArgs, rank, message));
|
||||||
List<String> aliases = pluginCommand.getAliases();
|
List<String> aliases = pluginCommand.getAliases();
|
||||||
for (String alias : aliases)
|
for (String alias : aliases)
|
||||||
{
|
{
|
||||||
blockedCommands.add(new MatchCommand(alias + " " + blockedArgs, rank, pieces.get(3)));
|
blockedCommands.add(new MatchCommand(alias + " " + blockedArgs, rank, message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,7 @@ package dev.plex.services;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.services.impl.AutoWipeService;
|
import dev.plex.services.impl.*;
|
||||||
import dev.plex.services.impl.BanService;
|
|
||||||
import dev.plex.services.impl.GameRuleService;
|
|
||||||
import dev.plex.services.impl.UpdateCheckerService;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -21,6 +18,7 @@ public class ServiceManager
|
|||||||
registerService(new GameRuleService());
|
registerService(new GameRuleService());
|
||||||
registerService(new UpdateCheckerService());
|
registerService(new UpdateCheckerService());
|
||||||
registerService(new AutoWipeService());
|
registerService(new AutoWipeService());
|
||||||
|
registerService(new CmdBlockerService());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startServices()
|
public void startServices()
|
||||||
|
Loading…
Reference in New Issue
Block a user