mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-06 02:42:05 +01:00
Implement missing commands
This commit is contained in:
parent
73b822b0ef
commit
bbfb78d0b8
@ -46,12 +46,13 @@ public class PlanCommand extends TreeCommand<Plan> {
|
|||||||
commands.add(new ReloadCommand(plugin));
|
commands.add(new ReloadCommand(plugin));
|
||||||
commands.add(new ManageCommand(plugin));
|
commands.add(new ManageCommand(plugin));
|
||||||
commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission()));
|
commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission()));
|
||||||
|
|
||||||
if (plugin.getWebServer().isEnabled()) {
|
|
||||||
commands.add(new ListCommand());
|
commands.add(new ListCommand());
|
||||||
RegisterCommand registerCommand = new RegisterCommand(plugin);
|
RegisterCommand registerCommand = new RegisterCommand(plugin);
|
||||||
commands.add(registerCommand);
|
commands.add(registerCommand);
|
||||||
commands.add(new WebUserCommand(plugin, registerCommand));
|
commands.add(new WebUserCommand(plugin, registerCommand));
|
||||||
|
if (plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||||
|
commands.add(new NetworkCommand());
|
||||||
|
commands.add(new ListServersCommand(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.DEV_MODE.isTrue()) {
|
if (Settings.DEV_MODE.isTrue()) {
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package main.java.com.djrapitops.plan.command.commands;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.command.CommandType;
|
||||||
|
import com.djrapitops.plugin.command.ISender;
|
||||||
|
import com.djrapitops.plugin.command.SubCommand;
|
||||||
|
import com.djrapitops.plugin.settings.ColorScheme;
|
||||||
|
import main.java.com.djrapitops.plan.Log;
|
||||||
|
import main.java.com.djrapitops.plan.Permissions;
|
||||||
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
|
import main.java.com.djrapitops.plan.api.IPlan;
|
||||||
|
import main.java.com.djrapitops.plan.locale.Locale;
|
||||||
|
import main.java.com.djrapitops.plan.locale.Msg;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This subcommand is used to reload the plugin.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public class ListServersCommand extends SubCommand {
|
||||||
|
|
||||||
|
private final IPlan plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subcommand constructor.
|
||||||
|
*
|
||||||
|
* @param plugin Current instance of Plan
|
||||||
|
*/
|
||||||
|
public ListServersCommand(Plan plugin) {
|
||||||
|
super("servers, serverlist, listservers, sl",
|
||||||
|
CommandType.CONSOLE,
|
||||||
|
Permissions.MANAGE.getPermission(),
|
||||||
|
Locale.get(Msg.CMD_USG_RELOAD).toString());
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||||
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
String mCol = colorScheme.getMainColor();
|
||||||
|
String sCol = colorScheme.getSecondaryColor();
|
||||||
|
String tCol = colorScheme.getTertiaryColor();
|
||||||
|
try {
|
||||||
|
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString() + mCol + " Servers");
|
||||||
|
Map<Integer, String> serverNames = plugin.getDB().getServerTable().getServerNames();
|
||||||
|
for (Map.Entry<Integer, String> entry : serverNames.entrySet()) {
|
||||||
|
sender.sendMessage(" " + tCol + entry.getKey() + sCol + " : " + entry.getValue());
|
||||||
|
}
|
||||||
|
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
sender.sendMessage("§cSQLException occurred.");
|
||||||
|
Log.toLog(this.getClass().getName(), e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package main.java.com.djrapitops.plan.command.commands;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.command.CommandType;
|
||||||
|
import com.djrapitops.plugin.command.CommandUtils;
|
||||||
|
import com.djrapitops.plugin.command.ISender;
|
||||||
|
import com.djrapitops.plugin.command.SubCommand;
|
||||||
|
import main.java.com.djrapitops.plan.Permissions;
|
||||||
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
|
import main.java.com.djrapitops.plan.locale.Locale;
|
||||||
|
import main.java.com.djrapitops.plan.locale.Msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command used to display link to the player list webpage.
|
||||||
|
* <p>
|
||||||
|
* Subcommand is not registered if Webserver is not enabled.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
* @since 3.5.2
|
||||||
|
*/
|
||||||
|
public class NetworkCommand extends SubCommand {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor.
|
||||||
|
*/
|
||||||
|
public NetworkCommand() {
|
||||||
|
super("network, n, netw", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), Locale.get(Msg.CMD_USG_LIST).toString(), "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||||
|
|
||||||
|
sendNetworkMsg(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendNetworkMsg(ISender sender) {
|
||||||
|
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
|
||||||
|
|
||||||
|
// Link
|
||||||
|
String url = Plan.getInstance().getInfoManager().getLinkTo("/network");
|
||||||
|
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
||||||
|
boolean console = !CommandUtils.isPlayer(sender);
|
||||||
|
if (console) {
|
||||||
|
sender.sendMessage(message + url);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(message);
|
||||||
|
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
|
||||||
|
}
|
||||||
|
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user