Removed deprecated APF code usage

This commit is contained in:
Rsl1122 2018-04-11 11:26:59 +03:00
parent a27175e136
commit 4b4594d9b8
19 changed files with 58 additions and 99 deletions

View File

@ -22,7 +22,7 @@ import org.spongepowered.api.plugin.Plugin;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
@Plugin(id = "plan", name = "Plan", version = "4.2.0") @Plugin(id = "plan", name = "Plan", version = "4.2.0", description = "Player Analytics Plugin by Rsl1122", authors = {"Rsl1122"})
public class PlanSponge extends SpongePlugin implements PlanPlugin { public class PlanSponge extends SpongePlugin implements PlanPlugin {
@Inject @Inject
@ -90,7 +90,6 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
return PlanColorScheme.create(); return PlanColorScheme.create();
} }
@Override @Override
public void onReload() { public void onReload() {

View File

@ -9,7 +9,7 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode; import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCmdNode; import com.djrapitops.plugin.command.TreeCmdNode;
import com.djrapitops.plugin.command.defaultcmds.StatusCommandNode; import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
/** /**
* TreeCommand for the /plan command, and all subcommands. * TreeCommand for the /plan command, and all subcommands.
@ -48,7 +48,7 @@ public class PlanBungeeCommand extends TreeCmdNode {
new ManageConDebugCommand(), new ManageConDebugCommand(),
new BungeeSetupToggleCommand(), new BungeeSetupToggleCommand(),
new ReloadCommand(plugin), new ReloadCommand(plugin),
new StatusCommandNode<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()), new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
} }
); );
} }

View File

@ -9,7 +9,7 @@ import com.djrapitops.plan.system.settings.locale.Msg;
import com.djrapitops.plugin.command.CommandNode; import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCmdNode; import com.djrapitops.plugin.command.TreeCmdNode;
import com.djrapitops.plugin.command.defaultcmds.StatusCommandNode; import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
/** /**
* TreeCommand for the /plan command, and all SubCommands. * TreeCommand for the /plan command, and all SubCommands.
@ -45,7 +45,7 @@ public class PlanCommand extends TreeCmdNode {
new InfoCommand(plugin), new InfoCommand(plugin),
new ReloadCommand(plugin), new ReloadCommand(plugin),
new ManageCommand(plugin, this), new ManageCommand(plugin, this),
new StatusCommandNode<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()), new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
(Settings.DEV_MODE.isTrue() ? new DevCommand() : null) (Settings.DEV_MODE.isTrue() ? new DevCommand() : null)
} }
); );

View File

@ -20,7 +20,9 @@ import com.djrapitops.plugin.command.ISender;
public class DevCommand extends CommandNode { 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", "plan.*", CommandType.PLAYER_OR_ARGS);
setShortHelp("Test Plugin functions not testable with unit tests.");
setArguments("<feature>");
} }
@Override @Override

View File

@ -25,11 +25,8 @@ public class ListServersCommand extends CommandNode {
private final PlanPlugin plugin; private final PlanPlugin plugin;
public ListServersCommand(PlanPlugin plugin) { public ListServersCommand(PlanPlugin plugin) {
super("servers, serverlist, listservers, sl", super("servers|serverlist|listservers|sl|ls", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp("List servers in the network");
Permissions.MANAGE.getPermission(),
"List servers in the network",
"");
this.plugin = plugin; this.plugin = plugin;
} }

View File

@ -27,7 +27,8 @@ public class ManageCommand extends TreeCmdNode {
new ManageMoveCommand(), new ManageMoveCommand(),
new ManageBackupCommand(), new ManageBackupCommand(),
new ManageRestoreCommand(plugin), new ManageRestoreCommand(plugin),
new ManageHotswapCommand(plugin), new ManageRemoveCommand(),
new ManageHotSwapCommand(plugin),
new ManageClearCommand(plugin), new ManageClearCommand(plugin),
}, },
new CommandNode[]{ new CommandNode[]{

View File

@ -17,8 +17,7 @@ import com.djrapitops.plugin.command.ISender;
public class NetworkCommand extends CommandNode { public class NetworkCommand extends CommandNode {
public NetworkCommand() { public NetworkCommand() {
super("network|n|netw", super("network|n|netw", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
setShortHelp("View the network page"); setShortHelp("View the network page");
} }

View File

@ -32,11 +32,10 @@ import java.util.Arrays;
public class RegisterCommand extends CommandNode { public class RegisterCommand extends CommandNode {
public RegisterCommand() { public RegisterCommand() {
super("register", // No Permission Requirement
CommandType.PLAYER_OR_ARGS, super("register", "", CommandType.PLAYER_OR_ARGS);
"", // No Permission Requirement setShortHelp(Locale.get(Msg.CMD_USG_WEB_REGISTER).toString());
Locale.get(Msg.CMD_USG_WEB_REGISTER).toString(), setArguments("<password>", "[name]", "[lvl]");
"<password> [name] [lvl]");
setInDepthHelp(Locale.get(Msg.CMD_HELP_WEB_REGISTER).toArray()); setInDepthHelp(Locale.get(Msg.CMD_HELP_WEB_REGISTER).toArray());
if (Check.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
setupFilter(); setupFilter();

View File

@ -25,11 +25,9 @@ import java.util.List;
public class SearchCommand extends CommandNode { public class SearchCommand extends CommandNode {
public SearchCommand() { public SearchCommand() {
super("search", super("search", Permissions.SEARCH.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp(Locale.get(Msg.CMD_USG_SEARCH).toString());
Permissions.SEARCH.getPermission(), setArguments("<text>");
Locale.get(Msg.CMD_USG_SEARCH).toString(),
"<text>");
setInDepthHelp(Locale.get(Msg.CMD_HELP_SEARCH).toArray()); setInDepthHelp(Locale.get(Msg.CMD_HELP_SEARCH).toArray());
} }

View File

@ -25,11 +25,9 @@ import com.djrapitops.plugin.utilities.Verify;
public class ManageBackupCommand extends CommandNode { public class ManageBackupCommand extends CommandNode {
public ManageBackupCommand() { public ManageBackupCommand() {
super("backup", super("backup", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_MANAGE_BACKUP).toString());
Permissions.MANAGE.getPermission(), setArguments("<DB>");
Locale.get(Msg.CMD_USG_MANAGE_BACKUP).toString(),
"<DB>");
} }

View File

@ -32,12 +32,9 @@ public class ManageClearCommand extends CommandNode {
private final Plan plugin; private final Plan plugin;
public ManageClearCommand(Plan plugin) { public ManageClearCommand(Plan plugin) {
super("clear", super("clear", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp(Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString());
Permissions.MANAGE.getPermission(), setArguments("<DB>", "[-a]");
Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString(),
"<DB> [-a]");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_CLEAR).toArray()); setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_CLEAR).toArray());
this.plugin = plugin; this.plugin = plugin;

View File

@ -31,11 +31,8 @@ public class ManageConDebugCommand extends CommandNode {
private final ColorScheme cs; private final ColorScheme cs;
public ManageConDebugCommand() { public ManageConDebugCommand() {
super("con", super("con", Permissions.MANAGE.getPermission(), CommandType.ALL);
CommandType.ALL, setShortHelp("Debug Bukkit-Bungee Connections");
Permissions.MANAGE.getPermission(),
"Debug Bukkit-Bungee Connections",
"");
cs = PlanPlugin.getInstance().getColorScheme(); cs = PlanPlugin.getInstance().getColorScheme();
} }

View File

@ -20,11 +20,9 @@ public class ManageDisableCommand extends CommandNode {
* Class Constructor. * Class Constructor.
*/ */
public ManageDisableCommand() { public ManageDisableCommand() {
super("disable", super("disable", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp("Disable a feature temporarily");
Permissions.MANAGE.getPermission(), setArguments("<feature>");
"Disable a feature temporarily",
"<feature>");
} }
@Override @Override

View File

@ -21,16 +21,14 @@ import com.djrapitops.plugin.utilities.Verify;
* @author Rsl1122 * @author Rsl1122
* @since 2.3.0 * @since 2.3.0
*/ */
public class ManageHotswapCommand extends CommandNode { public class ManageHotSwapCommand extends CommandNode {
private final Plan plugin; private final Plan plugin;
public ManageHotswapCommand(Plan plugin) { public ManageHotSwapCommand(Plan plugin) {
super("hotswap", super("hotswap", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp(Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString());
Permissions.MANAGE.getPermission(), setArguments("<DB>");
Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString(),
"<DB>");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray()); setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray());
this.plugin = plugin; this.plugin = plugin;

View File

@ -23,11 +23,9 @@ import java.util.Arrays;
public class ManageImportCommand extends CommandNode { public class ManageImportCommand extends CommandNode {
public ManageImportCommand() { public ManageImportCommand() {
super("import", super("import", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_MANAGE_IMPORT).toString());
Permissions.MANAGE.getPermission(), setArguments("<plugin>/list", "[import args]");
Locale.get(Msg.CMD_USG_MANAGE_IMPORT).toString(),
"<plugin>/list [import args]");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_IMPORT).toArray()); setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_IMPORT).toArray());
} }

View File

@ -26,11 +26,9 @@ import com.djrapitops.plugin.utilities.Verify;
public class ManageMoveCommand extends CommandNode { public class ManageMoveCommand extends CommandNode {
public ManageMoveCommand() { public ManageMoveCommand() {
super("move", super("move", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp(Locale.get(Msg.CMD_USG_MANAGE_MOVE).toString());
Permissions.MANAGE.getPermission(), setArguments("<fromDB>", "<toDB>", "[-a]");
Locale.get(Msg.CMD_USG_MANAGE_MOVE).toString(),
"<fromDB> <toDB> [-a]");
} }
@Override @Override

View File

@ -1,8 +1,6 @@
package com.djrapitops.plan.command.commands.manage; package com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBException;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.Database;
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;
@ -11,49 +9,39 @@ 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.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;
import org.bukkit.entity.Player;
import java.util.UUID; import java.util.UUID;
import static org.bukkit.Bukkit.getPlayer;
/** /**
* This manage subcommand is used to remove a single player's data from the * This manage subcommand is used to remove a single player's data from the
* database. * database.
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class ManageRemoveCommand extends SubCommand { public class ManageRemoveCommand extends CommandNode {
public ManageRemoveCommand() { public ManageRemoveCommand() {
super("remove", super("remove|delete", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp(Locale.get(Msg.CMD_USG_MANAGE_REMOVE).toString());
Permissions.MANAGE.getPermission(), setArguments("<player>", "[-a]");
Locale.get(Msg.CMD_USG_MANAGE_REMOVE).toString(), setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_REMOVE).toArray());
"<player> [-a]");
} }
@Override @Override
public String[] addHelp() { public void onCommand(ISender sender, String commandLabel, String[] args) {
return Locale.get(Msg.CMD_HELP_MANAGE_REMOVE).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 playerName = MiscUtils.getPlayerName(args, sender, Permissions.MANAGE); String playerName = MiscUtils.getPlayerName(args, sender, Permissions.MANAGE);
runRemoveTask(playerName, sender, args); runRemoveTask(playerName, sender, args);
return true;
} }
private void runRemoveTask(String playerName, ISender sender, String[] args) { private void runRemoveTask(String playerName, ISender sender, String[] args) {
@ -83,11 +71,6 @@ public class ManageRemoveCommand extends SubCommand {
database.remove().player(uuid); database.remove().player(uuid);
Player player = getPlayer(uuid);
if (player != null) {
SessionCache.getActiveSessions().remove(uuid);
SessionCache.getInstance().cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name()));
}
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, Database.getActive().getConfigName())); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, Database.getActive().getConfigName()));
} catch (DBException e) { } catch (DBException e) {
Log.toLog(this.getClass(), e); Log.toLog(this.getClass(), e);

View File

@ -18,6 +18,7 @@ import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import java.io.File; import java.io.File;
import java.util.Arrays;
/** /**
* This manage SubCommand is used to restore a backup.db file in the * This manage SubCommand is used to restore a backup.db file in the
@ -30,18 +31,16 @@ public class ManageRestoreCommand extends CommandNode {
private final Plan plugin; private final Plan plugin;
public ManageRestoreCommand(Plan plugin) { public ManageRestoreCommand(Plan plugin) {
super("restore", super("restore", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
CommandType.CONSOLE, setShortHelp(Locale.get(Msg.CMD_USG_MANAGE_RESTORE).toString());
Permissions.MANAGE.getPermission(), setArguments("<Filename.db>", "<dbTo>", "[-a]");
Locale.get(Msg.CMD_USG_MANAGE_RESTORE).toString(),
"<Filename.db> <dbTo> [-a]");
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public void 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(Arrays.toString(this.getArguments())), sender)) {
return; return;
} }

View File

@ -23,11 +23,9 @@ import com.djrapitops.plugin.command.ISender;
public class ManageSetupCommand extends CommandNode { public class ManageSetupCommand extends CommandNode {
public ManageSetupCommand() { public ManageSetupCommand() {
super("setup", super("setup", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
CommandType.PLAYER_OR_ARGS, setShortHelp("Set-Up Bungee connection");
Permissions.MANAGE.getPermission(), setArguments("<BungeeAddress>");
"Set-Up Bungee connection",
"<BungeeAddress>");
setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray()); setInDepthHelp(Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray());
} }