mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 15:44:49 +08:00
Implemented /planbungee command functionality #349
This commit is contained in:
parent
0864cbae84
commit
6bb633ab45
@ -10,7 +10,7 @@ import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||
import main.java.com.djrapitops.plan.command.commands.ReloadCommand;
|
||||
import main.java.com.djrapitops.plan.command.PlanBungeeCommand;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
@ -65,7 +65,7 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
||||
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
|
||||
initDatabase();
|
||||
|
||||
registerCommand(new ReloadCommand(this));
|
||||
registerCommand(new PlanBungeeCommand(this));
|
||||
|
||||
String ip = variableHolder.getIp();
|
||||
if ("0.0.0.0".equals(ip)) {
|
||||
|
@ -0,0 +1,50 @@
|
||||
package main.java.com.djrapitops.plan.command;
|
||||
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.TreeCommand;
|
||||
import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.command.commands.*;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
|
||||
/**
|
||||
* TreeCommand for the /plan command, and all subcommands.
|
||||
* <p>
|
||||
* Uses the Abstract Plugin Framework for easier command management.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class PlanBungeeCommand extends TreeCommand<PlanBungee> {
|
||||
|
||||
/**
|
||||
* CommandExecutor class Constructor.
|
||||
* <p>
|
||||
* Initializes Subcommands
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public PlanBungeeCommand(PlanBungee plugin) {
|
||||
super(plugin, "planbungee", CommandType.CONSOLE, "", "", "planbungee");
|
||||
super.setDefaultCommand("help");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] addHelp() {
|
||||
return Locale.get(Msg.CMD_HELP_PLAN).toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands() {
|
||||
commands.add(new ReloadCommand(plugin));
|
||||
commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission()));
|
||||
commands.add(new ListCommand());
|
||||
RegisterCommand registerCommand = new RegisterCommand(plugin);
|
||||
commands.add(registerCommand);
|
||||
commands.add(new WebUserCommand(plugin, registerCommand));
|
||||
commands.add(new NetworkCommand(plugin));
|
||||
commands.add(new ListServersCommand(plugin));
|
||||
}
|
||||
}
|
@ -5,9 +5,9 @@ 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;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
||||
/**
|
||||
* Command used to display link to the player list webpage.
|
||||
@ -43,7 +43,7 @@ public class ListCommand extends SubCommand {
|
||||
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
|
||||
|
||||
// Link
|
||||
String url = Plan.getInstance().getInfoManager().getLinkTo("/players/");
|
||||
String url = MiscUtils.getIPlan().getInfoManager().getLinkTo("/players/");
|
||||
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -6,7 +6,6 @@ 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;
|
||||
@ -29,7 +28,7 @@ public class ListServersCommand extends SubCommand {
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ListServersCommand(Plan plugin) {
|
||||
public ListServersCommand(IPlan plugin) {
|
||||
super("servers, serverlist, listservers, sl",
|
||||
CommandType.CONSOLE,
|
||||
Permissions.MANAGE.getPermission(),
|
||||
|
@ -5,7 +5,7 @@ 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.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
|
||||
@ -19,12 +19,12 @@ import main.java.com.djrapitops.plan.locale.Msg;
|
||||
*/
|
||||
public class NetworkCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
private final IPlan plugin;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*/
|
||||
public NetworkCommand(Plan plugin) {
|
||||
public NetworkCommand(IPlan plugin) {
|
||||
super("network, n, netw",
|
||||
CommandType.CONSOLE,
|
||||
Permissions.ANALYZE.getPermission(),
|
||||
@ -34,10 +34,6 @@ public class NetworkCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||
sender.sendMessage("§cNot using Bungee WebServer!");
|
||||
return true;
|
||||
}
|
||||
sendNetworkMsg(sender);
|
||||
return true;
|
||||
}
|
||||
@ -46,7 +42,7 @@ public class NetworkCommand extends SubCommand {
|
||||
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
|
||||
|
||||
// Link
|
||||
String url = Plan.getInstance().getInfoManager().getLinkTo("/network/");
|
||||
String url = plugin.getInfoManager().getLinkTo("/network/");
|
||||
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -7,7 +7,7 @@ import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
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.data.WebUser;
|
||||
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
@ -31,9 +31,9 @@ import org.apache.logging.log4j.core.Logger;
|
||||
*/
|
||||
public class RegisterCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
private final IPlan plugin;
|
||||
|
||||
public RegisterCommand(Plan plugin) {
|
||||
public RegisterCommand(IPlan plugin) {
|
||||
super("register",
|
||||
CommandType.CONSOLE_WITH_ARGUMENTS,
|
||||
"", // No Permission Requirement
|
||||
|
@ -4,8 +4,6 @@ import com.djrapitops.plugin.command.CommandType;
|
||||
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.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
@ -25,7 +23,7 @@ public class ReloadCommand extends SubCommand {
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ReloadCommand(Plan plugin) {
|
||||
public ReloadCommand(IPlan plugin) {
|
||||
super("reload",
|
||||
CommandType.CONSOLE,
|
||||
Permissions.MANAGE.getPermission(),
|
||||
@ -34,15 +32,6 @@ public class ReloadCommand extends SubCommand {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public ReloadCommand(PlanBungee plugin) {
|
||||
super("planbungee",
|
||||
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) {
|
||||
plugin.restart();
|
||||
|
@ -3,7 +3,7 @@ package main.java.com.djrapitops.plan.command.commands;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.TreeCommand;
|
||||
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.command.commands.webuser.WebCheckCommand;
|
||||
import main.java.com.djrapitops.plan.command.commands.webuser.WebDeleteCommand;
|
||||
import main.java.com.djrapitops.plan.command.commands.webuser.WebLevelCommand;
|
||||
@ -17,9 +17,9 @@ import main.java.com.djrapitops.plan.locale.Msg;
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
public class WebUserCommand extends TreeCommand<Plan> {
|
||||
public class WebUserCommand extends TreeCommand<IPlan> {
|
||||
|
||||
public WebUserCommand(Plan plugin, RegisterCommand register) {
|
||||
public WebUserCommand(IPlan plugin, RegisterCommand register) {
|
||||
super(plugin, "webuser, web",
|
||||
CommandType.CONSOLE,
|
||||
Permissions.MANAGE_WEB.getPerm(),
|
||||
|
@ -6,7 +6,7 @@ import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
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.data.WebUser;
|
||||
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
@ -22,9 +22,9 @@ import org.bukkit.ChatColor;
|
||||
*/
|
||||
public class WebCheckCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
private final IPlan plugin;
|
||||
|
||||
public WebCheckCommand(Plan plugin) {
|
||||
public WebCheckCommand(IPlan plugin) {
|
||||
super("check",
|
||||
CommandType.CONSOLE_WITH_ARGUMENTS,
|
||||
Permissions.MANAGE_WEB.getPerm(),
|
||||
|
@ -6,7 +6,7 @@ import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
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.database.tables.SecurityTable;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
@ -21,9 +21,9 @@ import net.md_5.bungee.api.ChatColor;
|
||||
*/
|
||||
public class WebDeleteCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
private final IPlan plugin;
|
||||
|
||||
public WebDeleteCommand(Plan plugin) {
|
||||
public WebDeleteCommand(IPlan plugin) {
|
||||
super("delete, remove",
|
||||
CommandType.CONSOLE_WITH_ARGUMENTS,
|
||||
Permissions.MANAGE_WEB.getPerm(),
|
||||
|
@ -5,7 +5,7 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
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;
|
||||
|
||||
@ -17,9 +17,9 @@ import main.java.com.djrapitops.plan.locale.Msg;
|
||||
*/
|
||||
public class WebLevelCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
private final IPlan plugin;
|
||||
|
||||
public WebLevelCommand(Plan plugin) {
|
||||
public WebLevelCommand(IPlan plugin) {
|
||||
super("level",
|
||||
CommandType.CONSOLE,
|
||||
Permissions.MANAGE_WEB.getPerm(),
|
||||
|
@ -7,7 +7,7 @@ import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
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.data.WebUser;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
@ -23,9 +23,9 @@ import java.util.List;
|
||||
*/
|
||||
public class WebListUsersCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
private final IPlan plugin;
|
||||
|
||||
public WebListUsersCommand(Plan plugin) {
|
||||
public WebListUsersCommand(IPlan plugin) {
|
||||
super("list", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), "List registered web users & permission levels.");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user