Remove getCommandMap() method in CommandBlocker

This commit is contained in:
Allink 2023-07-25 16:40:25 +01:00
parent b4dd35c4df
commit 794a25ba16
No known key found for this signature in database

View File

@ -30,24 +30,6 @@ public class CommandBlocker extends FreedomService
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
private final List<String> unknownCommands = Lists.newArrayList();
public static CommandMap getCommandMap()
{
try
{
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
commandMapField.setAccessible(true);
return (SimpleCommandMap)commandMapField.get(simplePluginManager);
}
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
{
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
}
return null;
}
@Override
public void onStart()
{
@ -65,7 +47,7 @@ public class CommandBlocker extends FreedomService
entryList.clear();
unknownCommands.clear();
final CommandMap commandMap = getCommandMap();
final CommandMap commandMap = Bukkit.getCommandMap();
@SuppressWarnings("unchecked")
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();