mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Add command disabling
This commit is contained in:
1 parent
632d43d131
commit
6cd2a23770
7 files changed
+59
-12
No files matched your search
@@ -4,6 +4,8 @@ import io.papermc.lib.PaperLib;
|
||||
import net.william278.annotaml.Annotaml;
|
||||
import net.william278.huskhomes.command.BukkitCommand;
|
||||
import net.william278.huskhomes.command.BukkitCommandType;
|
||||
import net.william278.huskhomes.command.ConsoleExecutable;
|
||||
import net.william278.huskhomes.command.DisabledCommand;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.config.Spawn;
|
||||
@@ -172,12 +174,26 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
})));
|
||||
|
||||
// Register commands
|
||||
for (final BukkitCommandType bukkitCommandType : BukkitCommandType.values()) {
|
||||
final PluginCommand pluginCommand = getCommand(bukkitCommandType.commandBase.command);
|
||||
if (pluginCommand != null) {
|
||||
new BukkitCommand(bukkitCommandType.commandBase, this).register(pluginCommand);
|
||||
Arrays.stream(BukkitCommandType.values()).forEach(commandType -> {
|
||||
final PluginCommand pluginCommand = getCommand(commandType.commandBase.command);
|
||||
if (pluginCommand == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If the command is disabled, use the disabled CommandBase
|
||||
if (settings.disabledCommands.stream().anyMatch(disabledCommand -> {
|
||||
final String command = (disabledCommand.startsWith("/") ? disabledCommand.substring(1) : disabledCommand);
|
||||
return command.equalsIgnoreCase(commandType.commandBase.command) ||
|
||||
Arrays.stream(commandType.commandBase.aliases)
|
||||
.anyMatch(alias -> alias.equalsIgnoreCase(command));
|
||||
})) {
|
||||
new BukkitCommand(new DisabledCommand(this), this).register(pluginCommand);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, register the command
|
||||
new BukkitCommand(commandType.commandBase, this).register(pluginCommand);
|
||||
});
|
||||
getLoggingAdapter().log(Level.INFO, "Successfully registered permissions & commands.");
|
||||
|
||||
// Hook into bStats metrics
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BukkitCommand implements CommandExecutor, TabExecutor {
|
||||
pluginCommand.setDescription(command.getDescription());
|
||||
pluginCommand.setExecutor(this);
|
||||
pluginCommand.setTabCompleter(this);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package net.william278.huskhomes.command;
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Commands available on the Bukkit HuskHomes implementation
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user