Skip to content

Commit

Permalink
Add aliases to some commands and code reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmq committed Aug 17, 2024
1 parent 01c2d46 commit 2e3ee65
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void printHelp(CommandSender sender, String label) {
subCommands.forEach(subCommand -> {
SubCommandMeta subCommandMeta = subCommand.getClass().getAnnotation(SubCommandMeta.class);
if (sender.hasPermission(subCommandMeta.permission()) || subCommandMeta.permission().equals("")) {
if ((subCommandMeta.playerOnly() && sender instanceof Player) || !subCommandMeta.playerOnly()) {
if (!subCommandMeta.playerOnly() || sender instanceof Player) {
sender.sendMessage(HELP_CMD_FORMAT
.replace("%maincommand%", label)
.replace("%subcommand%", subCommandMeta.usage().equals("") ? subCommandMeta.command() : subCommandMeta.command() + " " + subCommandMeta.usage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

@SubCommandMeta(
command = "help",
aliases = {"gethelp"},
permission = "pyspigot.command.help",
description = "Useful information for PySpigot and how to get help",
aliases = {"gethelp"}
description = "Useful information for PySpigot and how to get help"
)
public class HelpCommand implements SubCommand {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

@SubCommandMeta(
command = "info",
aliases = {"scriptinfo"},
permission = "pyspigot.command.info",
description = "Print information about a script, including uptime, registered listeners, commands, and more info",
aliases = {"scriptinfo"},
usage = "<scriptname>"
)
public class InfoCommand implements SubCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

@SubCommandMeta(
command = "listscripts",
aliases = {"list", "scriptslist", "ls"},
permission = "pyspigot.command.listscripts",
description = "List all scripts",
aliases = {"list", "scriptslist", "ls"},
usage = "[page]"
)
public class ListScriptsCommand implements SubCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

@SubCommandMeta(
command = "load",
aliases = {"start"},
permission = "pyspigot.command.load",
description = "Load a script with the specified name",
usage = "<scriptname>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@SubCommandMeta(
command = "reloadall",
aliases = {"reset"},
aliases = {"resetall"},
permission = "pyspigot.command.reloadall",
description = "Perform a complete reload of the plugin, including configs, libraries, and all scripts."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

@SubCommandMeta(
command = "reload",
aliases = {"restart"},
permission = "pyspigot.command.reload",
description = "Reload a script with the specified name",
usage = "<scriptname>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

@SubCommandMeta(
command = "unload",
aliases = {"stop"},
permission = "pyspigot.command.unload",
description = "Unload a script with the specified name",
usage = "<scriptname>"
Expand Down

0 comments on commit 2e3ee65

Please sign in to comment.