Commands
Create command listeners without limit
You can handle commands on a separate layer if you wish while using phantomapi. This layer works above the bukkit command api, allowing you to override all bukkit commands before they touch other plugins. Here are some benefits while using phantom command regristry.
- Dynamic Registry and Unregistry
- Dynamically create aliases and change them anytime
- No configuration with the plugin.yml file
- Command Filters and messaging handled before it hits your listener
- Custom Command sender for RawText, Tags, and MessageProviders
Creating a Command Controller
Lets create the most basic CommandController without handling anything.
package org.phantomapi.example;
import org.phantomapi.command.CommandController;
import org.phantomapi.command.PhantomCommand;
import org.phantomapi.command.PhantomCommandSender;
import org.phantomapi.construct.Controllable;
public class CommandHandler extends CommandController
{
public CommandHandler(Controllable parentController)
{
super(parentController, "command-name");
}
@Override
public boolean onCommand(PhantomCommandSender sender, PhantomCommand command)
{
return false;
}
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
}
Controller registry handles command registry, however you can dynamically re-register them if need be.
Hotdrop Command Listeners
In any controller you can now hotdrop methods as command listeners with filters.
package org.phantomapi;
import org.phantomapi.command.Command;
import org.phantomapi.command.CommandFilter;
import org.phantomapi.command.PhantomCommand;
import org.phantomapi.command.PhantomSender;
import org.phantomapi.construct.Controllable;
import org.phantomapi.construct.Controller;
public class BasicController extends Controller
{
public BasicController(Controllable parentController)
{
super(parentController);
}
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@Command("testing")
@CommandFilter.PlayerOnly
@CommandFilter.Permission("test.green")
@CommandFilter.SubCommands("green")
public void onCommandGreen(PhantomSender sender, PhantomCommand cmd)
{
//Fires this when a player with the permission test.green
//uses the command /testing green
}
@Command("testing")
@CommandFilter.ConsoleOnly
@CommandFilter.SubCommands("red")
public void onCommandRed(PhantomSender sender, PhantomCommand cmd)
{
//Fires this when a console
//uses the command /testing red
}
}