Updated commands to new APF 3.2.0 commands, better help formatting

This commit is contained in:
Rsl1122 2018-04-09 23:50:29 +03:00
parent 58592f0777
commit a27175e136
32 changed files with 265 additions and 414 deletions

View File

@ -29,7 +29,7 @@
<dependency> <dependency>
<groupId>com.djrapitops</groupId> <groupId>com.djrapitops</groupId>
<artifactId>AbstractPluginFramework</artifactId> <artifactId>AbstractPluginFramework</artifactId>
<version>3.1.1</version> <version>3.2.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- SoftDepended Plugins --> <!-- SoftDepended Plugins -->
<dependency> <dependency>

View File

@ -102,29 +102,8 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
} }
@Override @Override
public void log(String level, String msg) { public Logger getLogger() {
switch (level.toUpperCase()) { return logger;
case "INFO_COLOR":
case "INFO":
case "I":
logger.info(msg);
break;
case "W":
case "WARN":
case "WARNING":
logger.warn(msg);
break;
case "E":
case "ERR":
case "ERROR":
case "SEVERE":
logger.error(msg);
break;
default:
logger.info(msg);
break;
}
} }
@Override @Override

View File

@ -6,9 +6,10 @@ import com.djrapitops.plan.command.commands.manage.ManageConDebugCommand;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.TreeCmdNode;
import com.djrapitops.plugin.command.defaultcmds.StatusCommand; import com.djrapitops.plugin.command.defaultcmds.StatusCommandNode;
/** /**
* TreeCommand for the /plan command, and all subcommands. * TreeCommand for the /plan command, and all subcommands.
@ -18,7 +19,7 @@ import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
* @author Rsl1122 * @author Rsl1122
* @since 1.0.0 * @since 1.0.0
*/ */
public class PlanBungeeCommand extends TreeCommand<PlanBungee> { public class PlanBungeeCommand extends TreeCmdNode {
/** /**
* CommandExecutor class Constructor. * CommandExecutor class Constructor.
@ -28,31 +29,27 @@ public class PlanBungeeCommand extends TreeCommand<PlanBungee> {
* @param plugin Current instance of Plan * @param plugin Current instance of Plan
*/ */
public PlanBungeeCommand(PlanBungee plugin) { public PlanBungeeCommand(PlanBungee plugin) {
super(plugin, "planbungee", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), "", "planbungee"); super("planbungee", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, null);
super.setDefaultCommand("help");
super.setColorScheme(plugin.getColorScheme()); super.setColorScheme(plugin.getColorScheme());
} setInDepthHelp(Locale.get(Msg.CMD_HELP_PLAN).toArray());
@Override
public String[] addHelp() {
return Locale.get(Msg.CMD_HELP_PLAN).toArray();
}
@Override
public void addCommands() {
add(
new ReloadCommand(plugin),
new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
new ListCommand(),
new BungeeSetupToggleCommand()
);
RegisterCommand registerCommand = new RegisterCommand(); RegisterCommand registerCommand = new RegisterCommand();
add( setNodeGroups(
registerCommand, new CommandNode[]{
new WebUserCommand(plugin, registerCommand), new NetworkCommand(),
new NetworkCommand(), new ListServersCommand(plugin),
new ListServersCommand(plugin), new ListCommand(),
new ManageConDebugCommand() },
new CommandNode[]{
registerCommand,
new WebUserCommand(plugin, registerCommand, this),
},
new CommandNode[]{
new ManageConDebugCommand(),
new BungeeSetupToggleCommand(),
new ReloadCommand(plugin),
new StatusCommandNode<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
}
); );
} }
} }

View File

@ -6,9 +6,10 @@ import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.TreeCmdNode;
import com.djrapitops.plugin.command.defaultcmds.StatusCommand; import com.djrapitops.plugin.command.defaultcmds.StatusCommandNode;
/** /**
* TreeCommand for the /plan command, and all SubCommands. * TreeCommand for the /plan command, and all SubCommands.
@ -18,41 +19,35 @@ import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
* @author Rsl1122 * @author Rsl1122
* @since 1.0.0 * @since 1.0.0
*/ */
public class PlanCommand extends TreeCommand<Plan> { public class PlanCommand extends TreeCmdNode {
public PlanCommand(Plan plugin) { public PlanCommand(Plan plugin) {
super(plugin, "plan", CommandType.CONSOLE, "", "", "plan"); super("plan", "", CommandType.CONSOLE, null);
super.setDefaultCommand("inspect"); super.setDefaultCommand("inspect");
super.setColorScheme(plugin.getColorScheme()); super.setColorScheme(plugin.getColorScheme());
} setInDepthHelp(Locale.get(Msg.CMD_HELP_PLAN).toArray());
@Override
public String[] addHelp() {
return Locale.get(Msg.CMD_HELP_PLAN).toArray();
}
@Override
public void addCommands() {
add(
new InspectCommand(),
new QInspectCommand(plugin),
new AnalyzeCommand(),
new SearchCommand(),
new InfoCommand(plugin),
new ReloadCommand(plugin),
new ManageCommand(plugin),
new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
new ListCommand()
);
RegisterCommand registerCommand = new RegisterCommand(); RegisterCommand registerCommand = new RegisterCommand();
add( setNodeGroups(
registerCommand, new CommandNode[]{
new WebUserCommand(plugin, registerCommand), new InspectCommand(),
new NetworkCommand(), new QInspectCommand(plugin),
new ListServersCommand(plugin)); new SearchCommand(),
new ListCommand(),
if (Settings.DEV_MODE.isTrue()) { new AnalyzeCommand(),
add(new DevCommand()); new NetworkCommand(),
} },
new CommandNode[]{
new WebUserCommand(plugin, registerCommand, this),
registerCommand
},
new CommandNode[]{
new InfoCommand(plugin),
new ReloadCommand(plugin),
new ManageCommand(plugin, this),
new StatusCommandNode<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
(Settings.DEV_MODE.isTrue() ? new DevCommand() : null)
}
);
} }
} }

View File

@ -14,10 +14,10 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.system.webserver.WebServerSystem;
import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.analysis.Analysis;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import java.util.Map; import java.util.Map;
@ -30,23 +30,17 @@ import java.util.UUID;
* @author Rsl1122 * @author Rsl1122
* @since 2.0.0 * @since 2.0.0
*/ */
public class AnalyzeCommand extends SubCommand { public class AnalyzeCommand extends CommandNode {
public AnalyzeCommand() { public AnalyzeCommand() {
super("analyze, analyse, analysis, a", super("analyze|analyse|analysis|a", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_ANALYZE).parse());
Permissions.ANALYZE.getPermission(), setInDepthHelp(Locale.get(Msg.CMD_HELP_ANALYZE).toArray());
Locale.get(Msg.CMD_USG_ANALYZE).parse(), setArguments("[server/id]");
"[ServerName or ID]");
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_ANALYZE).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString()); sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString());
Processing.submitNonCritical(() -> { Processing.submitNonCritical(() -> {
@ -63,7 +57,6 @@ public class AnalyzeCommand extends SubCommand {
Log.toLog(this.getClass(), e); Log.toLog(this.getClass(), e);
} }
}); });
return true;
} }
private void sendLink(Server server, ISender sender) { private void sendLink(Server server, ISender sender) {

View File

@ -6,25 +6,26 @@ package com.djrapitops.plan.command.commands;
import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
/** /**
* Command for Toggling whether or not BungeeCord accepts set up requests. * Command for Toggling whether or not BungeeCord accepts set up requests.
* * <p>
* This was added as a security measure against unwanted MySQL snooping. * This was added as a security measure against unwanted MySQL snooping.
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class BungeeSetupToggleCommand extends SubCommand { public class BungeeSetupToggleCommand extends CommandNode {
public BungeeSetupToggleCommand() { public BungeeSetupToggleCommand() {
super("setup", CommandType.ALL, Permissions.MANAGE.getPermission(), "Toggle Setup mode for Bungee"); super("setup", Permissions.MANAGE.getPermission(), CommandType.ALL);
setShortHelp("Toggle Setup mode for Bungee");
} }
@Override @Override
public boolean onCommand(ISender sender, String s, String[] strings) { public void onCommand(ISender sender, String s, String[] strings) {
boolean setupAllowed = ConnectionSystem.isSetupAllowed(); boolean setupAllowed = ConnectionSystem.isSetupAllowed();
ConnectionSystem connectionSystem = ConnectionSystem.getInstance(); ConnectionSystem connectionSystem = ConnectionSystem.getInstance();
@ -35,6 +36,5 @@ public class BungeeSetupToggleCommand extends SubCommand {
} }
String msg = !setupAllowed ? "§aSet-up is now Allowed" : "§cSet-up is now Forbidden"; String msg = !setupAllowed ? "§aSet-up is now Allowed" : "§cSet-up is now Forbidden";
sender.sendMessage(msg); sender.sendMessage(msg);
return true;
} }
} }

View File

@ -8,25 +8,25 @@ import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
/** /**
* Command used for testing functions that are too difficult to unit test. * Command used for testing functions that are too difficult to unit test.
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class DevCommand extends SubCommand { public class DevCommand extends CommandNode {
public DevCommand() { public DevCommand() {
super("dev", CommandType.PLAYER_OR_ARGS, "plan.*", "Test Plugin functions not testable with unit tests.", "<feature to test>"); super("dev", CommandType.PLAYER_OR_ARGS, "plan.*", "Test Plugin functions not testable with unit tests.", "<feature to test>");
} }
@Override @Override
public boolean onCommand(ISender sender, String cmd, String[] args) { public void onCommand(ISender sender, String cmd, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return;
} }
String feature = args[0]; String feature = args[0];
switch (feature) { switch (feature) {
@ -45,6 +45,5 @@ public class DevCommand extends SubCommand {
default: default:
break; break;
} }
return true;
} }
} }

View File

@ -6,9 +6,9 @@ import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.update.VersionCheckSystem;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
/** /**
@ -17,21 +17,18 @@ import com.djrapitops.plugin.settings.ColorScheme;
* @author Rsl1122 * @author Rsl1122
* @since 2.0.0 * @since 2.0.0
*/ */
public class InfoCommand extends SubCommand { public class InfoCommand extends CommandNode {
private final Plan plugin; private final Plan plugin;
public InfoCommand(Plan plugin) { public InfoCommand(Plan plugin) {
super("info", super("info", Permissions.INFO.getPermission(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_INFO).toString());
Permissions.INFO.getPermission(),
Locale.get(Msg.CMD_USG_INFO).toString());
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
ColorScheme cs = plugin.getColorScheme(); ColorScheme cs = plugin.getColorScheme();
String mColor = cs.getMainColor(); String mColor = cs.getMainColor();
String sColor = cs.getSecondaryColor(); String sColor = cs.getSecondaryColor();
@ -47,7 +44,6 @@ public class InfoCommand extends SubCommand {
Locale.get(Msg.CMD_CONSTANT_FOOTER).toString() Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()
}; };
sender.sendMessage(messages); sender.sendMessage(messages);
return true;
} }
} }

View File

@ -13,10 +13,10 @@ import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plan.utilities.uuid.UUIDUtility;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
@ -30,27 +30,20 @@ import java.util.UUID;
* @author Rsl1122 * @author Rsl1122
* @since 1.0.0 * @since 1.0.0
*/ */
public class InspectCommand extends SubCommand { public class InspectCommand extends CommandNode {
public InspectCommand() { public InspectCommand() {
super("inspect", super("inspect", Permissions.INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setArguments("<player>");
Permissions.INSPECT.getPermission(), setShortHelp(Locale.get(Msg.CMD_USG_INSPECT).toString());
Locale.get(Msg.CMD_USG_INSPECT).toString(), setInDepthHelp(Locale.get(Msg.CMD_HELP_INSPECT).toArray());
"<player>");
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_INSPECT).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
String playerName = MiscUtils.getPlayerName(args, sender); String playerName = MiscUtils.getPlayerName(args, sender);
runInspectTask(playerName, sender); runInspectTask(playerName, sender);
return true;
} }
private void runInspectTask(String playerName, ISender sender) { private void runInspectTask(String playerName, ISender sender) {

View File

@ -4,10 +4,10 @@ import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
/** /**
* Command used to display url to the player list page. * Command used to display url to the player list page.
@ -15,22 +15,17 @@ import com.djrapitops.plugin.command.SubCommand;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
*/ */
public class ListCommand extends SubCommand { public class ListCommand extends CommandNode {
public ListCommand() { public ListCommand() {
super("list, pl, playerlist, players", CommandType.CONSOLE, Permissions.INSPECT_OTHER.getPermission(), Locale.get(Msg.CMD_USG_LIST).toString(), ""); super("players|pl|playerlist|list", Permissions.INSPECT_OTHER.getPermission(), CommandType.CONSOLE);
setShortHelp(Locale.get(Msg.CMD_USG_LIST).toString());
setInDepthHelp(Locale.get(Msg.CMD_HELP_LIST).toArray());
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_LIST).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
sendListMsg(sender); sendListMsg(sender);
return true;
} }
private void sendListMsg(ISender sender) { private void sendListMsg(ISender sender) {

View File

@ -8,9 +8,9 @@ import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import java.util.List; import java.util.List;
@ -20,7 +20,7 @@ import java.util.List;
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class ListServersCommand extends SubCommand { public class ListServersCommand extends CommandNode {
private final PlanPlugin plugin; private final PlanPlugin plugin;
@ -28,13 +28,14 @@ public class ListServersCommand extends SubCommand {
super("servers, serverlist, listservers, sl", super("servers, serverlist, listservers, sl",
CommandType.CONSOLE, CommandType.CONSOLE,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
"List servers in the network"); "List servers in the network",
"");
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
ColorScheme colorScheme = plugin.getColorScheme(); ColorScheme colorScheme = plugin.getColorScheme();
String mCol = colorScheme.getMainColor(); String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor(); String sCol = colorScheme.getSecondaryColor();
@ -50,7 +51,6 @@ public class ListServersCommand extends SubCommand {
sender.sendMessage("§cDatabase Exception occurred."); sender.sendMessage("§cDatabase Exception occurred.");
Log.toLog(this.getClass(), e); Log.toLog(this.getClass(), e);
} }
return true;
} }
} }

View File

@ -5,8 +5,9 @@ import com.djrapitops.plan.command.commands.manage.*;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.TreeCmdNode;
/** /**
* This SubCommand is used to manage the the plugin's database and components. * This SubCommand is used to manage the the plugin's database and components.
@ -14,31 +15,27 @@ import com.djrapitops.plugin.command.TreeCommand;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageCommand extends TreeCommand<Plan> { public class ManageCommand extends TreeCmdNode {
public ManageCommand(Plan plugin) { public ManageCommand(Plan plugin, CommandNode parent) {
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE).toString(), "plan m"); super("manage|m", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, parent);
setShortHelp(Locale.get(Msg.CMD_USG_MANAGE).toString());
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE).toArray());
super.setColorScheme(plugin.getColorScheme()); super.setColorScheme(plugin.getColorScheme());
} setNodeGroups(
new CommandNode[]{
@Override new ManageMoveCommand(),
public String[] addHelp() { new ManageBackupCommand(),
return Locale.get(Msg.CMD_HELP_MANAGE).toArray(); new ManageRestoreCommand(plugin),
} new ManageHotswapCommand(plugin),
new ManageClearCommand(plugin),
@Override },
public void addCommands() { new CommandNode[]{
add( new ManageSetupCommand(),
new ManageMoveCommand(), new ManageConDebugCommand(),
new ManageHotswapCommand(plugin), new ManageImportCommand(),
new ManageBackupCommand(), new ManageDisableCommand()
new ManageRestoreCommand(plugin), }
new ManageImportCommand(),
new ManageRemoveCommand(),
new ManageClearCommand(plugin),
new ManageSetupCommand(),
new ManageDisableCommand(),
new ManageConDebugCommand()
); );
} }
} }

View File

@ -4,29 +4,27 @@ import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
/** /**
* Command used to display url to the network page. * Command used to display url to the network page.
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class NetworkCommand extends SubCommand { public class NetworkCommand extends CommandNode {
public NetworkCommand() { public NetworkCommand() {
super("network, n, netw", super("network|n|netw",
CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
Permissions.ANALYZE.getPermission(), setShortHelp("View the network page");
"Get the link to the network page");
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
sendNetworkMsg(sender); sendNetworkMsg(sender);
return true;
} }
private void sendNetworkMsg(ISender sender) { private void sendNetworkMsg(ISender sender) {

View File

@ -13,9 +13,9 @@ import com.djrapitops.plan.utilities.FormatUtils;
import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plan.utilities.uuid.UUIDUtility;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.settings.DefaultMessages; import com.djrapitops.plugin.settings.DefaultMessages;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
@ -30,7 +30,7 @@ import java.util.UUID;
* @author Rsl1122 * @author Rsl1122
* @since 1.0.0 * @since 1.0.0
*/ */
public class QInspectCommand extends SubCommand { public class QInspectCommand extends CommandNode {
private final PlanPlugin plugin; private final PlanPlugin plugin;
@ -40,27 +40,19 @@ public class QInspectCommand extends SubCommand {
* @param plugin Current instance of Plan * @param plugin Current instance of Plan
*/ */
public QInspectCommand(PlanPlugin plugin) { public QInspectCommand(PlanPlugin plugin) {
super("qinspect", super("qinspect", Permissions.QUICK_INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setArguments("<player>");
Permissions.QUICK_INSPECT.getPermission(), setShortHelp(Locale.get(Msg.CMD_USG_QINSPECT).toString());
Locale.get(Msg.CMD_USG_QINSPECT).toString(), setInDepthHelp(Locale.get(Msg.CMD_HELP_QINSPECT).toArray());
"<player>");
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_QINSPECT).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER); String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER);
runInspectTask(playerName, sender); runInspectTask(playerName, sender);
return true;
} }
private void runInspectTask(String playerName, ISender sender) { private void runInspectTask(String playerName, ISender sender) {

View File

@ -9,13 +9,15 @@ import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.PassEncryptUtil; import com.djrapitops.plan.utilities.PassEncryptUtil;
import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import java.util.Arrays;
/** /**
* Command for registering web users. * Command for registering web users.
* <p> * <p>
@ -27,27 +29,23 @@ import com.djrapitops.plugin.task.RunnableFactory;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
*/ */
public class RegisterCommand extends SubCommand { public class RegisterCommand extends CommandNode {
public RegisterCommand() { public RegisterCommand() {
super("register", super("register",
CommandType.PLAYER_OR_ARGS, CommandType.PLAYER_OR_ARGS,
"", // No Permission Requirement "", // No Permission Requirement
Locale.get(Msg.CMD_USG_WEB_REGISTER).toString(), Locale.get(Msg.CMD_USG_WEB_REGISTER).toString(),
"<password> [name] [access lvl]"); "<password> [name] [lvl]");
setInDepthHelp(Locale.get(Msg.CMD_HELP_WEB_REGISTER).toArray());
if (Check.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
setupFilter(); setupFilter();
} }
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_WEB_REGISTER).toArray(); String notEnoughArgsMsg = Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(3) " + Arrays.toString(getArguments()));
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
String notEnoughArgsMsg = Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(3) " + super.getArguments());
String hashErrorMsg = "§cPassword hash error."; String hashErrorMsg = "§cPassword hash error.";
String permLvlErrorMsg = "§cIncorrect perm level, not a number: "; String permLvlErrorMsg = "§cIncorrect perm level, not a number: ";
try { try {
@ -65,7 +63,6 @@ public class RegisterCommand extends SubCommand {
} catch (Exception e) { } catch (Exception e) {
Log.toLog(this.getClass().getSimpleName(), e); Log.toLog(this.getClass().getSimpleName(), e);
} }
return true;
} }
private void consoleRegister(String[] args, ISender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException { private void consoleRegister(String[] args, ISender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException {

View File

@ -5,9 +5,9 @@ import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
/** /**
* This SubCommand is used to reload the plugin. * This SubCommand is used to reload the plugin.
@ -15,21 +15,18 @@ import com.djrapitops.plugin.command.SubCommand;
* @author Rsl1122 * @author Rsl1122
* @since 2.0.0 * @since 2.0.0
*/ */
public class ReloadCommand extends SubCommand { public class ReloadCommand extends CommandNode {
private final PlanPlugin plugin; private final PlanPlugin plugin;
public ReloadCommand(PlanPlugin plugin) { public ReloadCommand(PlanPlugin plugin) {
super("reload", super("reload", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_RELOAD).toString());
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_RELOAD).toString());
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
try { try {
plugin.reloadPlugin(true); plugin.reloadPlugin(true);
} catch (Exception e) { } catch (Exception e) {
@ -37,7 +34,5 @@ public class ReloadCommand extends SubCommand {
sender.sendMessage("§cSomething went wrong during reload of the plugin, a restart is recommended."); sender.sendMessage("§cSomething went wrong during reload of the plugin, a restart is recommended.");
} }
sender.sendMessage(Locale.get(Msg.CMD_INFO_RELOAD_COMPLETE).toString()); sender.sendMessage(Locale.get(Msg.CMD_INFO_RELOAD_COMPLETE).toString());
return true;
} }
} }

View File

@ -5,9 +5,9 @@ import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.FormatUtils; import com.djrapitops.plugin.utilities.FormatUtils;
@ -22,31 +22,25 @@ import java.util.List;
* @author Rsl1122 * @author Rsl1122
* @since 2.0.0 * @since 2.0.0
*/ */
public class SearchCommand extends SubCommand { public class SearchCommand extends CommandNode {
public SearchCommand() { public SearchCommand() {
super("search", super("search",
CommandType.PLAYER_OR_ARGS, CommandType.PLAYER_OR_ARGS,
Permissions.SEARCH.getPermission(), Permissions.SEARCH.getPermission(),
Locale.get(Msg.CMD_USG_SEARCH).toString(), Locale.get(Msg.CMD_USG_SEARCH).toString(),
"<part of playername>"); "<text>");
setInDepthHelp(Locale.get(Msg.CMD_HELP_SEARCH).toArray());
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_SEARCH).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return;
} }
sender.sendMessage(Locale.get(Msg.CMD_INFO_SEARCHING).toString()); sender.sendMessage(Locale.get(Msg.CMD_INFO_SEARCHING).toString());
runSearchTask(args, sender); runSearchTask(args, sender);
return true;
} }
private void runSearchTask(String[] args, ISender sender) { private void runSearchTask(String[] args, ISender sender) {

View File

@ -1,7 +1,5 @@
package com.djrapitops.plan.command.commands; package com.djrapitops.plan.command.commands;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.command.commands.webuser.WebCheckCommand; import com.djrapitops.plan.command.commands.webuser.WebCheckCommand;
import com.djrapitops.plan.command.commands.webuser.WebDeleteCommand; import com.djrapitops.plan.command.commands.webuser.WebDeleteCommand;
@ -10,8 +8,9 @@ import com.djrapitops.plan.command.commands.webuser.WebListUsersCommand;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.TreeCmdNode;
/** /**
* Web subcommand used to manage Web users. * Web subcommand used to manage Web users.
@ -19,39 +18,21 @@ import com.djrapitops.plugin.command.TreeCommand;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
*/ */
public class WebUserCommand extends TreeCommand<PlanPlugin> { public class WebUserCommand extends TreeCmdNode {
public WebUserCommand(Plan plugin, RegisterCommand register) { public WebUserCommand(PlanPlugin plugin, RegisterCommand register, CommandNode parent) {
super(plugin, "webuser, web", super("webuser|web", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE, parent);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_WEB).toString());
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB).toString(),
"plan web");
super.setColorScheme(plugin.getColorScheme()); super.setColorScheme(plugin.getColorScheme());
add(register); setInDepthHelp(Locale.get(Msg.CMD_HELP_WEB).toArray());
} setNodeGroups(
new CommandNode[]{
public WebUserCommand(PlanBungee plugin, RegisterCommand register) { register,
super(plugin, "webuser, web", new WebLevelCommand(plugin),
CommandType.CONSOLE, new WebListUsersCommand(plugin),
Permissions.MANAGE_WEB.getPerm(), new WebCheckCommand(),
Locale.get(Msg.CMD_USG_WEB).toString(), new WebDeleteCommand()
"planbungee web"); }
add(register);
}
@Override
public String[] addHelp() {
return Locale.get(Msg.CMD_HELP_WEB).toArray();
}
@Override
public void addCommands() {
add(
new WebLevelCommand(plugin),
new WebListUsersCommand(plugin),
new WebCheckCommand(),
new WebDeleteCommand()
); );
} }
} }

View File

@ -9,9 +9,9 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.ManageUtils;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
@ -22,7 +22,7 @@ import com.djrapitops.plugin.utilities.Verify;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageBackupCommand extends SubCommand { public class ManageBackupCommand extends CommandNode {
public ManageBackupCommand() { public ManageBackupCommand() {
super("backup", super("backup",
@ -34,16 +34,16 @@ public class ManageBackupCommand extends SubCommand {
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
try { try {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return;
} }
String dbName = args[0].toLowerCase(); String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName); boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true; return;
} }
final Database database = DBSystem.getActiveDatabaseByName(dbName); final Database database = DBSystem.getActiveDatabaseByName(dbName);
@ -51,7 +51,7 @@ public class ManageBackupCommand extends SubCommand {
// If DB is null return // If DB is null return
if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!"); Log.error(dbName + " was null!");
return true; return;
} }
Log.debug("Backup", "Start"); Log.debug("Backup", "Start");
runBackupTask(sender, args, database); runBackupTask(sender, args, database);
@ -60,7 +60,6 @@ public class ManageBackupCommand extends SubCommand {
} finally { } finally {
Log.logDebug("Backup"); Log.logDebug("Backup");
} }
return true;
} }
private void runBackupTask(ISender sender, String[] args, final Database database) { private void runBackupTask(ISender sender, String[] args, final Database database) {

View File

@ -14,9 +14,9 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
@ -27,7 +27,7 @@ import com.djrapitops.plugin.utilities.Verify;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageClearCommand extends SubCommand { public class ManageClearCommand extends CommandNode {
private final Plan plugin; private final Plan plugin;
@ -38,30 +38,26 @@ public class ManageClearCommand extends SubCommand {
Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString(), Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString(),
"<DB> [-a]"); "<DB> [-a]");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_CLEAR).toArray());
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_MANAGE_CLEAR).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return;
} }
String dbName = args[0].toLowerCase(); String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName); boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true; return;
} }
if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[0])), sender)) { if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[0])), sender)) {
return true; return;
} }
try { try {
@ -70,7 +66,6 @@ public class ManageClearCommand extends SubCommand {
} catch (DBInitException e) { } catch (DBInitException e) {
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
} }
return true;
} }
private void runClearTask(ISender sender, Database database) { private void runClearTask(ISender sender, Database database) {

View File

@ -10,13 +10,11 @@ import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processing; import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.system.webserver.WebServerSystem;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import java.util.List; import java.util.List;
@ -28,7 +26,7 @@ import java.util.UUID;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageConDebugCommand extends SubCommand { public class ManageConDebugCommand extends CommandNode {
private final ColorScheme cs; private final ColorScheme cs;
@ -38,25 +36,17 @@ public class ManageConDebugCommand extends SubCommand {
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
"Debug Bukkit-Bungee Connections", "Debug Bukkit-Bungee Connections",
""); "");
cs = PlanPlugin.getInstance().getColorScheme(); cs = PlanPlugin.getInstance().getColorScheme();
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!WebServerSystem.isWebServerEnabled()) { if (!WebServerSystem.isWebServerEnabled()) {
sender.sendMessage("§cWebServer is not enabled on this server."); sender.sendMessage("§cWebServer is not enabled on this server.");
return true; return;
} }
Processing.submitNonCritical(() -> testServers(sender)); Processing.submitNonCritical(() -> testServers(sender));
return true;
} }
private void testServers(ISender sender) { private void testServers(ISender sender) {

View File

@ -5,9 +5,9 @@ import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
/** /**
* This manage SubCommand is used to disable some features of the plugin temporarily. * This manage SubCommand is used to disable some features of the plugin temporarily.
@ -15,7 +15,7 @@ import com.djrapitops.plugin.command.SubCommand;
* @author Rsl1122 * @author Rsl1122
* @since 4.0.4 * @since 4.0.4
*/ */
public class ManageDisableCommand extends SubCommand { public class ManageDisableCommand extends CommandNode {
/** /**
* Class Constructor. * Class Constructor.
*/ */
@ -23,14 +23,14 @@ public class ManageDisableCommand extends SubCommand {
super("disable", super("disable",
CommandType.PLAYER_OR_ARGS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
"Used to disable some features of the Plugin temporarily", "Disable a feature temporarily",
"<feature>"); "<feature>");
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "kickcount": case "kickcount":
@ -40,6 +40,5 @@ public class ManageDisableCommand extends SubCommand {
default: default:
sender.sendMessage("§eDefine a feature to disable! (currently supports only kickCount)"); sender.sendMessage("§eDefine a feature to disable! (currently supports only kickCount)");
} }
return true;
} }
} }

View File

@ -9,9 +9,9 @@ import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
/** /**
@ -21,7 +21,7 @@ import com.djrapitops.plugin.utilities.Verify;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageHotswapCommand extends SubCommand { public class ManageHotswapCommand extends CommandNode {
private final Plan plugin; private final Plan plugin;
@ -31,30 +31,25 @@ public class ManageHotswapCommand extends SubCommand {
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString(), Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString(),
"<DB>"); "<DB>");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray());
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return;
} }
String dbName = args[0].toLowerCase(); String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName); boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true; return;
} }
if (Condition.isTrue(dbName.equals(Database.getActive().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) { if (Condition.isTrue(dbName.equals(Database.getActive().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
return true; return;
} }
try { try {
@ -63,22 +58,21 @@ public class ManageHotswapCommand extends SubCommand {
// If DB is null return // If DB is null return
if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!"); Log.error(dbName + " was null!");
return true; return;
} }
if (!database.isOpen()) { if (!database.isOpen()) {
return true; return;
} }
} catch (Exception e) { } catch (Exception e) {
Log.toLog(this.getClass(), e); Log.toLog(this.getClass(), e);
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
return true; return;
} }
Settings.DB_TYPE.set(dbName); Settings.DB_TYPE.set(dbName);
Settings.save(); Settings.save();
plugin.reloadPlugin(true); plugin.reloadPlugin(true);
return true;
} }
} }

View File

@ -6,19 +6,21 @@ import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import java.util.Arrays;
/** /**
* This manage SubCommand is used to import data from 3rd party plugins. * This manage SubCommand is used to import data from 3rd party plugins.
* *
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageImportCommand extends SubCommand { public class ManageImportCommand extends CommandNode {
public ManageImportCommand() { public ManageImportCommand() {
super("import", super("import",
@ -26,17 +28,13 @@ public class ManageImportCommand extends SubCommand {
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_IMPORT).toString(), Locale.get(Msg.CMD_USG_MANAGE_IMPORT).toString(),
"<plugin>/list [import args]"); "<plugin>/list [import args]");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_IMPORT).toArray());
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_MANAGE_IMPORT).toArray(); if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG) + " " + Arrays.toString(this.getArguments()), sender)) {
} return;
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG) + " " + this.getArguments(), sender)) {
return true;
} }
String importArg = args[0]; String importArg = args[0];
@ -47,13 +45,13 @@ public class ManageImportCommand extends SubCommand {
.map(Importer::getNames) .map(Importer::getNames)
.map(list -> list.get(0)) .map(list -> list.get(0))
.forEach(name -> sender.sendMessage("- " + name)); .forEach(name -> sender.sendMessage("- " + name));
return true; return;
} }
Importer importer = ImporterManager.getImporter(importArg); Importer importer = ImporterManager.getImporter(importArg);
if (importer == null) { if (importer == null) {
sender.sendMessage("§eImporter '" + importArg + "' doesn't exist"); sender.sendMessage("§eImporter '" + importArg + "' doesn't exist");
return true; return;
} }
RunnableFactory.createNew("Import:" + importArg, new AbsRunnable() { RunnableFactory.createNew("Import:" + importArg, new AbsRunnable() {
@ -66,6 +64,5 @@ public class ManageImportCommand extends SubCommand {
} }
} }
}).runTaskAsynchronously(); }).runTaskAsynchronously();
return true;
} }
} }

View File

@ -8,9 +8,9 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.ManageUtils;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
@ -23,7 +23,7 @@ import com.djrapitops.plugin.utilities.Verify;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageMoveCommand extends SubCommand { public class ManageMoveCommand extends CommandNode {
public ManageMoveCommand() { public ManageMoveCommand() {
super("move", super("move",
@ -34,31 +34,31 @@ public class ManageMoveCommand extends SubCommand {
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return;
} }
String fromDB = args[0].toLowerCase(); String fromDB = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(fromDB) || "mysql".equals(fromDB); boolean isCorrectDB = "sqlite".equals(fromDB) || "mysql".equals(fromDB);
if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + fromDB, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + fromDB, sender)) {
return true; return;
} }
String toDB = args[1].toLowerCase(); String toDB = args[1].toLowerCase();
isCorrectDB = "sqlite".equals(toDB) || "mysql".equals(toDB); isCorrectDB = "sqlite".equals(toDB) || "mysql".equals(toDB);
if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + toDB, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + toDB, sender)) {
return true; return;
} }
if (!Condition.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) { if (!Condition.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
return true; return;
} }
if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[1])), sender)) { if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[1])), sender)) {
return true; return;
} }
try { try {
@ -69,7 +69,6 @@ public class ManageMoveCommand extends SubCommand {
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
} }
return true;
} }
private void runMoveTask(final Database fromDatabase, final Database toDatabase, ISender sender) { private void runMoveTask(final Database fromDatabase, final Database toDatabase, ISender sender) {

View File

@ -10,9 +10,9 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.ManageUtils;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
@ -25,7 +25,7 @@ import java.io.File;
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class ManageRestoreCommand extends SubCommand { public class ManageRestoreCommand extends CommandNode {
private final Plan plugin; private final Plan plugin;
@ -40,20 +40,20 @@ public class ManageRestoreCommand extends SubCommand {
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return;
} }
String db = args[1].toLowerCase(); String db = args[1].toLowerCase();
boolean isCorrectDB = "sqlite".equals(db) || "mysql".equals(db); boolean isCorrectDB = "sqlite".equals(db) || "mysql".equals(db);
if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + db, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + db, sender)) {
return true; return;
} }
if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REWRITE).parse(args[1])), sender)) { if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REWRITE).parse(args[1])), sender)) {
return true; return;
} }
try { try {
@ -63,7 +63,6 @@ public class ManageRestoreCommand extends SubCommand {
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
} }
return true;
} }
private void runRestoreTask(String[] args, ISender sender, final Database database) { private void runRestoreTask(String[] args, ISender sender, final Database database) {

View File

@ -10,9 +10,9 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.system.webserver.WebServerSystem;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
/** /**
* This manage SubCommand is used to request settings from Bungee so that connection can be established. * This manage SubCommand is used to request settings from Bungee so that connection can be established.
@ -20,42 +20,36 @@ import com.djrapitops.plugin.command.SubCommand;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageSetupCommand extends SubCommand { public class ManageSetupCommand extends CommandNode {
public ManageSetupCommand() { public ManageSetupCommand() {
super("setup", super("setup",
CommandType.PLAYER_OR_ARGS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
"Set-Up Bungee WebServer connection", "Set-Up Bungee connection",
"<Bungee WebServer address>"); "<BungeeAddress>");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray());
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return;
} }
if (!WebServerSystem.isWebServerEnabled()) { if (!WebServerSystem.isWebServerEnabled()) {
sender.sendMessage("§cWebServer is not enabled on this server! Make sure it enables on boot!"); sender.sendMessage("§cWebServer is not enabled on this server! Make sure it enables on boot!");
return true; return;
} }
String address = args[0].toLowerCase(); String address = args[0].toLowerCase();
if (!address.startsWith("http") || address.endsWith("://")) { if (!address.startsWith("http") || address.endsWith("://")) {
sender.sendMessage("§cMake sure you're using the full address (Starts with http:// or https://) - Check Bungee enable log for the full address."); sender.sendMessage("§cMake sure you're using the full address (Starts with http:// or https://) - Check Bungee enable log for the full address.");
return true; return;
} }
if (address.endsWith("/")) { if (address.endsWith("/")) {
address = address.substring(0, address.length() - 1); address = address.substring(0, address.length() - 1);
} }
requestSetup(sender, address); requestSetup(sender, address);
return true;
} }
private void requestSetup(ISender sender, String address) { private void requestSetup(ISender sender, String address) {

View File

@ -7,9 +7,9 @@ import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -20,20 +20,18 @@ import org.bukkit.ChatColor;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
*/ */
public class WebCheckCommand extends SubCommand { public class WebCheckCommand extends CommandNode {
public WebCheckCommand() { public WebCheckCommand() {
super("check", super("check", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp(Locale.get(Msg.CMD_USG_WEB_CHECK).toString());
Permissions.MANAGE_WEB.getPerm(), setArguments("<username>");
Locale.get(Msg.CMD_USG_WEB_CHECK).toString(),
"<username>");
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) {
return true; return;
} }
Database database = Database.getActive(); Database database = Database.getActive();
String user = args[0]; String user = args[0];
@ -55,7 +53,6 @@ public class WebCheckCommand extends SubCommand {
} }
} }
}).runTaskAsynchronously(); }).runTaskAsynchronously();
return true;
} }
} }

View File

@ -6,9 +6,9 @@ import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -19,20 +19,18 @@ import net.md_5.bungee.api.ChatColor;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
*/ */
public class WebDeleteCommand extends SubCommand { public class WebDeleteCommand extends CommandNode {
public WebDeleteCommand() { public WebDeleteCommand() {
super("delete, remove", super("delete|remove", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp(Locale.get(Msg.CMD_USG_WEB_DELETE).toString());
Permissions.MANAGE_WEB.getPerm(), setArguments("<username>");
Locale.get(Msg.CMD_USG_WEB_DELETE).toString(),
"<username>");
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) {
return true; return;
} }
Database database = Database.getActive(); Database database = Database.getActive();
String user = args[0]; String user = args[0];
@ -54,7 +52,6 @@ public class WebDeleteCommand extends SubCommand {
} }
} }
}).runTaskAsynchronously(); }).runTaskAsynchronously();
return true;
} }
} }

View File

@ -4,9 +4,9 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
/** /**
@ -15,20 +15,18 @@ import com.djrapitops.plugin.settings.ColorScheme;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
*/ */
public class WebLevelCommand extends SubCommand { public class WebLevelCommand extends CommandNode {
private final PlanPlugin plugin; private final PlanPlugin plugin;
public WebLevelCommand(PlanPlugin plugin) { public WebLevelCommand(PlanPlugin plugin) {
super("level", super("level", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_WEB_LEVEL).toString());
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_LEVEL).toString());
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
ColorScheme cs = plugin.getColorScheme(); ColorScheme cs = plugin.getColorScheme();
String sCol = cs.getSecondaryColor(); String sCol = cs.getSecondaryColor();
String cmdBall = Locale.get(Msg.CMD_CONSTANT_LIST_BALL).parse(); String cmdBall = Locale.get(Msg.CMD_CONSTANT_LIST_BALL).parse();
@ -44,7 +42,6 @@ public class WebLevelCommand extends SubCommand {
}; };
sender.sendMessage(messages); sender.sendMessage(messages);
return true;
} }
} }

View File

@ -8,9 +8,9 @@ import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plan.utilities.comparators.WebUserComparator; import com.djrapitops.plan.utilities.comparators.WebUserComparator;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
@ -23,17 +23,18 @@ import java.util.List;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
*/ */
public class WebListUsersCommand extends SubCommand { public class WebListUsersCommand extends CommandNode {
private final PlanPlugin plugin; private final PlanPlugin plugin;
public WebListUsersCommand(PlanPlugin plugin) { public WebListUsersCommand(PlanPlugin plugin) {
super("list", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), "List registered web users & permission levels."); super("list", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE);
setShortHelp("List registered web users & permission levels.");
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public void onCommand(ISender sender, String commandLabel, String[] args) {
RunnableFactory.createNew(new AbsRunnable("Webuser List Task") { RunnableFactory.createNew(new AbsRunnable("Webuser List Task") {
@Override @Override
public void run() { public void run() {
@ -55,7 +56,6 @@ public class WebListUsersCommand extends SubCommand {
} }
} }
}).runTaskAsynchronously(); }).runTaskAsynchronously();
return true;
} }
} }

View File

@ -203,35 +203,33 @@ public class Locale {
add(Msg.CMD_USG_QANALYZE, "View the Server Analysis as Text"); add(Msg.CMD_USG_QANALYZE, "View the Server Analysis as Text");
add(Msg.CMD_USG_HELP, "Show command list."); add(Msg.CMD_USG_HELP, "Show command list.");
add(Msg.CMD_USG_INFO, "Check the version of Plan"); add(Msg.CMD_USG_INFO, "Check the version of Plan");
add(Msg.CMD_USG_INSPECT, "Inspect Player's Data"); add(Msg.CMD_USG_INSPECT, "Inspect player's data");
add(Msg.CMD_USG_QINSPECT, "Inspect Player's Data as Text"); add(Msg.CMD_USG_QINSPECT, "Inspect player's data in game");
add(Msg.CMD_USG_LIST, "List to all cached players"); add(Msg.CMD_USG_LIST, "List to all cached players");
add(Msg.CMD_USG_MANAGE, "Database management command"); add(Msg.CMD_USG_MANAGE, "Database management command");
add(Msg.CMD_USG_MANAGE_BACKUP, "Backup a database to .db file"); add(Msg.CMD_USG_MANAGE_BACKUP, "Backup a database to .db file");
add(Msg.CMD_USG_MANAGE_CLEAN, "Clear old data from the database"); add(Msg.CMD_USG_MANAGE_CLEAN, "Clear old data from the database");
add(Msg.CMD_USG_MANAGE_CLEAR, "Clear ALL data from the database"); add(Msg.CMD_USG_MANAGE_CLEAR, "Clear ALL data from the database");
add(Msg.CMD_USG_MANAGE_DUMP, "Create a Hastebin log for Dev for easier Issue reporting."); add(Msg.CMD_USG_MANAGE_DUMP, "Create a Hastebin log for Dev for easier Issue reporting.");
add(Msg.CMD_USG_MANAGE_HOTSWAP, "Hotswap to another database & restart the plugin"); add(Msg.CMD_USG_MANAGE_HOTSWAP, "Hotswap database & restart the plugin");
add(Msg.CMD_USG_MANAGE_IMPORT, "Import Data from supported plugins to Active Database."); add(Msg.CMD_USG_MANAGE_IMPORT, "Import Data from plugins");
add(Msg.CMD_USG_MANAGE_MOVE, "Copy data from one database to another & overwrite values"); add(Msg.CMD_USG_MANAGE_MOVE, "Move data between databases");
add(Msg.CMD_USG_MANAGE_REMOVE, "Remove players's data from the Active Database."); add(Msg.CMD_USG_MANAGE_REMOVE, "Remove players's data from the Active Database.");
add(Msg.CMD_USG_MANAGE_RESTORE, "Restore a database from a backup file"); add(Msg.CMD_USG_MANAGE_RESTORE, "Restore a database");
add(Msg.CMD_USG_RELOAD, "Restart the Plugin (Reloads config)"); add(Msg.CMD_USG_RELOAD, "Restart the Plugin (Reloads config)");
add(Msg.CMD_USG_SEARCH, "Search for player"); add(Msg.CMD_USG_SEARCH, "Search for player");
add(Msg.CMD_USG_WEB, "Manage Webusers"); add(Msg.CMD_USG_WEB, "Manage Web users");
add(Msg.CMD_USG_WEB_CHECK, "Check a webuser and their permission level."); add(Msg.CMD_USG_WEB_CHECK, "Check a web user's permission level.");
add(Msg.CMD_USG_WEB_DELETE, "Delete a webuser"); add(Msg.CMD_USG_WEB_DELETE, "Delete a web user");
add(Msg.CMD_USG_WEB_LEVEL, "Info about permission levels."); add(Msg.CMD_USG_WEB_LEVEL, "Info about permission levels.");
add(Msg.CMD_USG_WEB_REGISTER, "Register a user for the webserver"); add(Msg.CMD_USG_WEB_REGISTER, "Register a web user");
add(Msg.CMD_HELP_ANALYZE, mCol + "Analysis Command" add(Msg.CMD_HELP_ANALYZE, mCol + "Analysis Command"
+ "\\" + tCol + " Used to Refresh analysis cache & Access the result page" + "\\" + tCol + " Used to Refresh analysis cache & Access the result page"
+ "\\" + sCol + " /plan status can be used to check status of analysis while it is running." + "\\" + sCol + " /plan status can be used to check status of analysis while it is running.");
+ "\\" + sCol + " Aliases: analyze, analyse, analysis, a");
add(Msg.CMD_HELP_QANALYZE, mCol + "Quick Analysis command" add(Msg.CMD_HELP_QANALYZE, mCol + "Quick Analysis command"
+ "\\" + tCol + " Used to get in game info about analysis." + "\\" + tCol + " Used to get in game info about analysis."
+ "\\" + sCol + " Has less info than full Analysis web page." + "\\" + sCol + " Has less info than full Analysis web page.");
+ "\\" + sCol + " Aliases: qanalyze, ganalyse, qanalysis, qa");
add(Msg.CMD_HELP_PLAN, mCol + "/plan - Main Command" add(Msg.CMD_HELP_PLAN, mCol + "/plan - Main Command"
+ "\\" + tCol + " Used to access all SubCommands & help" + "\\" + tCol + " Used to access all SubCommands & help"
+ "\\" + sCol + " /plan - List subcommands" + "\\" + sCol + " /plan - List subcommands"
@ -242,21 +240,17 @@ public class Locale {
+ "\\" + sCol + " Alias: /plan <name>"); + "\\" + sCol + " Alias: /plan <name>");
add(Msg.CMD_HELP_QINSPECT, mCol + "Quick Inspect command" add(Msg.CMD_HELP_QINSPECT, mCol + "Quick Inspect command"
+ "\\" + tCol + " Used to get some inspect info in game." + "\\" + tCol + " Used to get some inspect info in game."
+ "\\" + sCol + " Has less info than full Inspect web page." + "\\" + sCol + " Has less info than full Inspect web page.");
+ "\\" + sCol + " Alias: /plan qi");
add(Msg.CMD_HELP_LIST, mCol + "List command" add(Msg.CMD_HELP_LIST, mCol + "List command"
+ "\\" + tCol + " Used to get a link to players page." + "\\" + tCol + " Used to get a link to players page."
+ "\\" + sCol + " Players page contains links to all cached inspect pages." + "\\" + sCol + " Players page contains links to all cached inspect pages.");
+ "\\" + sCol + " Alias: /plan pl");
add(Msg.CMD_HELP_MANAGE, mCol + "Manage command\\" add(Msg.CMD_HELP_MANAGE, mCol + "Manage command\\"
+ tCol + " Used to Manage Database of the plugin." + tCol + " Used to Manage Database of the plugin."
+ "\\" + sCol + " Alias: /plan m"
+ "\\" + sCol + " /plan m - List subcommands" + "\\" + sCol + " /plan m - List subcommands"
+ "\\" + sCol + " /plan m <subcommand> ? - in depth help"); + "\\" + sCol + " /plan m <subcommand> ? - in depth help");
add(Msg.CMD_HELP_MANAGE_CLEAR, mCol + "Manage Clear command" add(Msg.CMD_HELP_MANAGE_CLEAR, mCol + "Manage Clear command"
+ "\\" + tCol + " Used to delete ALL data in the active database." + "\\" + tCol + " Used to delete ALL data in the active database."
+ "\\" + sCol + " Plugin should be reloaded after successful clear." + "\\" + sCol + " Plugin should be reloaded after successful clear.");
+ "\\" + sCol + " Alias: /plan pl");
add(Msg.CMD_HELP_MANAGE_DUMP, mCol + "Manage Dump command" add(Msg.CMD_HELP_MANAGE_DUMP, mCol + "Manage Dump command"
+ "\\" + tCol + " Used to dump important data for bug reporting to hastebin."); + "\\" + tCol + " Used to dump important data for bug reporting to hastebin.");
add(Msg.CMD_HELP_MANAGE_HOTSWAP, mCol + "Manage Hotswap command" add(Msg.CMD_HELP_MANAGE_HOTSWAP, mCol + "Manage Hotswap command"
@ -275,8 +269,7 @@ public class Locale {
+ "\\" + sCol + " Users have a permission level:" + "\\" + sCol + " Users have a permission level:"
+ "\\" + tCol + " 0 - Access to all pages" + "\\" + tCol + " 0 - Access to all pages"
+ "\\" + tCol + " 1 - Access to /players & all inspect pages" + "\\" + tCol + " 1 - Access to /players & all inspect pages"
+ "\\" + tCol + " 2 - Access to own inspect page" + "\\" + tCol + " 2 - Access to own inspect page");
+ "\\" + sCol + " Alias: /plan web");
add(Msg.CMD_HELP_WEB_REGISTER, mCol + "Web Register command" add(Msg.CMD_HELP_WEB_REGISTER, mCol + "Web Register command"
+ "\\" + tCol + " Used to register a new user for the webserver." + "\\" + tCol + " Used to register a new user for the webserver."
+ "\\" + sCol + " Registering a user for another player requires " + Permissions.MANAGE_WEB.getPerm() + " permission." + "\\" + sCol + " Registering a user for another player requires " + Permissions.MANAGE_WEB.getPerm() + " permission."