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;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -23,13 +25,20 @@ public class CommandCaller implements CommandExecutor {
|
|||
public static void RegisterCommands() {
|
||||
if (instance == null)
|
||||
instance = new CommandCaller();
|
||||
for (TBMCCommandBase c : TBMCChatAPI.GetCommands().values()) {
|
||||
if (!c.GetCommandPath().contains("/")) // Top-level command
|
||||
for (Entry<String, TBMCCommandBase> entry : TBMCChatAPI.GetCommands().entrySet()) {
|
||||
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());
|
||||
if (pc == null)
|
||||
new Exception("Can't find top-level command: " + c.GetCommandPath() + " for plugin: "
|
||||
+ c.getPlugin().getName()).printStackTrace();
|
||||
TBMCCoreAPI.SendException("An error occured while registering commands",
|
||||
new Exception("Can't find top-level command: " + c.GetCommandPath() + " for plugin: "
|
||||
+ c.getPlugin().getName()));
|
||||
else
|
||||
pc.setExecutor(instance);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class HelpCommand extends UCommandBase {
|
|||
ArrayList<String> text = new ArrayList<String>();
|
||||
text.add("§6---- Command list ----");
|
||||
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values())
|
||||
if (!cmd.GetCommandPath().contains("/"))
|
||||
if (!cmd.GetCommandPath().contains(" "))
|
||||
text.add("/" + cmd.GetCommandPath());
|
||||
sender.sendMessage(text.toArray(new String[text.size()]));
|
||||
} else if (args[0].equalsIgnoreCase("colors")) {
|
||||
|
|
|
@ -8,7 +8,7 @@ public abstract class UCommandBase extends TBMCCommandBase {
|
|||
|
||||
@Override
|
||||
public String GetCommandPath() {
|
||||
return "u/" + GetUCommandPath();
|
||||
return "u " + GetUCommandPath();
|
||||
}
|
||||
|
||||
public abstract String GetUCommandPath();
|
||||
|
|
|
@ -8,7 +8,7 @@ public abstract class AdminCommandBase extends UCommandBase {
|
|||
|
||||
@Override
|
||||
public String GetUCommandPath() {
|
||||
return "admin/" + GetAdminCommandPath();
|
||||
return "admin " + GetAdminCommandPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ public abstract class AnnounceCommandBase extends UCommandBase {
|
|||
|
||||
@Override
|
||||
public String GetUCommandPath() {
|
||||
return "announce/" + GetAnnounceCommandPath();
|
||||
return "announce " + GetAnnounceCommandPath();
|
||||
}
|
||||
|
||||
public abstract String GetAnnounceCommandPath();
|
||||
|
|
Loading…
Reference in a new issue