Made command paths a bit more logical
This commit is contained in:
parent
398912353b
commit
cd490e5769
5 changed files with 17 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
||||||
package buttondevteam.chat.commands;
|
package buttondevteam.chat.commands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -23,13 +25,20 @@ public class CommandCaller implements CommandExecutor {
|
||||||
public static void RegisterCommands() {
|
public static void RegisterCommands() {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
instance = new CommandCaller();
|
instance = new CommandCaller();
|
||||||
for (TBMCCommandBase c : TBMCChatAPI.GetCommands().values()) {
|
for (Entry<String, TBMCCommandBase> entry : TBMCChatAPI.GetCommands().entrySet()) {
|
||||||
if (!c.GetCommandPath().contains("/")) // Top-level command
|
TBMCCommandBase c = entry.getValue();
|
||||||
|
if (c == null) {
|
||||||
|
TBMCCoreAPI.SendException("An error occured while registering commands",
|
||||||
|
new Exception("Null command found at " + entry.getKey() + "!"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!c.GetCommandPath().contains(" ")) // Top-level command
|
||||||
{
|
{
|
||||||
PluginCommand pc = ((JavaPlugin) c.getPlugin()).getCommand(c.GetCommandPath());
|
PluginCommand pc = ((JavaPlugin) c.getPlugin()).getCommand(c.GetCommandPath());
|
||||||
if (pc == null)
|
if (pc == null)
|
||||||
|
TBMCCoreAPI.SendException("An error occured while registering commands",
|
||||||
new Exception("Can't find top-level command: " + c.GetCommandPath() + " for plugin: "
|
new Exception("Can't find top-level command: " + c.GetCommandPath() + " for plugin: "
|
||||||
+ c.getPlugin().getName()).printStackTrace();
|
+ c.getPlugin().getName()));
|
||||||
else
|
else
|
||||||
pc.setExecutor(instance);
|
pc.setExecutor(instance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class HelpCommand extends UCommandBase {
|
||||||
ArrayList<String> text = new ArrayList<String>();
|
ArrayList<String> text = new ArrayList<String>();
|
||||||
text.add("§6---- Command list ----");
|
text.add("§6---- Command list ----");
|
||||||
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values())
|
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values())
|
||||||
if (!cmd.GetCommandPath().contains("/"))
|
if (!cmd.GetCommandPath().contains(" "))
|
||||||
text.add("/" + cmd.GetCommandPath());
|
text.add("/" + cmd.GetCommandPath());
|
||||||
sender.sendMessage(text.toArray(new String[text.size()]));
|
sender.sendMessage(text.toArray(new String[text.size()]));
|
||||||
} else if (args[0].equalsIgnoreCase("colors")) {
|
} else if (args[0].equalsIgnoreCase("colors")) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ public abstract class UCommandBase extends TBMCCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetCommandPath() {
|
public String GetCommandPath() {
|
||||||
return "u/" + GetUCommandPath();
|
return "u " + GetUCommandPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String GetUCommandPath();
|
public abstract String GetUCommandPath();
|
||||||
|
|
|
@ -8,7 +8,7 @@ public abstract class AdminCommandBase extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetUCommandPath() {
|
public String GetUCommandPath() {
|
||||||
return "admin/" + GetAdminCommandPath();
|
return "admin " + GetAdminCommandPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,7 +8,7 @@ public abstract class AnnounceCommandBase extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetUCommandPath() {
|
public String GetUCommandPath() {
|
||||||
return "announce/" + GetAnnounceCommandPath();
|
return "announce " + GetAnnounceCommandPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String GetAnnounceCommandPath();
|
public abstract String GetAnnounceCommandPath();
|
||||||
|
|
Loading…
Reference in a new issue