2019-10-17 16:04:43 -06:00
|
|
|
package dev.esophose.playerparticles.command;
|
2018-09-23 20:42:52 -06:00
|
|
|
|
2018-09-26 02:07:46 -06:00
|
|
|
import java.util.List;
|
|
|
|
|
2019-10-17 16:04:43 -06:00
|
|
|
import dev.esophose.playerparticles.manager.LangManager;
|
|
|
|
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
|
|
|
import dev.esophose.playerparticles.particles.PPlayer;
|
2018-09-23 20:42:52 -06:00
|
|
|
|
|
|
|
public interface CommandModule {
|
|
|
|
|
2018-09-27 18:58:05 -06:00
|
|
|
/**
|
|
|
|
* Called when this command gets executed
|
|
|
|
*
|
|
|
|
* @param pplayer The PPlayer who executed this command
|
|
|
|
* @param args The arguments to this command
|
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
void onCommandExecute(PPlayer pplayer, String[] args);
|
2018-09-27 18:58:05 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a player tries to tab complete this command
|
|
|
|
*
|
|
|
|
* @param pplayer The PPlayer who is tab completing this command
|
|
|
|
* @param args Arguments typed so far
|
2018-10-07 16:51:03 -06:00
|
|
|
* @return A list of possible argument values
|
2018-09-27 18:58:05 -06:00
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
List<String> onTabComplete(PPlayer pplayer, String[] args);
|
2018-09-27 18:58:05 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the name of this command
|
|
|
|
*
|
|
|
|
* @return The name of this command
|
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
String getName();
|
2018-09-27 18:58:05 -06:00
|
|
|
|
|
|
|
/**
|
2018-09-29 17:27:37 -06:00
|
|
|
* Gets the Lang description of this command
|
2018-09-27 18:58:05 -06:00
|
|
|
*
|
|
|
|
* @return The description of this command
|
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
Lang getDescription();
|
2018-09-27 18:58:05 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets any arguments this command has
|
|
|
|
*
|
|
|
|
* @return The arguments this command has
|
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
String getArguments();
|
2018-09-27 18:58:05 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if this command requires the player to have any effects
|
|
|
|
*
|
|
|
|
* @return If the player must have effects to use this command
|
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
boolean requiresEffects();
|
2019-07-16 01:32:45 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if this command can be executed from console, otherwise false
|
|
|
|
*/
|
|
|
|
boolean canConsoleExecute();
|
2018-09-29 17:27:37 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a command's usage to the player
|
|
|
|
*
|
|
|
|
* @param pplayer The PPlayer to display the command usage to
|
|
|
|
* @param command The command to display usage for
|
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
static void printUsage(PPlayer pplayer, CommandModule command) {
|
2018-11-28 23:26:20 -07:00
|
|
|
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_USAGE, command.getName(), command.getArguments());
|
2018-10-05 21:01:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a command's usage (with its description) to the player
|
|
|
|
*
|
|
|
|
* @param pplayer The PPlayer to display the command usage to
|
|
|
|
* @param command The command to display usage for
|
|
|
|
*/
|
2019-04-28 00:17:08 -06:00
|
|
|
static void printUsageWithDescription(PPlayer pplayer, CommandModule command) {
|
2018-10-05 21:01:28 -06:00
|
|
|
if (command.getArguments().length() == 0) {
|
2018-11-28 23:26:20 -07:00
|
|
|
LangManager.sendSimpleMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_HELP_1, command.getName(), LangManager.getText(command.getDescription()));
|
2018-10-05 21:01:28 -06:00
|
|
|
} else {
|
2018-11-28 23:26:20 -07:00
|
|
|
LangManager.sendSimpleMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_HELP_2, command.getName(), command.getArguments(), LangManager.getText(command.getDescription()));
|
2018-10-05 21:01:28 -06:00
|
|
|
}
|
2018-09-29 17:27:37 -06:00
|
|
|
}
|
2018-09-27 18:58:05 -06:00
|
|
|
|
2018-09-23 20:42:52 -06:00
|
|
|
}
|