Skip to content

Commit

Permalink
Actually send messages from filtered commands and boo exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberpwnn committed Aug 13, 2016
1 parent f385d05 commit 6dda2cf
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/org/phantomapi/command/CommandBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.phantomapi.command.CommandFilter.PlayerOnly;
import org.phantomapi.command.CommandFilter.SubCommands;
import org.phantomapi.text.MessageBuilder;
import org.phantomapi.util.C;
import org.phantomapi.util.M;

public class CommandBus
Expand All @@ -35,13 +36,16 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma

for(CommandListener i : c.getRegistry().get(root.toLowerCase()))
{
PhantomCommandSender psx = new PhantomSender(sender);
psx.setMessageBuilder(new MessageBuilder(i));

if(hasFilter(i, ArgumentRange.class))
{
ArgumentRange ar = (ArgumentRange) getFilter(i, ArgumentRange.class);

if(!M.within(M.min(ar.value()), M.max(ar.value()), args.length))
{
i.getMessageInvalidArguments(args.length, M.min(ar.value()), M.max(ar.value()));
psx.sendMessage(i.getMessageInvalidArguments(args.length, M.min(ar.value()), M.max(ar.value())));
continue;
}
}
Expand All @@ -50,7 +54,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma
{
if(sender instanceof Player)
{
i.getMessageNotConsole();
psx.sendMessage(i.getMessageNotConsole());
continue;
}
}
Expand All @@ -59,7 +63,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma
{
if(!(sender instanceof Player))
{
i.getMessageNotPlayer();
psx.sendMessage(i.getMessageNotPlayer());
continue;
}
}
Expand All @@ -68,7 +72,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma
{
if(!sender.isOp())
{
i.getMessageNoPermission();
psx.sendMessage(i.getMessageNoPermission());
continue;
}
}
Expand All @@ -79,7 +83,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma

if(!sender.hasPermission(p.value()))
{
i.getMessageNoPermission();
psx.sendMessage(i.getMessageNoPermission());
continue;
}
}
Expand All @@ -101,7 +105,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma

if(f)
{
i.getMessageNoPermission();
psx.sendMessage(i.getMessageNoPermission());
continue;
}
}
Expand All @@ -112,7 +116,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma

if(s.value().length > args.length)
{
i.getMessageUnknownSubCommand(args.toString());
psx.sendMessage(i.getMessageUnknownSubCommand(args.toString()));
continue;
}

Expand All @@ -129,7 +133,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma

if(f)
{
i.getMessageUnknownSubCommand(args.toString());
psx.sendMessage(i.getMessageUnknownSubCommand(args.toString()));
continue;
}
}
Expand All @@ -151,6 +155,7 @@ public CommandBus(CommandRegistryController c, String root, String[] args, Comma
{
result = CommandResult.EXCEPTION;
e.printStackTrace();
sender.sendMessage(C.RED + "#Boo" + e.getClass().getSimpleName() + "s");
}
}
}
Expand Down

0 comments on commit 6dda2cf

Please sign in to comment.