Skip to content

Commit

Permalink
Fix some problems with the new command system
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Sep 6, 2024
1 parent 5efbca6 commit 9bcee73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pluginVersion=1.5.6
pluginVersion=1.5.7

minecraftVersion=1.20.1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
String commandString = commandStringWithVar.replaceFirst("/", "");

Command command = commands.get(commandString);

if (command == null) return;

if (CommandManager.defaultCommands.contains(command)) {
return;
Expand All @@ -43,9 +45,9 @@ public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {

for (String plugin : CommandManager.pluginMap.keySet()) {
Map<String, Command> commandMap = CommandManager.pluginMap.get(plugin);
PerWorldPlugins.getInstance().getLogger().warning(plugin);
if (PerWorldUtils.getDisabledWorlds(plugin).contains(event.getPlayer().getWorld().getName())) continue;
if (!commandMap.containsKey(commandString)) continue;


String commandStr;

Expand All @@ -54,10 +56,17 @@ public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
} else {
commandStr = plugin.toLowerCase(Locale.ENGLISH) + ":" + commandString;
}



possibleCommands.add(commandStr);
}

for (Command defaultCommand : CommandManager.defaultCommands) {
if (defaultCommand.getName().contains(":" + commandString)) {
possibleCommands.add(defaultCommand.getName());
}
}

if (possibleCommands.isEmpty() && commands.containsKey(commandString)) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&',
Objects.requireNonNull(PerWorldPlugins.getInstance().getConfig().getString("disabledCommandMessage")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ public class CommandManager implements Listener {
public static void addPluginCommands(String plugin) {
getCommands().keySet().stream().filter(str -> {
if (defaultCommands.contains(getCommands().get(str))) return false;
if (getCommands().get(str).getClass().getName().equals("org.bukkit.craftbukkit.command.VanillaCommandWrapper")) {
Map<String, Command> commandMap = pluginMap.get("minecraft");

if (commandMap == null) commandMap = new HashMap<>();
if (commandMap.containsKey(str)) return false;

commandMap.put(str, getCommands().get(str));
pluginMap.put("minecraft", commandMap);
return false;
}
if (getCommands().get(str).getClass().getName().equals("org.bukkit.craftbukkit.command.VanillaCommandWrapper")) return false;

for (Map<String, Command> commandMap : pluginMap.values()) {
if (commandMap.containsKey(str)) return false;
Expand Down

0 comments on commit 9bcee73

Please sign in to comment.