mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-10 10:28:29 +01:00
Large changes: (Still compiles, does not function)
- Made all Command related things be initialized by Dagger - Removed Update stuff since it is incompatible with ConnectionSystem removal - Deprecated a lot of static methods
This commit is contained in:
parent
0b56576bb8
commit
b48eb26f74
@ -22,11 +22,8 @@ package com.djrapitops.plan;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.modules.APFModule;
|
||||
import com.djrapitops.plan.modules.common.ExportModule;
|
||||
import com.djrapitops.plan.modules.common.FileSystemModule;
|
||||
import com.djrapitops.plan.modules.common.LocaleModule;
|
||||
import com.djrapitops.plan.modules.common.VersionCheckModule;
|
||||
import com.djrapitops.plan.modules.server.ServerCommandModule;
|
||||
import com.djrapitops.plan.modules.common.*;
|
||||
import com.djrapitops.plan.modules.server.*;
|
||||
import com.djrapitops.plan.system.BukkitSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
@ -40,22 +37,33 @@ import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
||||
import com.djrapitops.plugin.benchmarking.Benchmark;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
BukkitPlanModule.class,
|
||||
APFModule.class,
|
||||
ServerCommandModule.class,
|
||||
ExportModule.class,
|
||||
VersionCheckModule.class,
|
||||
FileSystemModule.class,
|
||||
LocaleModule.class
|
||||
ServerConfigModule.class,
|
||||
LocaleModule.class,
|
||||
ServerDatabaseModule.class,
|
||||
ServerDataCacheModule.class,
|
||||
WebServerSystemModule.class,
|
||||
ServerInfoSystemModule.class,
|
||||
PluginHookModule.class,
|
||||
ServerAPIModule.class
|
||||
})
|
||||
interface PlanComponent {
|
||||
|
||||
@ -73,6 +81,21 @@ interface PlanComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Module
|
||||
class BukkitPlanModule {
|
||||
|
||||
@Provides
|
||||
PlanPlugin providePlanPlugin(Plan plan) {
|
||||
return plan;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("mainCommand")
|
||||
CommandNode provideMainCommand(PlanCommand command) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main class for Bukkit that manages the plugin.
|
||||
*
|
||||
|
@ -6,6 +6,11 @@ package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanBungeeCommand;
|
||||
import com.djrapitops.plan.modules.APFModule;
|
||||
import com.djrapitops.plan.modules.common.*;
|
||||
import com.djrapitops.plan.modules.server.ServerConfigModule;
|
||||
import com.djrapitops.plan.modules.server.ServerDatabaseModule;
|
||||
import com.djrapitops.plan.modules.server.ServerInfoSystemModule;
|
||||
import com.djrapitops.plan.system.BungeeSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
@ -15,12 +20,62 @@ import com.djrapitops.plugin.BungeePlugin;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
BungeePlanModule.class,
|
||||
APFModule.class,
|
||||
ExportModule.class,
|
||||
VersionCheckModule.class,
|
||||
FileSystemModule.class,
|
||||
ServerConfigModule.class,
|
||||
LocaleModule.class,
|
||||
ServerDatabaseModule.class,
|
||||
WebServerSystemModule.class,
|
||||
ServerInfoSystemModule.class,
|
||||
PluginHookModule.class
|
||||
})
|
||||
interface PlanBungeeComponent {
|
||||
|
||||
PlanBungeeCommand planCommand();
|
||||
|
||||
BungeeSystem system();
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
|
||||
@BindsInstance
|
||||
Builder plan(PlanBungee plan);
|
||||
|
||||
PlanBungeeComponent build();
|
||||
}
|
||||
}
|
||||
|
||||
@Module
|
||||
class BungeePlanModule {
|
||||
|
||||
@Provides
|
||||
PlanPlugin providePlanPlugin(PlanBungee plan) {
|
||||
return plan;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("mainCommand")
|
||||
CommandNode provideMainCommand(PlanBungeeCommand command) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bungee Main class.
|
||||
@ -39,36 +94,37 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
PlanBungeeComponent component = DaggerPlanBungeeComponent.builder().plan(this).build();
|
||||
try {
|
||||
system = new BungeeSystem(this);
|
||||
system = component.system();
|
||||
locale = system.getLocaleSystem().getLocale();
|
||||
system.enable();
|
||||
|
||||
new BStatsBungee(this).registerMetrics();
|
||||
|
||||
Log.info(locale.getString(PluginLang.ENABLED));
|
||||
logger.info(locale.getString(PluginLang.ENABLED));
|
||||
} catch (AbstractMethodError e) {
|
||||
Log.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||
logger.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||
} catch (EnableException e) {
|
||||
Log.error("----------------------------------------");
|
||||
Log.error("Error: " + e.getMessage());
|
||||
Log.error("----------------------------------------");
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||
logger.error("----------------------------------------");
|
||||
logger.error("Error: " + e.getMessage());
|
||||
logger.error("----------------------------------------");
|
||||
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||
onDisable();
|
||||
} catch (Exception e) {
|
||||
Logger.getGlobal().log(Level.SEVERE, this.getClass().getSimpleName() + "-v" + getVersion(), e);
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||
Log.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
errorHandler.log(L.CRITICAL, this.getClass(), e);
|
||||
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||
logger.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
onDisable();
|
||||
}
|
||||
registerCommand("planbungee", new PlanBungeeCommand(this));
|
||||
registerCommand("planbungee", component.planCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
system.disable();
|
||||
|
||||
Log.info(locale.getString(PluginLang.DISABLED));
|
||||
logger.info(locale.getString(PluginLang.DISABLED));
|
||||
Benchmark.pluginDisabled(PlanBungee.class);
|
||||
DebugLog.pluginDisabled(PlanBungee.class);
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.modules.APFModule;
|
||||
import com.djrapitops.plan.modules.common.*;
|
||||
import com.djrapitops.plan.modules.server.*;
|
||||
import com.djrapitops.plan.system.SpongeSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
@ -13,7 +16,13 @@ import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.google.inject.Inject;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import org.bstats.sponge.Metrics;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
@ -22,9 +31,58 @@ import org.spongepowered.api.event.game.state.GameStartedServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
SpongePlanModule.class,
|
||||
APFModule.class,
|
||||
ExportModule.class,
|
||||
VersionCheckModule.class,
|
||||
FileSystemModule.class,
|
||||
ServerConfigModule.class,
|
||||
LocaleModule.class,
|
||||
ServerDatabaseModule.class,
|
||||
ServerDataCacheModule.class,
|
||||
WebServerSystemModule.class,
|
||||
ServerInfoSystemModule.class,
|
||||
PluginHookModule.class,
|
||||
ServerAPIModule.class,
|
||||
})
|
||||
interface PlanSpongeComponent {
|
||||
|
||||
PlanCommand planCommand();
|
||||
|
||||
SpongeSystem system();
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
|
||||
@BindsInstance
|
||||
Builder plan(PlanSponge plan);
|
||||
|
||||
PlanSpongeComponent build();
|
||||
}
|
||||
}
|
||||
|
||||
@Module
|
||||
class SpongePlanModule {
|
||||
|
||||
@Provides
|
||||
PlanPlugin providePlanPlugin(PlanSponge plan) {
|
||||
return plan;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("mainCommand")
|
||||
CommandNode provideMainCommand(PlanCommand command) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
@Plugin(id = "plan", name = "Plan", version = "4.4.3", description = "Player Analytics Plugin by Rsl1122", authors = {"Rsl1122"})
|
||||
public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
||||
|
||||
@ -57,29 +115,30 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
PlanSpongeComponent component = DaggerPlanSpongeComponent.builder().plan(this).build();
|
||||
try {
|
||||
system = new SpongeSystem(this);
|
||||
system = component.system();
|
||||
locale = system.getLocaleSystem().getLocale();
|
||||
system.enable();
|
||||
|
||||
new BStatsSponge(metrics).registerMetrics();
|
||||
|
||||
Log.info(locale.getString(PluginLang.ENABLED));
|
||||
logger.info(locale.getString(PluginLang.ENABLED));
|
||||
} catch (AbstractMethodError e) {
|
||||
Log.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||
logger.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||
} catch (EnableException e) {
|
||||
Log.error("----------------------------------------");
|
||||
Log.error("Error: " + e.getMessage());
|
||||
Log.error("----------------------------------------");
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
||||
logger.error("----------------------------------------");
|
||||
logger.error("Error: " + e.getMessage());
|
||||
logger.error("----------------------------------------");
|
||||
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
||||
onDisable();
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getSimpleName() + "-v" + getVersion(), e);
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
||||
Log.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
errorHandler.log(L.CRITICAL, this.getClass(), e);
|
||||
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
||||
logger.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
onDisable();
|
||||
}
|
||||
registerCommand("plan", new PlanCommand(this));
|
||||
registerCommand("plan", component.planCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +1,18 @@
|
||||
package com.djrapitops.plan.command;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.commands.*;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageConDebugCommand;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageRawDataCommand;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* TreeCommand for the /plan command, and all subcommands.
|
||||
* <p>
|
||||
@ -21,31 +23,42 @@ import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
*/
|
||||
public class PlanBungeeCommand extends TreeCmdNode {
|
||||
|
||||
public PlanBungeeCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public PlanBungeeCommand(ColorScheme colorScheme, Locale locale,
|
||||
// Group 1
|
||||
NetworkCommand networkCommand,
|
||||
ListServersCommand listServersCommand,
|
||||
ListPlayersCommand listPlayersCommand,
|
||||
// Group 2
|
||||
RegisterCommand registerCommand,
|
||||
WebUserCommand webUserCommand,
|
||||
// Group 3
|
||||
ManageConDebugCommand conDebugCommand,
|
||||
ManageRawDataCommand rawDataCommand,
|
||||
BungeeSetupToggleCommand setupToggleCommand,
|
||||
ReloadCommand reloadCommand,
|
||||
DisableCommand disableCommand
|
||||
) {
|
||||
super("planbungee", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, null);
|
||||
super.setColorScheme(plugin.getColorScheme());
|
||||
|
||||
Locale locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
super.setColorScheme(colorScheme);
|
||||
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAN));
|
||||
|
||||
RegisterCommand registerCommand = new RegisterCommand(plugin);
|
||||
CommandNode[] analyticsGroup = {
|
||||
new NetworkCommand(plugin),
|
||||
new ListServersCommand(plugin),
|
||||
new ListPlayersCommand(plugin),
|
||||
networkCommand,
|
||||
listServersCommand,
|
||||
listPlayersCommand
|
||||
};
|
||||
CommandNode[] webGroup = {
|
||||
registerCommand,
|
||||
new WebUserCommand(plugin, registerCommand, this),
|
||||
webUserCommand
|
||||
};
|
||||
CommandNode[] manageGroup = {
|
||||
new ManageConDebugCommand(plugin),
|
||||
new ManageRawDataCommand(plugin),
|
||||
new BungeeSetupToggleCommand(plugin),
|
||||
new ReloadCommand(plugin),
|
||||
new DisableCommand(plugin),
|
||||
// (Settings.ALLOW_UPDATE.isTrue() ? new UpdateCommand() : null)
|
||||
conDebugCommand,
|
||||
rawDataCommand,
|
||||
setupToggleCommand,
|
||||
reloadCommand,
|
||||
disableCommand
|
||||
};
|
||||
setNodeGroups(analyticsGroup, webGroup, manageGroup);
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
package com.djrapitops.plan.command;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.commands.*;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* TreeCommand for the /plan command, and all SubCommands.
|
||||
* <p>
|
||||
@ -19,35 +22,49 @@ import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
*/
|
||||
public class PlanCommand extends TreeCmdNode {
|
||||
|
||||
public PlanCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public PlanCommand(ColorScheme colorScheme, Locale locale, PlanConfig config,
|
||||
// Group 1
|
||||
InspectCommand inspectCommand,
|
||||
QInspectCommand qInspectCommand,
|
||||
SearchCommand searchCommand,
|
||||
ListPlayersCommand listPlayersCommand,
|
||||
AnalyzeCommand analyzeCommand,
|
||||
NetworkCommand networkCommand,
|
||||
ListServersCommand listServersCommand,
|
||||
// Group 2
|
||||
WebUserCommand webUserCommand,
|
||||
RegisterCommand registerCommand,
|
||||
// Group 3
|
||||
InfoCommand infoCommand,
|
||||
ReloadCommand reloadCommand,
|
||||
ManageCommand manageCommand,
|
||||
DevCommand devCommand
|
||||
) {
|
||||
super("plan", "", CommandType.CONSOLE, null);
|
||||
super.setDefaultCommand("inspect");
|
||||
super.setColorScheme(plugin.getColorScheme());
|
||||
|
||||
Locale locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
super.setColorScheme(colorScheme);
|
||||
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAN));
|
||||
|
||||
RegisterCommand registerCommand = new RegisterCommand(plugin);
|
||||
CommandNode[] analyticsGroup = {
|
||||
new InspectCommand(plugin),
|
||||
new QInspectCommand(plugin),
|
||||
new SearchCommand(plugin),
|
||||
new ListPlayersCommand(plugin),
|
||||
new AnalyzeCommand(plugin),
|
||||
new NetworkCommand(plugin),
|
||||
new ListServersCommand(plugin)
|
||||
inspectCommand,
|
||||
qInspectCommand,
|
||||
searchCommand,
|
||||
listPlayersCommand,
|
||||
analyzeCommand,
|
||||
networkCommand,
|
||||
listServersCommand
|
||||
};
|
||||
CommandNode[] webGroup = {
|
||||
new WebUserCommand(plugin, registerCommand, this),
|
||||
webUserCommand,
|
||||
registerCommand
|
||||
};
|
||||
CommandNode[] manageGroup = {
|
||||
new InfoCommand(plugin),
|
||||
new ReloadCommand(plugin),
|
||||
new ManageCommand(plugin, this),
|
||||
(Settings.DEV_MODE.isTrue() ? new DevCommand(plugin) : null),
|
||||
// (Settings.ALLOW_UPDATE.isTrue() ? new UpdateCommand() : null)
|
||||
infoCommand,
|
||||
reloadCommand,
|
||||
manageCommand,
|
||||
config.isTrue(Settings.DEV_MODE) ? devCommand : null
|
||||
};
|
||||
setNodeGroups(analyticsGroup, webGroup, manageGroup);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
@ -15,13 +14,15 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -35,11 +36,22 @@ import java.util.UUID;
|
||||
public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final InfoSystem infoSystem;
|
||||
private final WebServer webServer;
|
||||
private final Database database;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public AnalyzeCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public AnalyzeCommand(Locale locale, InfoSystem infoSystem, WebServer webServer, Database database, ErrorHandler errorHandler) {
|
||||
super("analyze|analyse|analysis|a", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.infoSystem = infoSystem;
|
||||
connectionSystem = infoSystem.getConnectionSystem();
|
||||
this.webServer = webServer;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.ANALYZE));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.ANALYZE));
|
||||
@ -52,22 +64,22 @@ public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
Processing.submitNonCritical(() -> {
|
||||
try {
|
||||
Server server = getServer(args).orElseGet(ServerInfo::getServer);
|
||||
Server server = getServer(args).orElseGet(ServerInfo::getServer_Old);
|
||||
UUID serverUUID = server.getUuid();
|
||||
|
||||
InfoSystem.getInstance().generateAnalysisPage(serverUUID);
|
||||
infoSystem.generateAnalysisPage(serverUUID);
|
||||
sendWebUserNotificationIfNecessary(sender);
|
||||
sendLink(server, sender);
|
||||
} catch (DBOpException | WebException e) {
|
||||
sender.sendMessage("§cError occurred: " + e.toString());
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendLink(Server server, ISender sender) {
|
||||
String target = "/server/" + server.getName();
|
||||
String url = ConnectionSystem.getAddress() + target;
|
||||
String url = connectionSystem.getMainAddress() + target;
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_ANALYSIS));
|
||||
// Link
|
||||
@ -82,18 +94,16 @@ public class AnalyzeCommand extends CommandNode {
|
||||
}
|
||||
|
||||
private void sendWebUserNotificationIfNecessary(ISender sender) {
|
||||
if (WebServerSystem.getInstance().getWebServer().isAuthRequired() && CommandUtils.isPlayer(sender)) {
|
||||
|
||||
boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName());
|
||||
if (!senderHasWebUser) {
|
||||
if (webServer.isAuthRequired() &&
|
||||
CommandUtils.isPlayer(sender) &&
|
||||
!database.check().doesWebUserExists(sender.getName())) {
|
||||
sender.sendMessage("§e" + locale.getString(CommandLang.NO_WEB_USER_NOTIFY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<Server> getServer(String[] args) {
|
||||
if (args.length >= 1 && ConnectionSystem.getInstance().isServerAvailable()) {
|
||||
Map<UUID, Server> bukkitServers = Database.getActive().fetch().getBukkitServers();
|
||||
if (args.length >= 1 && connectionSystem.isServerAvailable()) {
|
||||
Map<UUID, Server> bukkitServers = database.fetch().getBukkitServers();
|
||||
String serverIdentifier = getGivenIdentifier(args);
|
||||
for (Map.Entry<UUID, Server> entry : bukkitServers.entrySet()) {
|
||||
Server server = entry.getValue();
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -15,6 +14,8 @@ import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Command for Toggling whether or not BungeeCord accepts set up requests.
|
||||
* <p>
|
||||
@ -25,11 +26,14 @@ import com.djrapitops.plugin.command.ISender;
|
||||
public class BungeeSetupToggleCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
public BungeeSetupToggleCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public BungeeSetupToggleCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
super("setup", Permissions.MANAGE.getPermission(), CommandType.ALL);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.SETUP));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.SETUP));
|
||||
@ -37,15 +41,13 @@ public class BungeeSetupToggleCommand extends CommandNode {
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String s, String[] strings) {
|
||||
boolean setupAllowed = ConnectionSystem.isSetupAllowed();
|
||||
ConnectionSystem connectionSystem = ConnectionSystem.getInstance();
|
||||
|
||||
if (setupAllowed) {
|
||||
if (connectionSystem.isSetupAllowed()) {
|
||||
connectionSystem.setSetupAllowed(false);
|
||||
} else {
|
||||
connectionSystem.setSetupAllowed(true);
|
||||
}
|
||||
String msg = locale.getString(!setupAllowed ? CommandLang.SETUP_ALLOWED : CommandLang.CONNECT_FORBIDDEN);
|
||||
|
||||
String msg = locale.getString(connectionSystem.isSetupAllowed() ? CommandLang.SETUP_ALLOWED : CommandLang.CONNECT_FORBIDDEN);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -13,6 +12,7 @@ import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -24,10 +24,11 @@ public class DevCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
|
||||
public DevCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public DevCommand(Locale locale) {
|
||||
super("dev", "plan.*", CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
|
||||
setShortHelp(locale.get(CmdHelpLang.DEV).toString());
|
||||
setArguments("<feature>");
|
||||
|
@ -9,14 +9,19 @@ import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DisableCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final PlanPlugin plugin;
|
||||
|
||||
public DisableCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public DisableCommand(PlanPlugin plugin, Locale locale) {
|
||||
super("disable", "plan.reload", CommandType.ALL);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.plugin = plugin;
|
||||
this.locale = locale;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.DISABLE));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.DISABLE));
|
||||
@ -24,7 +29,7 @@ public class DisableCommand extends CommandNode {
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
PlanPlugin.getInstance().onDisable();
|
||||
plugin.onDisable();
|
||||
sender.sendMessage(locale.getString(CommandLang.DISABLE_DISABLED));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* This SubCommand is used to view the version and the database type in use.
|
||||
*
|
||||
@ -23,14 +25,19 @@ public class InfoCommand extends CommandNode {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
|
||||
public InfoCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public InfoCommand(PlanPlugin plugin, Locale locale, ConnectionSystem connectionSystem, VersionCheckSystem versionCheckSystem) {
|
||||
super("info", Permissions.INFO.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.plugin = plugin;
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
|
||||
setShortHelp(locale.get(CmdHelpLang.INFO).toString());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,8 +45,8 @@ public class InfoCommand extends CommandNode {
|
||||
String yes = locale.getString(GenericLang.YES);
|
||||
String no = locale.getString(GenericLang.NO);
|
||||
|
||||
String updateAvailable = VersionCheckSystem.isNewVersionAvailable() ? yes : no;
|
||||
String connectedToBungee = ConnectionSystem.getInstance().isServerAvailable() ? yes : no;
|
||||
String updateAvailable = versionCheckSystem.isNewVersionAvailable() ? yes : no;
|
||||
String connectedToBungee = connectionSystem.isServerAvailable() ? yes : no;
|
||||
String[] messages = {
|
||||
locale.getString(CommandLang.HEADER_INFO),
|
||||
"",
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -13,12 +12,14 @@ import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
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.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -30,12 +31,19 @@ import java.util.UUID;
|
||||
public class InspectCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final WebServer webServer;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public InspectCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public InspectCommand(Locale locale, Database database, WebServer webServer, ErrorHandler errorHandler) {
|
||||
super("inspect", Permissions.INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
setArguments("<player>");
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.webServer = webServer;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.INSPECT));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.INSPECT));
|
||||
@ -61,24 +69,23 @@ public class InspectCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
Database activeDB = Database.getActive();
|
||||
if (!activeDB.check().isPlayerRegistered(uuid)) {
|
||||
if (!database.check().isPlayerRegistered(uuid)) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
|
||||
return;
|
||||
}
|
||||
|
||||
checkWebUserAndNotify(activeDB, sender);
|
||||
checkWebUserAndNotify(sender);
|
||||
Processing.submit(new InspectCacheRequestProcessor(uuid, sender, playerName, locale));
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkWebUserAndNotify(Database activeDB, ISender sender) {
|
||||
if (CommandUtils.isPlayer(sender) && WebServer.getInstance().isAuthRequired()) {
|
||||
boolean senderHasWebUser = activeDB.check().doesWebUserExists(sender.getName());
|
||||
private void checkWebUserAndNotify(ISender sender) {
|
||||
if (CommandUtils.isPlayer(sender) && webServer.isAuthRequired()) {
|
||||
boolean senderHasWebUser = database.check().doesWebUserExists(sender.getName());
|
||||
|
||||
if (!senderHasWebUser) {
|
||||
sender.sendMessage("§e" + locale.getString(CommandLang.NO_WEB_USER_NOTIFY));
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -12,6 +11,8 @@ import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Command used to display url to the player list page.
|
||||
*
|
||||
@ -21,11 +22,14 @@ import com.djrapitops.plugin.command.ISender;
|
||||
public class ListPlayersCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
public ListPlayersCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ListPlayersCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
super("players|pl|playerlist|list", Permissions.INSPECT_OTHER.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.PLAYERS));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAYERS));
|
||||
@ -40,7 +44,7 @@ public class ListPlayersCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_PLAYERS));
|
||||
|
||||
// Link
|
||||
String url = ConnectionSystem.getAddress() + "/players/";
|
||||
String url = connectionSystem.getMainAddress() + "/players/";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -9,12 +9,14 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -24,14 +26,19 @@ import java.util.List;
|
||||
*/
|
||||
public class ListServersCommand extends CommandNode {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final ColorScheme colorScheme;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public ListServersCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ListServersCommand(Locale locale, ColorScheme colorScheme, Database database, ErrorHandler errorHandler) {
|
||||
super("servers|serverlist|listservers|sl|ls", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
|
||||
this.plugin = plugin;
|
||||
|
||||
this.locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.colorScheme = colorScheme;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.SERVERS));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.SERVERS));
|
||||
@ -39,20 +46,28 @@ public class ListServersCommand extends CommandNode {
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
ColorScheme colorScheme = plugin.getColorScheme();
|
||||
String sCol = colorScheme.getSecondaryColor();
|
||||
String tCol = colorScheme.getTertiaryColor();
|
||||
Formatter<Server> serverFormatter = serverLister(sCol, tCol);
|
||||
try {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_SERVERS));
|
||||
List<Server> servers = Database.getActive().fetch().getServers();
|
||||
for (Server server : servers) {
|
||||
sender.sendMessage(" " + tCol + server.getId() + sCol + " : " + server.getName() + " : " + server.getWebAddress());
|
||||
}
|
||||
sendServers(sender, serverFormatter);
|
||||
sender.sendMessage(">");
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§cDatabase Exception occurred.");
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendServers(ISender sender, Formatter<Server> serverFormatter) {
|
||||
List<Server> servers = database.fetch().getServers();
|
||||
for (Server server : servers) {
|
||||
sender.sendMessage(serverFormatter.apply(server));
|
||||
}
|
||||
}
|
||||
|
||||
private Formatter<Server> serverLister(String tertiaryColor, String secondaryColor) {
|
||||
return server -> " " + tertiaryColor + server.getId() + secondaryColor + " : " + server.getName() + " : " + server.getWebAddress();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.commands.manage.*;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
import dagger.Lazy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* This SubCommand is used to manage the the plugin's database and components.
|
||||
@ -18,29 +22,43 @@ import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
*/
|
||||
public class ManageCommand extends TreeCmdNode {
|
||||
|
||||
public ManageCommand(PlanPlugin plugin, CommandNode parent) {
|
||||
super("manage|m", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, parent);
|
||||
|
||||
Locale locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
@Inject
|
||||
public ManageCommand(ColorScheme colorScheme, Locale locale, @Named("mainCommand") Lazy<CommandNode> parent,
|
||||
// Group 1
|
||||
ManageRawDataCommand rawDataCommand,
|
||||
ManageMoveCommand moveCommand,
|
||||
ManageBackupCommand backupCommand,
|
||||
ManageRemoveCommand removeCommand,
|
||||
ManageRestoreCommand restoreCommand,
|
||||
ManageHotSwapCommand hotSwapCommand,
|
||||
ManageClearCommand clearCommand,
|
||||
// Group 2
|
||||
ManageSetupCommand setupCommand,
|
||||
ManageConDebugCommand conDebugCommand,
|
||||
ManageImportCommand importCommand,
|
||||
ManageDisableCommand disableCommand,
|
||||
ManageUninstalledCommand uninstalledCommand
|
||||
) {
|
||||
super("manage|m", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, parent.get());
|
||||
super.setColorScheme(colorScheme);
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE));
|
||||
super.setColorScheme(plugin.getColorScheme());
|
||||
CommandNode[] databaseGroup = {
|
||||
new ManageRawDataCommand(plugin),
|
||||
new ManageMoveCommand(plugin),
|
||||
new ManageBackupCommand(plugin),
|
||||
new ManageRestoreCommand(plugin),
|
||||
new ManageRemoveCommand(plugin),
|
||||
new ManageHotSwapCommand(plugin),
|
||||
new ManageClearCommand(plugin),
|
||||
rawDataCommand,
|
||||
moveCommand,
|
||||
backupCommand,
|
||||
restoreCommand,
|
||||
hotSwapCommand,
|
||||
removeCommand,
|
||||
clearCommand,
|
||||
};
|
||||
CommandNode[] pluginGroup = {
|
||||
new ManageSetupCommand(plugin),
|
||||
new ManageConDebugCommand(plugin),
|
||||
new ManageImportCommand(plugin),
|
||||
new ManageDisableCommand(plugin),
|
||||
new ManageUninstalledCommand(plugin)
|
||||
setupCommand,
|
||||
conDebugCommand,
|
||||
importCommand,
|
||||
disableCommand,
|
||||
uninstalledCommand
|
||||
};
|
||||
setNodeGroups(databaseGroup, pluginGroup);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -12,6 +11,8 @@ import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Command used to display url to the network page.
|
||||
*
|
||||
@ -20,11 +21,14 @@ import com.djrapitops.plugin.command.ISender;
|
||||
public class NetworkCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
public NetworkCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public NetworkCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
super("network|n|netw", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.NETWORK));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.NETWORK));
|
||||
@ -39,7 +43,7 @@ public class NetworkCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_NETWORK));
|
||||
|
||||
// Link
|
||||
String url = ConnectionSystem.getAddress() + "/network/";
|
||||
String url = connectionSystem.getMainAddress() + "/network/";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
@ -21,11 +20,13 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -40,17 +41,17 @@ import java.util.UUID;
|
||||
public class QInspectCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public QInspectCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public QInspectCommand(Locale locale, Database database, ErrorHandler errorHandler) {
|
||||
super("qinspect", Permissions.QUICK_INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
setArguments("<player>");
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.QINSPECT));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.QINSPECT));
|
||||
@ -77,7 +78,7 @@ public class QInspectCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerContainer container = Database.getActive().fetch().getPlayerContainer(uuid);
|
||||
PlayerContainer container = database.fetch().getPlayerContainer(uuid);
|
||||
if (!container.getValue(PlayerKeys.REGISTERED).isPresent()) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
|
||||
return;
|
||||
@ -86,7 +87,7 @@ public class QInspectCommand extends CommandNode {
|
||||
sendMessages(sender, container);
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -11,13 +10,16 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
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.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -34,14 +36,20 @@ import java.util.Arrays;
|
||||
public class RegisterCommand extends CommandNode {
|
||||
|
||||
private final String notEnoughArgsMsg;
|
||||
private final String hashErrorMsg;
|
||||
private final Locale locale;
|
||||
private final PluginLogger logger;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public RegisterCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public RegisterCommand(Locale locale, PluginLogger logger, Database database, ErrorHandler errorHandler) {
|
||||
// No Permission Requirement
|
||||
super("register", "", CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.logger = logger;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<password>", "[name]", "[lvl]");
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_REGISTER));
|
||||
@ -51,7 +59,6 @@ public class RegisterCommand extends CommandNode {
|
||||
}
|
||||
|
||||
notEnoughArgsMsg = locale.getString(CommandLang.FAIL_REQ_ARGS, 3, Arrays.toString(getArguments()));
|
||||
hashErrorMsg = "§cPassword hash error.";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,12 +70,12 @@ public class RegisterCommand extends CommandNode {
|
||||
consoleRegister(args, sender, notEnoughArgsMsg);
|
||||
}
|
||||
} catch (PassEncryptUtil.CannotPerformOperationException e) {
|
||||
Log.toLog(this.getClass().getSimpleName(), e);
|
||||
sender.sendMessage(hashErrorMsg);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
sender.sendMessage("§cPassword hash error.");
|
||||
} catch (NumberFormatException e) {
|
||||
throw new NumberFormatException(args[2]);
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getSimpleName(), e);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +122,6 @@ public class RegisterCommand extends CommandNode {
|
||||
Processing.submitCritical(() -> {
|
||||
String userName = webUser.getName();
|
||||
try {
|
||||
Database database = Database.getActive();
|
||||
boolean userExists = database.check().doesWebUserExists(userName);
|
||||
if (userExists) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_EXISTS));
|
||||
@ -123,9 +129,9 @@ public class RegisterCommand extends CommandNode {
|
||||
}
|
||||
database.save().webUser(webUser);
|
||||
sender.sendMessage(locale.getString(CommandLang.WEB_USER_REGISTER_SUCCESS));
|
||||
Log.info(locale.getString(CommandLang.WEB_USER_REGISTER_NOTIFY, userName, webUser.getPermLevel()));
|
||||
logger.info(locale.getString(CommandLang.WEB_USER_REGISTER_NOTIFY, userName, webUser.getPermLevel()));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -6,13 +6,16 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* This SubCommand is used to reload the plugin.
|
||||
*
|
||||
@ -23,12 +26,17 @@ public class ReloadCommand extends CommandNode {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final ErrorHandler errorHandler;
|
||||
private final RunnableFactory runnableFactory;
|
||||
|
||||
public ReloadCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ReloadCommand(PlanPlugin plugin, Locale locale, RunnableFactory runnableFactory, ErrorHandler errorHandler) {
|
||||
super("reload", Permissions.RELOAD.getPermission(), CommandType.CONSOLE);
|
||||
this.plugin = plugin;
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.plugin = plugin;
|
||||
this.locale = locale;
|
||||
this.runnableFactory = runnableFactory;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.RELOAD));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.RELOAD));
|
||||
@ -36,13 +44,13 @@ public class ReloadCommand extends CommandNode {
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
RunnableFactory.createNew("Reload task", new AbsRunnable() {
|
||||
runnableFactory.create("Reload task", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
plugin.reloadPlugin(true);
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.CRITICAL, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(CommandLang.RELOAD_FAILED));
|
||||
}
|
||||
sender.sendMessage(locale.getString(CommandLang.RELOAD_COMPLETE));
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -9,15 +9,16 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.utilities.FormatUtils;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -29,11 +30,16 @@ import java.util.List;
|
||||
public class SearchCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public SearchCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public SearchCommand(Locale locale, Database database, ErrorHandler errorHandler) {
|
||||
super("search", Permissions.SEARCH.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<text>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.SEARCH));
|
||||
@ -54,20 +60,21 @@ public class SearchCommand extends CommandNode {
|
||||
Processing.submitNonCritical(() -> {
|
||||
try {
|
||||
String searchTerm = args[0];
|
||||
List<String> names = MiscUtils.getMatchingPlayerNames(searchTerm);
|
||||
|
||||
List<String> names = database.search().matchingPlayers(searchTerm);
|
||||
Collections.sort(names);
|
||||
boolean empty = Verify.isEmpty(names);
|
||||
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_SEARCH, empty ? 0 : names.size(), searchTerm));
|
||||
// Results
|
||||
if (!empty) {
|
||||
sender.sendMessage(FormatUtils.collectionToStringNoBrackets(names));
|
||||
String message = names.toString();
|
||||
sender.sendMessage(message.substring(1, message.length() - 1));
|
||||
}
|
||||
|
||||
sender.sendMessage(">");
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§cDatabase error occurred: " + e.getMessage());
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,237 +0,0 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.command.commands.manage.ManageConDebugCommand;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.request.UpdateCancelRequest;
|
||||
import com.djrapitops.plan.system.info.request.UpdateRequest;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.system.update.VersionInfo;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
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.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Command that updates all servers in the network
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class UpdateCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
|
||||
public UpdateCommand(PlanPlugin plugin) {
|
||||
super("update", Permissions.MANAGE.getPermission(), CommandType.ALL);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
|
||||
setArguments("[-u]/[cancel]");
|
||||
setShortHelp(locale.getString(CmdHelpLang.UPDATE));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.UPDATE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!VersionCheckSystem.isNewVersionAvailable()) {
|
||||
sender.sendMessage("§a" + locale.getString(PluginLang.VERSION_NEWEST));
|
||||
return;
|
||||
}
|
||||
|
||||
VersionInfo available = VersionCheckSystem.getInstance().getNewVersionAvailable();
|
||||
String downloadUrl = available.getDownloadUrl();
|
||||
|
||||
if (!available.isTrusted()) {
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_WRONG_URL, "https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/"));
|
||||
sender.sendLink(downloadUrl, downloadUrl);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
String message = locale.getString(CommandLang.UPDATE_CHANGE_LOG, available.getVersion().toString());
|
||||
String url = available.getChangeLogUrl();
|
||||
if (CommandUtils.isConsole(sender)) {
|
||||
sender.sendMessage(message + url);
|
||||
} else {
|
||||
sender.sendMessage(message);
|
||||
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String firstArgument = args[0];
|
||||
RunnableFactory.createNew("Update Command Task", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if ("-u".equals(firstArgument)) {
|
||||
handleUpdate(sender, args);
|
||||
} else if ("cancel".equals(firstArgument)) {
|
||||
handleCancel(sender);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown argument, use '-u' or 'cancel'");
|
||||
}
|
||||
} finally {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}).runTaskAsynchronously();
|
||||
}
|
||||
|
||||
private void handleCancel(ISender sender) {
|
||||
try {
|
||||
cancel(sender, Database.getActive().fetch().getServers());
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_CANCEL_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§cDatabase error occurred, cancel could not be performed.");
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUpdate(ISender sender, String[] args) {
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_NOTIFY_CANCEL));
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_ONLINE_CHECK));
|
||||
if (!checkNetworkStatus(sender)) {
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_FAIL_NOT_ONLINE));
|
||||
// If -force, continue, otherwise return.
|
||||
if (args.length < 2 || !"-force".equals(args[1])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
List<Server> servers = Database.getActive().fetch().getServers();
|
||||
update(sender, servers, args);
|
||||
} catch (DBOpException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void update(ISender sender, List<Server> servers, String[] args) {
|
||||
for (Server server : servers) {
|
||||
if (update(sender, server)) {
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_SCHEDULED, server.getName()));
|
||||
} else {
|
||||
if (args.length > 1 && "-force".equals(args[1])) {
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_FAIL_FORCED));
|
||||
continue;
|
||||
}
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_FAIL_CANCEL));
|
||||
cancel(sender, servers);
|
||||
sender.sendMessage(locale.getString(CommandLang.UPDATE_CANCELLED));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cancel(ISender sender, List<Server> servers) {
|
||||
for (Server server : servers) {
|
||||
cancel(sender, server);
|
||||
}
|
||||
}
|
||||
|
||||
private void cancel(ISender sender, Server server) {
|
||||
try {
|
||||
InfoSystem.getInstance().getConnectionSystem().sendInfoRequest(new UpdateCancelRequest(), server);
|
||||
} catch (ForbiddenException | GatewayException | InternalErrorException e) {
|
||||
sender.sendMessage("§cCancel failed on " + server.getName() + ": Odd Exception: " + e.getClass().getSimpleName());
|
||||
} catch (UnauthorizedServerException e) {
|
||||
sender.sendMessage("§cCancel failed on " + server.getName() + ": Unauthorized. " + server.getName() + " might be using different database.");
|
||||
} catch (ConnectionFailException e) {
|
||||
sender.sendMessage("§cCancel failed on " + server.getName() + ": " + e.getCause().getClass().getSimpleName() + " " + e.getCause().getMessage());
|
||||
String address = server.getWebAddress();
|
||||
boolean local = address.contains("localhost")
|
||||
|| address.startsWith("https://:") // IP empty = Localhost
|
||||
|| address.startsWith("http://:") // IP empty = Localhost
|
||||
|| address.contains("127.0.0.1");
|
||||
if (!local) {
|
||||
sender.sendMessage("§cNon-local address, check that port is open");
|
||||
}
|
||||
} catch (NotFoundException e) {
|
||||
/* Ignored, older version */
|
||||
} catch (WebException e) {
|
||||
sender.sendMessage("§cCancel failed on " + server.getName() + ": Odd Exception:" + e.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean update(ISender sender, Server server) {
|
||||
try {
|
||||
InfoSystem.getInstance().getConnectionSystem().sendInfoRequest(new UpdateRequest(), server);
|
||||
return true;
|
||||
} catch (BadRequestException e) {
|
||||
sender.sendMessage("§c" + server.getName() + " has Allow-Update set to false, aborting update.");
|
||||
return false;
|
||||
} catch (ForbiddenException | GatewayException | InternalErrorException | NoServersException e) {
|
||||
sender.sendMessage("§c" + server.getName() + ": Odd Exception: " + e.getClass().getSimpleName());
|
||||
return false;
|
||||
} catch (UnauthorizedServerException e) {
|
||||
sender.sendMessage("§cFail reason: Unauthorized. " + server.getName() + " might be using different database.");
|
||||
return false;
|
||||
} catch (ConnectionFailException e) {
|
||||
sender.sendMessage("§cFail reason: " + e.getCause().getClass().getSimpleName() + " " + e.getCause().getMessage());
|
||||
String address = server.getWebAddress();
|
||||
boolean local = address.contains("localhost")
|
||||
|| address.startsWith("https://:") // IP empty = Localhost
|
||||
|| address.startsWith("http://:") // IP empty = Localhost
|
||||
|| address.contains("127.0.0.1");
|
||||
if (!local) {
|
||||
sender.sendMessage("§cNon-local address, check that port is open");
|
||||
}
|
||||
return false;
|
||||
} catch (NotFoundException e) {
|
||||
sender.sendMessage("§e" + server.getName() + " is using older version and can not be scheduled for update. " +
|
||||
"You can update it manually, update will proceed.");
|
||||
return true;
|
||||
} catch (WebException e) {
|
||||
sender.sendMessage("§eOdd Exception: " + e.getClass().getSimpleName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkNetworkStatus(ISender sender) {
|
||||
try {
|
||||
FetchOperations fetch = Database.getActive().fetch();
|
||||
Optional<Server> bungeeInformation = fetch.getBungeeInformation();
|
||||
if (!bungeeInformation.isPresent()) {
|
||||
sender.sendMessage("Bungee address not found in the database, assuming this is not a network.");
|
||||
return true;
|
||||
}
|
||||
Map<UUID, Server> bukkitServers = fetch.getBukkitServers();
|
||||
String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
||||
boolean success = true;
|
||||
for (Server server : bukkitServers.values()) {
|
||||
if (!ManageConDebugCommand.testServer(sender, accessAddress, server, locale)) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
Server bungee = bungeeInformation.get();
|
||||
if (!ManageConDebugCommand.testServer(sender, accessAddress, bungee, locale)) {
|
||||
success = false;
|
||||
}
|
||||
return success;
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§cDatabase error occurred, update has been cancelled.");
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.commands.webuser.WebCheckCommand;
|
||||
import com.djrapitops.plan.command.commands.webuser.WebDeleteCommand;
|
||||
import com.djrapitops.plan.command.commands.webuser.WebLevelCommand;
|
||||
@ -9,9 +8,14 @@ import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
import dagger.Lazy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* Web subcommand used to manage Web users.
|
||||
@ -21,20 +25,25 @@ import com.djrapitops.plugin.command.TreeCmdNode;
|
||||
*/
|
||||
public class WebUserCommand extends TreeCmdNode {
|
||||
|
||||
public WebUserCommand(PlanPlugin plugin, RegisterCommand register, CommandNode parent) {
|
||||
super("webuser|web", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE, parent);
|
||||
super.setColorScheme(plugin.getColorScheme());
|
||||
|
||||
Locale locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
@Inject
|
||||
public WebUserCommand(ColorScheme colorScheme, Locale locale, @Named("mainCommand") Lazy<CommandNode> parent,
|
||||
RegisterCommand registerCommand,
|
||||
WebLevelCommand levelCommand,
|
||||
WebListUsersCommand listUsersCommand,
|
||||
WebCheckCommand checkCommand,
|
||||
WebDeleteCommand deleteCommand
|
||||
) {
|
||||
super("webuser|web", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE, parent.get());
|
||||
super.setColorScheme(colorScheme);
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.WEB));
|
||||
CommandNode[] webGroup = {
|
||||
register,
|
||||
new WebLevelCommand(plugin),
|
||||
new WebListUsersCommand(plugin),
|
||||
new WebCheckCommand(plugin),
|
||||
new WebDeleteCommand(plugin)
|
||||
registerCommand,
|
||||
levelCommand,
|
||||
listUsersCommand,
|
||||
checkCommand,
|
||||
deleteCommand
|
||||
};
|
||||
setNodeGroups(webGroup);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
@ -18,8 +17,11 @@ 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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
@ -33,11 +35,16 @@ import java.util.UUID;
|
||||
public class ManageBackupCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public ManageBackupCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageBackupCommand(Locale locale, DBSystem dbSystem, ErrorHandler errorHandler) {
|
||||
super("backup", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_BACKUP));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_BACKUP));
|
||||
@ -57,7 +64,7 @@ public class ManageBackupCommand extends CommandNode {
|
||||
Verify.isTrue(isCorrectDB,
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, dbName)));
|
||||
|
||||
Database database = DBSystem.getActiveDatabaseByName(dbName);
|
||||
Database database = dbSystem.getActiveDatabaseByName(dbName);
|
||||
|
||||
runBackupTask(sender, args, database);
|
||||
} catch (DBInitException e) {
|
||||
@ -73,7 +80,7 @@ public class ManageBackupCommand extends CommandNode {
|
||||
createNewBackup(args[0], database);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(ManageBackupCommand.class, e);
|
||||
errorHandler.log(L.ERROR, ManageBackupCommand.class, e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
}
|
||||
});
|
||||
@ -98,7 +105,7 @@ public class ManageBackupCommand extends CommandNode {
|
||||
backupDB.init();
|
||||
copyFromDB.backup().backup(backupDB);
|
||||
} catch (DBException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
} finally {
|
||||
if (backupDB != null) {
|
||||
backupDB.close();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
@ -12,12 +11,14 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -29,11 +30,16 @@ import java.util.Arrays;
|
||||
public class ManageClearCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public ManageClearCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageClearCommand(Locale locale, DBSystem dbSystem, ErrorHandler errorHandler) {
|
||||
super("clear", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<DB>", "[-a]");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_CLEAR));
|
||||
@ -57,7 +63,7 @@ public class ManageClearCommand extends CommandNode {
|
||||
}
|
||||
|
||||
try {
|
||||
Database database = DBSystem.getActiveDatabaseByName(dbName);
|
||||
Database database = dbSystem.getActiveDatabaseByName(dbName);
|
||||
runClearTask(sender, database);
|
||||
} catch (DBInitException e) {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
@ -74,7 +80,7 @@ public class ManageClearCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.request.CheckConnectionRequest;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
@ -14,6 +13,7 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
@ -21,6 +21,7 @@ import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -33,17 +34,26 @@ import java.util.UUID;
|
||||
public class ManageConDebugCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final WebServer webServer;
|
||||
private final Database database;
|
||||
private final ColorScheme colorScheme;
|
||||
|
||||
public ManageConDebugCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageConDebugCommand(ColorScheme colorScheme, Locale locale, ConnectionSystem connectionSystem, WebServer webServer, Database database) {
|
||||
super("con", Permissions.MANAGE.getPermission(), CommandType.ALL);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.colorScheme = colorScheme;
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.webServer = webServer;
|
||||
this.database = database;
|
||||
|
||||
setShortHelp(locale.getString(Check.isBungeeAvailable() ? CmdHelpLang.CON : CmdHelpLang.MANAGE_CON));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_CON));
|
||||
}
|
||||
|
||||
public static boolean testServer(ISender sender, String accessAddress, Server server, Locale locale) {
|
||||
private void testServer(ISender sender, String accessAddress, Server server, Locale locale) {
|
||||
String address = server.getWebAddress().toLowerCase();
|
||||
boolean usingHttps = address.startsWith("https");
|
||||
boolean local = address.contains("localhost")
|
||||
@ -52,11 +62,8 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
|| address.contains("127.0.0.1");
|
||||
|
||||
try {
|
||||
|
||||
InfoSystem.getInstance().getConnectionSystem().sendInfoRequest(new CheckConnectionRequest(accessAddress), server);
|
||||
connectionSystem.sendInfoRequest(new CheckConnectionRequest(accessAddress), server);
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, true, true));
|
||||
return true;
|
||||
|
||||
} catch (ForbiddenException | BadRequestException | InternalErrorException e) {
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, false, false));
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_EXCEPTION, e.getClass().getSimpleName()));
|
||||
@ -78,7 +85,6 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
sender.sendMessage(getMsgFor(address, usingHttps, local, false, false));
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_EXCEPTION, e.getClass().getSimpleName()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -92,14 +98,14 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
}
|
||||
|
||||
private void testServers(ISender sender) {
|
||||
List<Server> servers = Database.getActive().fetch().getServers();
|
||||
List<Server> servers = database.fetch().getServers();
|
||||
|
||||
if (servers.isEmpty()) {
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_NO_SERVERS));
|
||||
}
|
||||
|
||||
String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
||||
UUID thisServer = ServerInfo.getServerUUID();
|
||||
String accessAddress = webServer.getAccessAddress();
|
||||
UUID thisServer = ServerInfo.getServerUUID_Old();
|
||||
for (Server server : servers) {
|
||||
if (thisServer.equals(server.getUuid())) {
|
||||
continue;
|
||||
@ -108,10 +114,9 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getMsgFor(String address, boolean usingHttps, boolean local, boolean successTo, boolean successFrom) {
|
||||
ColorScheme cs = PlanPlugin.getInstance().getColorScheme();
|
||||
String tCol = cs.getTertiaryColor();
|
||||
String sCol = cs.getSecondaryColor();
|
||||
private String getMsgFor(String address, boolean usingHttps, boolean local, boolean successTo, boolean successFrom) {
|
||||
String tCol = colorScheme.getTertiaryColor();
|
||||
String sCol = colorScheme.getSecondaryColor();
|
||||
return tCol + address + sCol + ": "
|
||||
+ (usingHttps ? "HTTPS" : "HTTP") + " : "
|
||||
+ (local ? "Local" : "External") + " : "
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.listeners.bukkit.PlayerOnlineListener;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -12,6 +11,7 @@ import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -24,10 +24,11 @@ public class ManageDisableCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
|
||||
public ManageDisableCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageDisableCommand(Locale locale) {
|
||||
super("disable", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
|
||||
setArguments("<feature>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_DISABLE));
|
||||
|
@ -9,12 +9,16 @@ import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -28,12 +32,19 @@ public class ManageHotSwapCommand extends CommandNode {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final PlanConfig config;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public ManageHotSwapCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageHotSwapCommand(PlanPlugin plugin, Locale locale, DBSystem dbSystem, PlanConfig config, ErrorHandler errorHandler) {
|
||||
super("hotswap", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
this.plugin = plugin;
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.plugin = plugin;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.config = config;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<DB>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_HOTSWAP));
|
||||
@ -50,24 +61,28 @@ public class ManageHotSwapCommand extends CommandNode {
|
||||
Verify.isTrue(isCorrectDB,
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, dbName)));
|
||||
|
||||
Verify.isFalse(dbName.equals(Database.getActive().getConfigName()),
|
||||
Verify.isFalse(dbName.equals(dbSystem.getActiveDatabase().getConfigName()),
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_SAME_DB)));
|
||||
|
||||
try {
|
||||
Database database = DBSystem.getActiveDatabaseByName(dbName);
|
||||
Database database = dbSystem.getActiveDatabaseByName(dbName);
|
||||
|
||||
if (!database.isOpen()) {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
Settings.DB_TYPE.set(dbName);
|
||||
|
||||
Settings.save();
|
||||
try {
|
||||
config.set(Settings.DB_TYPE, dbName);
|
||||
config.save();
|
||||
} catch (IOException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
return;
|
||||
}
|
||||
plugin.reloadPlugin(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.importing.ImporterManager;
|
||||
import com.djrapitops.plan.system.processing.importing.importers.Importer;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -28,10 +27,11 @@ public class ManageImportCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
|
||||
public ManageImportCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageImportCommand(Locale locale) {
|
||||
super("import", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
|
||||
setArguments("<plugin>/list", "[import args]");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_IMPORT));
|
||||
@ -60,15 +60,6 @@ public class ManageImportCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
RunnableFactory.createNew("Import:" + importArg, new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
importer.processImport();
|
||||
} finally {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}).runTaskAsynchronously();
|
||||
Processing.submitNonCritical(importer::processImport);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -10,12 +9,14 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -29,11 +30,16 @@ import java.util.Arrays;
|
||||
public class ManageMoveCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public ManageMoveCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageMoveCommand(Locale locale, DBSystem dbSystem, ErrorHandler errorHandler) {
|
||||
super("move", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<fromDB>", "<toDB>", "[-a]");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_MOVE));
|
||||
@ -64,8 +70,8 @@ public class ManageMoveCommand extends CommandNode {
|
||||
}
|
||||
|
||||
try {
|
||||
final Database fromDatabase = DBSystem.getActiveDatabaseByName(fromDB);
|
||||
final Database toDatabase = DBSystem.getActiveDatabaseByName(toDB);
|
||||
final Database fromDatabase = dbSystem.getActiveDatabaseByName(fromDB);
|
||||
final Database toDatabase = dbSystem.getActiveDatabaseByName(toDB);
|
||||
|
||||
runMoveTask(fromDatabase, toDatabase, sender);
|
||||
} catch (Exception e) {
|
||||
@ -82,12 +88,12 @@ public class ManageMoveCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
|
||||
boolean movingToCurrentDB = toDatabase.getConfigName().equalsIgnoreCase(Database.getActive().getConfigName());
|
||||
boolean movingToCurrentDB = toDatabase.getConfigName().equalsIgnoreCase(dbSystem.getActiveDatabase().getConfigName());
|
||||
if (movingToCurrentDB) {
|
||||
sender.sendMessage(locale.getString(ManageLang.HOTSWAP_REMINDER, toDatabase.getConfigName()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -14,6 +13,7 @@ import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -25,11 +25,14 @@ import java.util.Arrays;
|
||||
public class ManageRawDataCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
public ManageRawDataCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageRawDataCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
super("raw", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
|
||||
setArguments("<player>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_RAW_DATA));
|
||||
@ -45,7 +48,7 @@ public class ManageRawDataCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
||||
// Link
|
||||
String url = ConnectionSystem.getInstance().getMainAddress() + "/player/" + playerName + "/raw";
|
||||
String url = connectionSystem.getMainAddress() + "/player/" + playerName + "/raw";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -12,12 +11,14 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -30,11 +31,16 @@ import java.util.UUID;
|
||||
public class ManageRemoveCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public ManageRemoveCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageRemoveCommand(Locale locale, Database database, ErrorHandler errorHandler) {
|
||||
super("remove|delete", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<player>", "[-a]");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_REMOVE));
|
||||
@ -66,7 +72,6 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
Database database = Database.getActive();
|
||||
if (!database.check().isPlayerRegistered(uuid)) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
|
||||
return;
|
||||
@ -83,7 +88,7 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
}
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||
import com.djrapitops.plan.system.file.FileSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -11,12 +11,14 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -28,14 +30,19 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class ManageRestoreCommand extends CommandNode {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
private final FileSystem fileSystem;
|
||||
|
||||
public ManageRestoreCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageRestoreCommand(Locale locale, DBSystem dbSystem, FileSystem fileSystem, ErrorHandler errorHandler) {
|
||||
super("restore", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
|
||||
this.plugin = plugin;
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.fileSystem = fileSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<Filename.db>", "<dbTo>", "[-a]");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_RESTORE));
|
||||
@ -55,7 +62,7 @@ public class ManageRestoreCommand extends CommandNode {
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, dbName)));
|
||||
|
||||
try {
|
||||
Database database = DBSystem.getActiveDatabaseByName(dbName);
|
||||
Database database = dbSystem.getActiveDatabaseByName(dbName);
|
||||
Verify.isFalse(backupDbName.contains("database") && database instanceof SQLiteDB,
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_SAME_DB)));
|
||||
|
||||
@ -70,13 +77,13 @@ public class ManageRestoreCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void runRestoreTask(String backupDbName, ISender sender, final Database database) {
|
||||
private void runRestoreTask(String backupDbName, ISender sender, Database database) {
|
||||
Processing.submitCritical(() -> {
|
||||
try {
|
||||
String backupDBName = backupDbName;
|
||||
boolean containsDBFileExtension = backupDBName.endsWith(".db");
|
||||
|
||||
File backupDBFile = new File(plugin.getDataFolder(), backupDBName + (containsDBFileExtension ? "" : ".db"));
|
||||
File backupDBFile = fileSystem.getFileFromPluginFolder(backupDBName + (containsDBFileExtension ? "" : ".db"));
|
||||
|
||||
if (!backupDBFile.exists()) {
|
||||
sender.sendMessage(locale.getString(ManageLang.FAIL_FILE_NOT_FOUND, backupDBFile.getAbsolutePath()));
|
||||
@ -96,7 +103,7 @@ public class ManageRestoreCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -10,13 +9,16 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -28,11 +30,20 @@ import java.util.Arrays;
|
||||
public class ManageSetupCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final PlanConfig config;
|
||||
private final InfoSystem infoSystem;
|
||||
private final WebServer webServer;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public ManageSetupCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageSetupCommand(Locale locale, PlanConfig config, InfoSystem infoSystem, WebServer webServer, ErrorHandler errorHandler) {
|
||||
super("setup", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.config = config;
|
||||
this.infoSystem = infoSystem;
|
||||
this.webServer = webServer;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<BungeeAddress>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_SETUP));
|
||||
@ -44,7 +55,7 @@ public class ManageSetupCommand extends CommandNode {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
if (!WebServerSystem.isWebServerEnabled()) {
|
||||
if (!webServer.isEnabled()) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_WEBSERVER_NOT_ENABLED));
|
||||
return;
|
||||
}
|
||||
@ -63,10 +74,10 @@ public class ManageSetupCommand extends CommandNode {
|
||||
private void requestSetup(ISender sender, String address) {
|
||||
Processing.submitNonCritical(() -> {
|
||||
try {
|
||||
Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.set(false);
|
||||
Settings.BUNGEE_COPY_CONFIG.set(true);
|
||||
config.set(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE, false);
|
||||
config.set(Settings.BUNGEE_COPY_CONFIG, true);
|
||||
|
||||
InfoSystem.getInstance().requestSetUp(address);
|
||||
infoSystem.requestSetUp(address);
|
||||
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_SUCCESS));
|
||||
} catch (ForbiddenException e) {
|
||||
@ -82,7 +93,7 @@ public class ManageSetupCommand extends CommandNode {
|
||||
} catch (GatewayException e) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_GATEWAY));
|
||||
} catch (WebException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_FAIL, e.toString()));
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
@ -12,11 +11,13 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -30,11 +31,18 @@ import java.util.UUID;
|
||||
public class ManageUninstalledCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
public ManageUninstalledCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public ManageUninstalledCommand(Locale locale, Database database, ConnectionSystem connectionSystem, ErrorHandler errorHandler) {
|
||||
super("uninstalled", Permissions.MANAGE.getPermission(), CommandType.ALL_WITH_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_UNINSTALLED));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_UNINSTALLED));
|
||||
@ -54,23 +62,23 @@ public class ManageUninstalledCommand extends CommandNode {
|
||||
}
|
||||
Server server = serverOptional.get();
|
||||
UUID serverUUID = server.getUuid();
|
||||
if (ServerInfo.getServerUUID().equals(serverUUID)) {
|
||||
if (ServerInfo.getServerUUID_Old().equals(serverUUID)) {
|
||||
sender.sendMessage(locale.getString(ManageLang.UNINSTALLING_SAME_SERVER));
|
||||
return;
|
||||
}
|
||||
|
||||
Database.getActive().save().setAsUninstalled(serverUUID);
|
||||
database.save().setAsUninstalled(serverUUID);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§cError occurred: " + e.toString());
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Optional<Server> getServer(String[] args) {
|
||||
if (args.length >= 1 && ConnectionSystem.getInstance().isServerAvailable()) {
|
||||
Map<UUID, Server> bukkitServers = Database.getActive().fetch().getBukkitServers();
|
||||
if (args.length >= 1 && connectionSystem.isServerAvailable()) {
|
||||
Map<UUID, Server> bukkitServers = database.fetch().getBukkitServers();
|
||||
String serverIdentifier = getGivenIdentifier(args);
|
||||
for (Map.Entry<UUID, Server> entry : bukkitServers.entrySet()) {
|
||||
Server server = entry.getValue();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.webuser;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -9,12 +8,14 @@ import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -26,11 +27,16 @@ import java.util.Arrays;
|
||||
public class WebCheckCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public WebCheckCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public WebCheckCommand(Locale locale, Database database, ErrorHandler errorHandler) {
|
||||
super("check", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_CHECK));
|
||||
setArguments("<username>");
|
||||
@ -41,7 +47,6 @@ public class WebCheckCommand extends CommandNode {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
Database database = Database.getActive();
|
||||
String user = args[0];
|
||||
|
||||
Processing.submitNonCritical(() -> {
|
||||
@ -53,7 +58,7 @@ public class WebCheckCommand extends CommandNode {
|
||||
WebUser info = database.fetch().getWebUser(user);
|
||||
sender.sendMessage(locale.getString(CommandLang.WEB_USER_LIST, info.getName(), info.getPermLevel()));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
}
|
||||
});
|
||||
|
@ -1,20 +1,20 @@
|
||||
package com.djrapitops.plan.command.commands.webuser;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@ -26,11 +26,16 @@ import java.util.Arrays;
|
||||
public class WebDeleteCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public WebDeleteCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public WebDeleteCommand(Locale locale, Database database, ErrorHandler errorHandler) {
|
||||
super("delete|remove", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_DELETE));
|
||||
setArguments("<username>");
|
||||
@ -41,12 +46,9 @@ public class WebDeleteCommand extends CommandNode {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
Database database = Database.getActive();
|
||||
String user = args[0];
|
||||
|
||||
RunnableFactory.createNew("Webuser Delete Task: " + user, new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Processing.submitNonCritical(() -> {
|
||||
try {
|
||||
if (!database.check().doesWebUserExists(user)) {
|
||||
sender.sendMessage("§c[Plan] User Doesn't exist.");
|
||||
@ -55,13 +57,10 @@ public class WebDeleteCommand extends CommandNode {
|
||||
database.remove().webUser(user);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
} finally {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}).runTaskAsynchronously();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.webuser;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -9,6 +8,8 @@ import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Subcommand for info about permission levels.
|
||||
*
|
||||
@ -19,10 +20,11 @@ public class WebLevelCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
|
||||
public WebLevelCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public WebLevelCommand(Locale locale) {
|
||||
super("level", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_LEVEL));
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.command.commands.webuser;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -10,11 +9,13 @@ import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.comparators.WebUserComparator;
|
||||
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.ISender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -26,11 +27,16 @@ import java.util.List;
|
||||
public class WebListUsersCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
public WebListUsersCommand(PlanPlugin plugin) {
|
||||
@Inject
|
||||
public WebListUsersCommand(Locale locale, Database database, ErrorHandler errorHandler) {
|
||||
super("list", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE);
|
||||
|
||||
locale = plugin.getSystem().getLocaleSystem().getLocale();
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_LIST));
|
||||
}
|
||||
@ -39,7 +45,7 @@ public class WebListUsersCommand extends CommandNode {
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
Processing.submitNonCritical(() -> {
|
||||
try {
|
||||
List<WebUser> users = Database.getActive().fetch().getWebUsers();
|
||||
List<WebUser> users = database.fetch().getWebUsers();
|
||||
users.sort(new WebUserComparator());
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_WEB_USERS, users.size()));
|
||||
for (WebUser user : users) {
|
||||
@ -47,7 +53,7 @@ public class WebListUsersCommand extends CommandNode {
|
||||
}
|
||||
sender.sendMessage(">");
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||
}
|
||||
});
|
||||
|
@ -56,7 +56,7 @@ public class Session extends DataContainer implements DateHolder {
|
||||
putSupplier(SessionKeys.LENGTH, () ->
|
||||
getValue(SessionKeys.END).orElse(System.currentTimeMillis()) - getUnsafe(SessionKeys.START));
|
||||
putSupplier(SessionKeys.ACTIVE_TIME, () -> getUnsafe(SessionKeys.LENGTH) - getUnsafe(SessionKeys.AFK_TIME));
|
||||
putSupplier(SessionKeys.SERVER_UUID, ServerInfo::getServerUUID);
|
||||
putSupplier(SessionKeys.SERVER_UUID, ServerInfo::getServerUUID_Old);
|
||||
|
||||
putSupplier(SessionKeys.LONGEST_WORLD_PLAYED, this::getLongestWorldPlayed);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
getUnsafe(serverNames).getOrDefault(serverContainer.getUnsafe(ServerKeys.SERVER_UUID), "Plan")
|
||||
);
|
||||
|
||||
ServerProperties serverProperties = ServerInfo.getServerProperties();
|
||||
ServerProperties serverProperties = ServerInfo.getServerProperties_Old();
|
||||
putRawData(AnalysisKeys.PLAYERS_MAX, serverProperties.getMaxPlayers());
|
||||
putRawData(AnalysisKeys.PLAYERS_ONLINE, serverProperties.getOnlinePlayers());
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class NetworkContainer extends DataContainer {
|
||||
Settings.BUNGEE_NETWORK_NAME.toString() :
|
||||
bungeeContainer.getValue(ServerKeys.NAME).orElse("Plan")
|
||||
);
|
||||
putSupplier(NetworkKeys.PLAYERS_ONLINE, ServerInfo.getServerProperties()::getOnlinePlayers);
|
||||
putSupplier(NetworkKeys.PLAYERS_ONLINE, ServerInfo.getServerProperties_Old()::getOnlinePlayers);
|
||||
putRawData(NetworkKeys.WORLD_MAP_LOW_COLOR, Theme.getValue(ThemeVal.WORLD_MAP_LOW));
|
||||
putRawData(NetworkKeys.WORLD_MAP_HIGH_COLOR, Theme.getValue(ThemeVal.WORLD_MAP_HIGH));
|
||||
putRawData(NetworkKeys.PLAYERS_GRAPH_COLOR, Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
|
||||
|
@ -24,7 +24,7 @@ public class MultiBanCombiner {
|
||||
}
|
||||
|
||||
public void combine(Set<UUID> banned) {
|
||||
combine(Collections.singletonMap(ServerInfo.getServerUUID(), banned));
|
||||
combine(Collections.singletonMap(ServerInfo.getServerUUID_Old(), banned));
|
||||
}
|
||||
|
||||
public void combine(Map<UUID, Set<UUID>> perServerBanned) {
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.djrapitops.plan.modules;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plugin.IPlugin;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.debug.DebugLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -16,6 +18,15 @@ import dagger.Provides;
|
||||
*/
|
||||
@Module
|
||||
public class APFModule {
|
||||
@Provides
|
||||
IPlugin provideIPlugin(PlanPlugin plugin) {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Provides
|
||||
ColorScheme provideColorScheme(PlanPlugin plugin) {
|
||||
return plugin.getColorScheme();
|
||||
}
|
||||
|
||||
@Provides
|
||||
DebugLogger provideDebugLogger(IPlugin plugin) {
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.djrapitops.plan.modules.common;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Dagger module for WebServerSystem.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Module
|
||||
public class WebServerSystemModule {
|
||||
|
||||
@Provides
|
||||
WebServerSystem provideWebServerSystem(Locale locale) {
|
||||
return new WebServerSystem(() -> locale);
|
||||
}
|
||||
|
||||
@Provides
|
||||
WebServer provideWebServer(WebServerSystem webServerSystem) {
|
||||
return webServerSystem.getWebServer();
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.djrapitops.plan.modules.server;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Dagger module for Server Command /plan.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Module
|
||||
public class ServerCommandModule {
|
||||
|
||||
@Provides
|
||||
PlanCommand providePlanCommand(PlanPlugin plugin) {
|
||||
return new PlanCommand(plugin);
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.djrapitops.plan.modules.server.bukkit;
|
||||
package com.djrapitops.plan.modules.server;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.config.ServerConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plugin.config.Config;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@ -13,7 +13,7 @@ import dagger.Provides;
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Module
|
||||
public class BukkitConfigModule {
|
||||
public class ServerConfigModule {
|
||||
|
||||
@Provides
|
||||
ConfigSystem provideConfigSystem() {
|
||||
@ -21,7 +21,7 @@ public class BukkitConfigModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigSystem configSystem) {
|
||||
PlanConfig provideConfig(ConfigSystem configSystem) {
|
||||
return configSystem.getConfig();
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.djrapitops.plan.modules.server;
|
||||
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Dagger module for Server CacheSystem.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Module
|
||||
public class ServerDataCacheModule {
|
||||
|
||||
@Provides
|
||||
SessionCache provideSessionCache(DataCache cache) {
|
||||
return cache;
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package com.djrapitops.plan.modules.server;
|
||||
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.ServerDBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
@ -19,4 +20,9 @@ public class ServerDatabaseModule {
|
||||
return new ServerDBSystem(() -> locale);
|
||||
}
|
||||
|
||||
@Provides
|
||||
Database provideDatabase(DBSystem dbSystem) {
|
||||
return dbSystem.getActiveDatabase();
|
||||
}
|
||||
|
||||
}
|
@ -6,19 +6,18 @@ package com.djrapitops.plan.system;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.ShutdownHook;
|
||||
import com.djrapitops.plan.api.ServerAPI;
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.system.database.ServerDBSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.export.ExportSystem;
|
||||
import com.djrapitops.plan.system.file.FileSystem;
|
||||
import com.djrapitops.plan.system.info.ServerInfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ServerConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.BukkitListenerSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.PlanErrorManager;
|
||||
import com.djrapitops.plan.system.settings.config.ServerConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.network.NetworkSettings;
|
||||
import com.djrapitops.plan.system.tasks.BukkitTaskSystem;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
@ -36,26 +35,35 @@ import java.util.function.Supplier;
|
||||
public class BukkitSystem extends PlanSystem implements ServerSystem {
|
||||
|
||||
@Inject
|
||||
public BukkitSystem(Plan plugin) {
|
||||
public BukkitSystem(Plan plugin,
|
||||
VersionCheckSystem versionCheckSystem,
|
||||
FileSystem fileSystem,
|
||||
ConfigSystem serverConfigSystem,
|
||||
InfoSystem serverInfoSystem,
|
||||
HookHandler hookHandler,
|
||||
PlanAPI planAPI,
|
||||
ExportSystem exportSystem,
|
||||
DBSystem serverDBSystem
|
||||
) {
|
||||
setTestSystem(this);
|
||||
|
||||
Log.setErrorManager(new PlanErrorManager());
|
||||
|
||||
Supplier<Locale> localeSupplier = () -> getLocaleSystem().getLocale();
|
||||
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion(), localeSupplier);
|
||||
fileSystem = new FileSystem(plugin);
|
||||
configSystem = new ServerConfigSystem();
|
||||
exportSystem = new ExportSystem(plugin);
|
||||
databaseSystem = new ServerDBSystem(localeSupplier);
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
this.fileSystem = fileSystem;
|
||||
this.configSystem = serverConfigSystem;
|
||||
this.exportSystem = exportSystem;
|
||||
this.databaseSystem = serverDBSystem;
|
||||
listenerSystem = new BukkitListenerSystem(plugin);
|
||||
taskSystem = new BukkitTaskSystem(plugin);
|
||||
|
||||
infoSystem = new ServerInfoSystem(new ServerConnectionSystem(localeSupplier));
|
||||
infoSystem = serverInfoSystem;
|
||||
serverInfo = new BukkitServerInfo(plugin);
|
||||
|
||||
hookHandler = new HookHandler();
|
||||
planAPI = new ServerAPI(hookHandler, databaseSystem.getActiveDatabase(), cacheSystem.getDataCache());
|
||||
this.hookHandler = hookHandler;
|
||||
this.planAPI = planAPI;
|
||||
|
||||
StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass());
|
||||
new ShutdownHook().register();
|
||||
|
@ -24,6 +24,7 @@ import com.djrapitops.plan.system.tasks.BungeeTaskSystem;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -33,26 +34,32 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public class BungeeSystem extends PlanSystem {
|
||||
|
||||
public BungeeSystem(PlanBungee plugin) {
|
||||
@Inject
|
||||
public BungeeSystem(PlanBungee plugin,
|
||||
VersionCheckSystem versionCheckSystem,
|
||||
FileSystem fileSystem,
|
||||
BungeeCacheSystem bungeeCacheSystem,
|
||||
HookHandler hookHandler
|
||||
) {
|
||||
setTestSystem(this);
|
||||
|
||||
Log.setErrorManager(new PlanErrorManager());
|
||||
|
||||
Supplier<Locale> localeSupplier = () -> getLocaleSystem().getLocale();
|
||||
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion(), localeSupplier);
|
||||
fileSystem = new FileSystem(plugin);
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
this.fileSystem = fileSystem;
|
||||
configSystem = new BungeeConfigSystem();
|
||||
exportSystem = new ExportSystem(plugin);
|
||||
databaseSystem = new BungeeDBSystem(localeSupplier);
|
||||
cacheSystem = new BungeeCacheSystem(this);
|
||||
cacheSystem = bungeeCacheSystem;
|
||||
listenerSystem = new BungeeListenerSystem(plugin);
|
||||
taskSystem = new BungeeTaskSystem(plugin.getRunnableFactory());
|
||||
|
||||
infoSystem = new BungeeInfoSystem();
|
||||
serverInfo = new BungeeServerInfo(plugin);
|
||||
|
||||
hookHandler = new HookHandler();
|
||||
this.hookHandler = hookHandler;
|
||||
planAPI = new BungeeAPI(this);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,6 @@ public abstract class PlanSystem implements SubSystem {
|
||||
processing = new Processing(localeSupplier);
|
||||
webServerSystem = new WebServerSystem(localeSupplier);
|
||||
localeSystem = new LocaleSystem();
|
||||
cacheSystem = new CacheSystem(this);
|
||||
}
|
||||
|
||||
public static PlanSystem getInstance() {
|
||||
|
@ -6,24 +6,23 @@ package com.djrapitops.plan.system;
|
||||
|
||||
import com.djrapitops.plan.PlanSponge;
|
||||
import com.djrapitops.plan.ShutdownHook;
|
||||
import com.djrapitops.plan.api.ServerAPI;
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.system.database.ServerDBSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.export.ExportSystem;
|
||||
import com.djrapitops.plan.system.file.FileSystem;
|
||||
import com.djrapitops.plan.system.info.ServerInfoSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.server.SpongeServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.SpongeListenerSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.PlanErrorManager;
|
||||
import com.djrapitops.plan.system.settings.config.SpongeConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.network.NetworkSettings;
|
||||
import com.djrapitops.plan.system.tasks.SpongeTaskSystem;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -33,26 +32,34 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public class SpongeSystem extends PlanSystem implements ServerSystem {
|
||||
|
||||
public SpongeSystem(PlanSponge plugin) {
|
||||
@Inject
|
||||
public SpongeSystem(PlanSponge plugin,
|
||||
VersionCheckSystem versionCheckSystem,
|
||||
FileSystem fileSystem,
|
||||
ConfigSystem serverConfigSystem,
|
||||
InfoSystem serverInfoSystem,
|
||||
HookHandler hookHandler,
|
||||
PlanAPI planAPI,
|
||||
ExportSystem exportSystem,
|
||||
DBSystem serverDBSystem
|
||||
) {
|
||||
setTestSystem(this);
|
||||
|
||||
Supplier<Locale> localeSupplier = () -> getLocaleSystem().getLocale();
|
||||
|
||||
Log.setErrorManager(new PlanErrorManager());
|
||||
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion(), localeSupplier);
|
||||
fileSystem = new FileSystem(plugin);
|
||||
configSystem = new SpongeConfigSystem();
|
||||
exportSystem = new ExportSystem(plugin);
|
||||
databaseSystem = new ServerDBSystem(localeSupplier);
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
this.fileSystem = fileSystem;
|
||||
this.configSystem = serverConfigSystem;
|
||||
this.exportSystem = exportSystem;
|
||||
this.databaseSystem = serverDBSystem;
|
||||
listenerSystem = new SpongeListenerSystem(plugin);
|
||||
taskSystem = new SpongeTaskSystem(plugin);
|
||||
|
||||
infoSystem = new ServerInfoSystem(localeSupplier);
|
||||
infoSystem = serverInfoSystem;
|
||||
serverInfo = new SpongeServerInfo();
|
||||
|
||||
hookHandler = new HookHandler();
|
||||
planAPI = new ServerAPI(this);
|
||||
this.hookHandler = hookHandler;
|
||||
this.planAPI = planAPI;
|
||||
|
||||
StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass());
|
||||
new ShutdownHook().register();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* CacheSystem for Bungee.
|
||||
@ -11,8 +11,9 @@ import com.djrapitops.plan.system.PlanSystem;
|
||||
*/
|
||||
public class BungeeCacheSystem extends CacheSystem {
|
||||
|
||||
public BungeeCacheSystem(PlanSystem system) {
|
||||
super(new BungeeDataCache(system), system);
|
||||
@Inject
|
||||
public BungeeCacheSystem(BungeeDataCache dataCache, GeolocationCache geolocationCache) {
|
||||
super(dataCache, geolocationCache);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -13,8 +14,9 @@ import java.util.UUID;
|
||||
*/
|
||||
public class BungeeDataCache extends DataCache {
|
||||
|
||||
public BungeeDataCache(PlanSystem system) {
|
||||
super(system);
|
||||
@Inject
|
||||
public BungeeDataCache(Database database) {
|
||||
super(database);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,8 @@ import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* System that holds data caches of the plugin.
|
||||
*
|
||||
@ -19,13 +21,10 @@ public class CacheSystem implements SubSystem {
|
||||
private final DataCache dataCache;
|
||||
private final GeolocationCache geolocationCache;
|
||||
|
||||
public CacheSystem(PlanSystem system) {
|
||||
this(new DataCache(system), system);
|
||||
}
|
||||
|
||||
protected CacheSystem(DataCache dataCache, PlanSystem system) {
|
||||
@Inject
|
||||
public CacheSystem(DataCache dataCache, GeolocationCache geolocationCache) {
|
||||
this.dataCache = dataCache;
|
||||
geolocationCache = new GeolocationCache(() -> system.getLocaleSystem().getLocale());
|
||||
this.geolocationCache = geolocationCache;
|
||||
}
|
||||
|
||||
public static CacheSystem getInstance() {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -24,22 +24,22 @@ import java.util.*;
|
||||
*/
|
||||
public class DataCache extends SessionCache implements SubSystem {
|
||||
|
||||
private Database db;
|
||||
private Database database;
|
||||
private final Map<UUID, String> playerNames;
|
||||
private final Map<String, UUID> uuids;
|
||||
private final Map<UUID, String> displayNames;
|
||||
|
||||
public DataCache(PlanSystem system) {
|
||||
super(system);
|
||||
|
||||
@Inject
|
||||
public DataCache(Database database) {
|
||||
playerNames = new HashMap<>();
|
||||
displayNames = new HashMap<>();
|
||||
uuids = new HashMap<>();
|
||||
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
db = system.getDatabaseSystem().getActiveDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,7 +87,7 @@ public class DataCache extends SessionCache implements SubSystem {
|
||||
String name = playerNames.get(uuid);
|
||||
if (name == null) {
|
||||
try {
|
||||
name = db.fetch().getPlayerName(uuid);
|
||||
name = database.fetch().getPlayerName(uuid);
|
||||
playerNames.put(uuid, name);
|
||||
} catch (DBOpException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
@ -110,7 +110,7 @@ public class DataCache extends SessionCache implements SubSystem {
|
||||
if (cached == null) {
|
||||
List<String> nicknames;
|
||||
try {
|
||||
nicknames = db.fetch().getNicknames(uuid);
|
||||
nicknames = database.fetch().getNicknames(uuid);
|
||||
if (!nicknames.isEmpty()) {
|
||||
return nicknames.get(nicknames.size() - 1);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
import com.maxmind.geoip2.model.CountryResponse;
|
||||
import com.maxmind.geoip2.record.Country;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -23,7 +24,6 @@ import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
@ -36,28 +36,29 @@ import java.util.zip.GZIPInputStream;
|
||||
*/
|
||||
public class GeolocationCache implements SubSystem {
|
||||
|
||||
private final Supplier<Locale> locale;
|
||||
private final Locale locale;
|
||||
private final Map<String, String> cached;
|
||||
private File geolocationDB;
|
||||
|
||||
public GeolocationCache(Supplier<Locale> locale) {
|
||||
@Inject
|
||||
public GeolocationCache(Locale locale) {
|
||||
this.locale = locale;
|
||||
cached = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
geolocationDB = new File(FileSystem.getDataFolder(), "GeoIP.dat");
|
||||
geolocationDB = new File(FileSystem.getDataFolder_Old(), "GeoIP.dat");
|
||||
if (Settings.DATA_GEOLOCATIONS.isTrue()) {
|
||||
try {
|
||||
GeolocationCache.checkDB();
|
||||
} catch (UnknownHostException e) {
|
||||
Log.error(locale.get().getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_INTERNET_REQUIRED));
|
||||
Log.error(locale.getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_INTERNET_REQUIRED));
|
||||
} catch (IOException e) {
|
||||
throw new EnableException(locale.get().getString(PluginLang.ENABLE_FAIL_GEODB_WRITE), e);
|
||||
throw new EnableException(locale.getString(PluginLang.ENABLE_FAIL_GEODB_WRITE), e);
|
||||
}
|
||||
} else {
|
||||
Log.infoColor("§e" + locale.get().getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_DISABLED));
|
||||
Log.infoColor("§e" + locale.getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package com.djrapitops.plan.system.cache;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -22,11 +21,6 @@ import java.util.UUID;
|
||||
public class SessionCache {
|
||||
|
||||
private static final Map<UUID, Session> activeSessions = new HashMap<>();
|
||||
protected final PlanSystem system;
|
||||
|
||||
public SessionCache(PlanSystem system) {
|
||||
this.system = system;
|
||||
}
|
||||
|
||||
public static SessionCache getInstance() {
|
||||
SessionCache dataCache = CacheSystem.getInstance().getDataCache();
|
||||
|
@ -37,22 +37,27 @@ public abstract class DBSystem implements SubSystem {
|
||||
databases = new HashSet<>();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static DBSystem getInstance() {
|
||||
DBSystem dbSystem = PlanSystem.getInstance().getDatabaseSystem();
|
||||
Verify.nullCheck(dbSystem, () -> new IllegalStateException("Database system was not initialized."));
|
||||
return dbSystem;
|
||||
}
|
||||
|
||||
public static Database getActiveDatabaseByName(String dbName) throws DBInitException {
|
||||
DBSystem system = getInstance();
|
||||
for (Database database : system.getDatabases()) {
|
||||
@Deprecated
|
||||
public static Database getActiveDatabaseByName_Old(String dbName) throws DBInitException {
|
||||
return getInstance().getActiveDatabaseByName(dbName);
|
||||
}
|
||||
|
||||
public Database getActiveDatabaseByName(String dbName) throws DBInitException {
|
||||
for (Database database : getDatabases()) {
|
||||
String dbConfigName = database.getConfigName();
|
||||
if (Verify.equalsIgnoreCase(dbName, dbConfigName)) {
|
||||
database.init();
|
||||
return database;
|
||||
}
|
||||
}
|
||||
throw new DBInitException(system.locale.get().getString(PluginLang.ENABLE_FAIL_WRONG_DB, dbName));
|
||||
throw new DBInitException(locale.get().getString(PluginLang.ENABLE_FAIL_WRONG_DB, dbName));
|
||||
}
|
||||
|
||||
protected abstract void initDatabase() throws DBInitException;
|
||||
|
@ -31,6 +31,6 @@ public class ServerDBSystem extends DBSystem {
|
||||
databases.add(new SQLiteDB(locale));
|
||||
|
||||
String dbType = Settings.DB_TYPE.toString().toLowerCase().trim();
|
||||
db = getActiveDatabaseByName(dbType);
|
||||
db = getActiveDatabaseByName_Old(dbType);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public abstract class Database {
|
||||
|
||||
protected boolean open = false;
|
||||
|
||||
@Deprecated
|
||||
public static Database getActive() {
|
||||
Database database = DBSystem.getInstance().getActiveDatabase();
|
||||
Verify.nullCheck(database, () -> new IllegalStateException("Database was not initialized."));
|
||||
|
@ -13,7 +13,7 @@ public interface CheckOperations {
|
||||
boolean doesWebUserExists(String username);
|
||||
|
||||
default boolean isPlayerRegisteredOnThisServer(UUID player) {
|
||||
return isPlayerRegistered(player, ServerInfo.getServerUUID());
|
||||
return isPlayerRegistered(player, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
boolean isServerInDatabase(UUID serverUUID);
|
||||
|
@ -29,7 +29,7 @@ public class SQLCheckOps extends SQLOps implements CheckOperations {
|
||||
|
||||
@Override
|
||||
public boolean isPlayerRegisteredOnThisServer(UUID player) {
|
||||
return isPlayerRegistered(player, ServerInfo.getServerUUID());
|
||||
return isPlayerRegistered(player, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ public class Version10Patch extends Patch {
|
||||
@Override
|
||||
public void apply() {
|
||||
try {
|
||||
Optional<Integer> fetchedServerID = db.getServerTable().getServerID(ServerInfo.getServerUUID());
|
||||
Optional<Integer> fetchedServerID = db.getServerTable().getServerID(ServerInfo.getServerUUID_Old());
|
||||
if (!fetchedServerID.isPresent()) {
|
||||
throw new IllegalStateException("Server UUID was not registered, try rebooting the plugin.");
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class CommandUseTable extends Table {
|
||||
* @return command - times used Map
|
||||
*/
|
||||
public Map<String, Integer> getCommandUse() {
|
||||
return getCommandUse(ServerInfo.getServerUUID());
|
||||
return getCommandUse(ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
public void commandUsed(String command) {
|
||||
@ -110,7 +110,7 @@ public class CommandUseTable extends Table {
|
||||
boolean updated = execute(new ExecStatement(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(1, ServerInfo.getServerUUID_Old().toString());
|
||||
statement.setString(2, command);
|
||||
}
|
||||
});
|
||||
@ -144,7 +144,7 @@ public class CommandUseTable extends Table {
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, command);
|
||||
statement.setInt(2, 1);
|
||||
statement.setString(3, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(3, ServerInfo.getServerUUID_Old().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class KillsTable extends UserIDTable {
|
||||
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, victim.toString());
|
||||
statement.setString(3, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(3, ServerInfo.getServerUUID_Old().toString());
|
||||
statement.setInt(4, sessionID);
|
||||
statement.setLong(5, date);
|
||||
statement.setString(6, weapon);
|
||||
|
@ -111,7 +111,7 @@ public class NicknamesTable extends UserIDTable {
|
||||
* @return The nicknames of the User
|
||||
*/
|
||||
public List<String> getNicknames(UUID uuid) {
|
||||
return getNicknames(uuid, ServerInfo.getServerUUID());
|
||||
return getNicknames(uuid, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
public Map<UUID, Map<UUID, List<Nickname>>> getAllNicknames() {
|
||||
@ -167,7 +167,7 @@ public class NicknamesTable extends UserIDTable {
|
||||
statement.setLong(1, name.getDate());
|
||||
statement.setString(2, name.getName());
|
||||
statement.setString(3, uuid.toString());
|
||||
statement.setString(4, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(4, ServerInfo.getServerUUID_Old().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class NicknamesTable extends UserIDTable {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(2, ServerInfo.getServerUUID_Old().toString());
|
||||
statement.setString(3, name.getName());
|
||||
statement.setLong(4, name.getDate());
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class PingTable extends UserIDTable {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(2, ServerInfo.getServerUUID_Old().toString());
|
||||
statement.setLong(3, ping.getDate());
|
||||
statement.setInt(4, ping.getMin());
|
||||
statement.setInt(5, ping.getMax());
|
||||
|
@ -134,7 +134,7 @@ public class SessionsTable extends UserIDTable {
|
||||
statement.setInt(4, session.getUnsafe(SessionKeys.DEATH_COUNT));
|
||||
statement.setInt(5, session.getUnsafe(SessionKeys.MOB_KILL_COUNT));
|
||||
statement.setLong(6, session.getUnsafe(SessionKeys.AFK_TIME));
|
||||
statement.setString(7, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(7, ServerInfo.getServerUUID_Old().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -239,7 +239,7 @@ public class SessionsTable extends UserIDTable {
|
||||
* @return Milliseconds played on THIS server. 0 if player or server not found.
|
||||
*/
|
||||
public long getPlaytime(UUID uuid) {
|
||||
return getPlaytime(uuid, ServerInfo.getServerUUID());
|
||||
return getPlaytime(uuid, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,7 +250,7 @@ public class SessionsTable extends UserIDTable {
|
||||
* @return Milliseconds played on THIS server. 0 if player or server not found.
|
||||
*/
|
||||
public long getPlaytime(UUID uuid, long afterDate) {
|
||||
return getPlaytime(uuid, ServerInfo.getServerUUID(), afterDate);
|
||||
return getPlaytime(uuid, ServerInfo.getServerUUID_Old(), afterDate);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -357,7 +357,7 @@ public class SessionsTable extends UserIDTable {
|
||||
* @return How many sessions player has. 0 if player or server not found.
|
||||
*/
|
||||
public int getSessionCount(UUID uuid, long afterDate) {
|
||||
return getSessionCount(uuid, ServerInfo.getServerUUID(), afterDate);
|
||||
return getSessionCount(uuid, ServerInfo.getServerUUID_Old(), afterDate);
|
||||
}
|
||||
|
||||
public Map<UUID, List<Session>> getSessionInfoOfServer(UUID serverUUID) {
|
||||
@ -404,7 +404,7 @@ public class SessionsTable extends UserIDTable {
|
||||
}
|
||||
|
||||
public Map<UUID, List<Session>> getSessionInfoOfServer() {
|
||||
return getSessionInfoOfServer(ServerInfo.getServerUUID());
|
||||
return getSessionInfoOfServer(ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
public Map<UUID, Long> getLastSeenForAllPlayers() {
|
||||
|
@ -105,7 +105,7 @@ public class TPSTable extends Table {
|
||||
* @return @throws SQLException
|
||||
*/
|
||||
public List<TPS> getTPSData() {
|
||||
return getTPSData(ServerInfo.getServerUUID());
|
||||
return getTPSData(ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,7 @@ public class TPSTable extends Table {
|
||||
execute(new ExecStatement(insertStatement) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(1, ServerInfo.getServerUUID_Old().toString());
|
||||
statement.setLong(2, tps.getDate());
|
||||
statement.setDouble(3, tps.getTicksPerSecond());
|
||||
statement.setInt(4, tps.getPlayers());
|
||||
@ -194,7 +194,7 @@ public class TPSTable extends Table {
|
||||
}
|
||||
|
||||
public Optional<TPS> getPeakPlayerCount(long afterDate) {
|
||||
return getPeakPlayerCount(ServerInfo.getServerUUID(), afterDate);
|
||||
return getPeakPlayerCount(ServerInfo.getServerUUID_Old(), afterDate);
|
||||
}
|
||||
|
||||
public Map<UUID, List<TPS>> getAllTPS() {
|
||||
|
@ -90,7 +90,7 @@ public class TransferTable extends Table {
|
||||
execute(new ExecStatement(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(1, ServerInfo.getServerUUID_Old().toString());
|
||||
statement.setString(2, "onlineStatus");
|
||||
}
|
||||
});
|
||||
@ -100,7 +100,7 @@ public class TransferTable extends Table {
|
||||
execute(new ExecStatement(insertStatementNoParts) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(1, ServerInfo.getServerUUID_Old().toString());
|
||||
statement.setLong(2, System.currentTimeMillis() + TimeAmount.HOUR.ms());
|
||||
statement.setString(3, "configSettings");
|
||||
statement.setString(4, null);
|
||||
|
@ -69,7 +69,7 @@ public class UserInfoTable extends UserIDTable {
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setLong(2, registered);
|
||||
statement.setString(3, ServerInfo.getServerUUID().toString());
|
||||
statement.setString(3, ServerInfo.getServerUUID_Old().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -95,7 +95,7 @@ public class UserInfoTable extends UserIDTable {
|
||||
}
|
||||
|
||||
public boolean isRegistered(UUID uuid) {
|
||||
return isRegistered(uuid, ServerInfo.getServerUUID());
|
||||
return isRegistered(uuid, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
public void updateOpStatus(UUID uuid, boolean op) {
|
||||
@ -166,7 +166,7 @@ public class UserInfoTable extends UserIDTable {
|
||||
}
|
||||
|
||||
public UserInfo getUserInfo(UUID uuid) {
|
||||
return getAllUserInfo(uuid).get(ServerInfo.getServerUUID());
|
||||
return getAllUserInfo(uuid).get(ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
public List<UserInfo> getServerUserInfo(UUID serverUUID) {
|
||||
@ -213,7 +213,7 @@ public class UserInfoTable extends UserIDTable {
|
||||
* @return List of UserInfo objects.
|
||||
*/
|
||||
public List<UserInfo> getServerUserInfo() {
|
||||
return getServerUserInfo(ServerInfo.getServerUUID());
|
||||
return getServerUserInfo(ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
public Map<UUID, List<UserInfo>> getAllUserInfo() {
|
||||
|
@ -73,7 +73,7 @@ public class WorldTable extends Table {
|
||||
}
|
||||
|
||||
public List<String> getWorlds() {
|
||||
return getWorlds(ServerInfo.getServerUUID());
|
||||
return getWorlds(ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
public List<String> getWorlds(UUID serverUUID) {
|
||||
@ -100,7 +100,7 @@ public class WorldTable extends Table {
|
||||
}
|
||||
|
||||
public void saveWorlds(Collection<String> worlds) {
|
||||
saveWorlds(worlds, ServerInfo.getServerUUID());
|
||||
saveWorlds(worlds, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,7 +143,7 @@ public class WorldTimesTable extends UserIDTable {
|
||||
GMTimes gmTimes = entry.getValue();
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, worldName);
|
||||
String serverUUID = ServerInfo.getServerUUID().toString();
|
||||
String serverUUID = ServerInfo.getServerUUID_Old().toString();
|
||||
statement.setString(3, serverUUID);
|
||||
statement.setString(4, serverUUID);
|
||||
statement.setInt(5, sessionID);
|
||||
|
@ -15,6 +15,8 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@ -29,38 +31,55 @@ public class FileSystem implements SubSystem {
|
||||
private final File dataFolder;
|
||||
private File configFile;
|
||||
|
||||
@Deprecated
|
||||
public FileSystem(PlanPlugin plugin) {
|
||||
this(plugin.getDataFolder());
|
||||
}
|
||||
|
||||
public FileSystem(File dataFolder) {
|
||||
@Inject
|
||||
public FileSystem(@Named("dataFolder") File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
configFile = new File(dataFolder, "config.yml");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FileSystem getInstance() {
|
||||
FileSystem fileSystem = PlanSystem.getInstance().getFileSystem();
|
||||
Verify.nullCheck(fileSystem, () -> new IllegalStateException("File system was not initialized."));
|
||||
return fileSystem;
|
||||
}
|
||||
|
||||
public static File getDataFolder() {
|
||||
@Deprecated
|
||||
public static File getDataFolder_Old() {
|
||||
return getInstance().dataFolder;
|
||||
}
|
||||
|
||||
public static File getConfigFile() {
|
||||
@Deprecated
|
||||
public static File getConfigFile_Old() {
|
||||
return getInstance().configFile;
|
||||
}
|
||||
|
||||
public static File getLocaleFile() {
|
||||
return new File(getInstance().dataFolder, "locale.txt");
|
||||
@Deprecated
|
||||
public static File getLocaleFile_Old() {
|
||||
return getInstance().getLocaleFile();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static List<String> readFromResource(String fileName) throws IOException {
|
||||
return FileUtil.lines(PlanPlugin.getInstance(), fileName);
|
||||
}
|
||||
|
||||
public File getDataFolder() {
|
||||
return dataFolder;
|
||||
}
|
||||
|
||||
public File getConfigFile() {
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public File getLocaleFile() {
|
||||
return getFileFromPluginFolder("locale.txt");
|
||||
}
|
||||
|
||||
public File getFileFromPluginFolder(String name) {
|
||||
return new File(dataFolder, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
Verify.isTrue((dataFolder.exists() && dataFolder.isDirectory()) || dataFolder.mkdirs(),
|
||||
|
@ -41,7 +41,7 @@ public class BungeeInfoSystem extends InfoSystem {
|
||||
|
||||
@Override
|
||||
public void updateNetworkPage() {
|
||||
ResponseCache.cacheResponse(PageId.SERVER.of(ServerInfo.getServerUUID()), () -> {
|
||||
ResponseCache.cacheResponse(PageId.SERVER.of(ServerInfo.getServerUUID_Old()), () -> {
|
||||
try {
|
||||
return new NetworkPageResponse();
|
||||
} catch (ParseException e) {
|
||||
|
@ -75,7 +75,7 @@ public abstract class InfoSystem implements SubSystem {
|
||||
*/
|
||||
public void generateAnalysisPage(UUID serverUUID) throws WebException {
|
||||
GenerateAnalysisPageRequest request = new GenerateAnalysisPageRequest(serverUUID);
|
||||
if (ServerInfo.getServerUUID().equals(serverUUID)) {
|
||||
if (ServerInfo.getServerUUID_Old().equals(serverUUID)) {
|
||||
runLocally(request);
|
||||
} else {
|
||||
sendRequest(request);
|
||||
|
@ -37,6 +37,6 @@ public class ServerInfoSystem extends InfoSystem {
|
||||
@Override
|
||||
public void updateNetworkPage() throws WebException {
|
||||
String html = HtmlStructure.createServerContainer();
|
||||
sendRequest(new CacheNetworkPageContentRequest(ServerInfo.getServerUUID(), html));
|
||||
sendRequest(new CacheNetworkPageContentRequest(ServerInfo.getServerUUID_Old(), html));
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class BungeeConnectionSystem extends ConnectionSystem {
|
||||
Server server = null;
|
||||
if (infoRequest instanceof CacheRequest || infoRequest instanceof GenerateInspectPageRequest) {
|
||||
// Run locally
|
||||
return ServerInfo.getServer();
|
||||
return ServerInfo.getServer_Old();
|
||||
} else if (infoRequest instanceof GenerateAnalysisPageRequest) {
|
||||
UUID serverUUID = ((GenerateAnalysisPageRequest) infoRequest).getServerUUID();
|
||||
server = bukkitServers.get(serverUUID);
|
||||
|
@ -47,7 +47,7 @@ public class ConnectionIn {
|
||||
Log.debug("ConnectionIn: " + infoRequest.getClass().getSimpleName());
|
||||
|
||||
if (infoRequest instanceof SetupRequest) {
|
||||
if (!ConnectionSystem.isSetupAllowed()) {
|
||||
if (!ConnectionSystem.isSetupAllowed_Old()) {
|
||||
throw new ForbiddenException("Setup not enabled on this server, use commands to enable.");
|
||||
}
|
||||
} else {
|
||||
|
@ -36,16 +36,23 @@ public abstract class ConnectionSystem implements SubSystem {
|
||||
connectionLog = new ConnectionLog();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ConnectionSystem getInstance() {
|
||||
ConnectionSystem connectionSystem = InfoSystem.getInstance().getConnectionSystem();
|
||||
Verify.nullCheck(connectionSystem, () -> new IllegalStateException("Connection System was not initialized"));
|
||||
return connectionSystem;
|
||||
}
|
||||
|
||||
public static boolean isSetupAllowed() {
|
||||
@Deprecated
|
||||
public static boolean isSetupAllowed_Old() {
|
||||
return getInstance().setupAllowed;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getAddress() {
|
||||
return getInstance().getMainAddress();
|
||||
}
|
||||
|
||||
public InfoRequest getInfoRequest(String name) {
|
||||
return dataRequests.get(name.toLowerCase());
|
||||
}
|
||||
@ -60,8 +67,8 @@ public abstract class ConnectionSystem implements SubSystem {
|
||||
|
||||
protected abstract Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException;
|
||||
|
||||
public static String getAddress() {
|
||||
return getInstance().getMainAddress();
|
||||
public boolean isSetupAllowed() {
|
||||
return setupAllowed;
|
||||
}
|
||||
|
||||
public void sendInfoRequest(InfoRequest infoRequest) throws WebException {
|
||||
@ -70,10 +77,10 @@ public abstract class ConnectionSystem implements SubSystem {
|
||||
}
|
||||
|
||||
public void sendInfoRequest(InfoRequest infoRequest, Server toServer) throws WebException {
|
||||
if (ServerInfo.getServerUUID().equals(toServer.getUuid())) {
|
||||
if (ServerInfo.getServerUUID_Old().equals(toServer.getUuid())) {
|
||||
InfoSystem.getInstance().runLocally(infoRequest);
|
||||
} else {
|
||||
new ConnectionOut(toServer, ServerInfo.getServerUUID(), infoRequest).sendRequest();
|
||||
new ConnectionOut(toServer, ServerInfo.getServerUUID_Old(), infoRequest).sendRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,8 +110,6 @@ public abstract class ConnectionSystem implements SubSystem {
|
||||
putRequest(requests, SendDBSettingsRequest.createHandler());
|
||||
putRequest(requests, CheckConnectionRequest.createHandler());
|
||||
|
||||
// putRequest(requests, UpdateRequest.createHandler());
|
||||
// putRequest(requests, UpdateCancelRequest.createHandler());
|
||||
return requests;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
||||
|
||||
@Override
|
||||
public String getMainAddress() {
|
||||
return isServerAvailable() ? mainServer.getWebAddress() : ServerInfo.getServer().getWebAddress();
|
||||
return isServerAvailable() ? mainServer.getWebAddress() : ServerInfo.getServer_Old().getWebAddress();
|
||||
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
||||
boolean usingBungeeWebServer = ConnectionSystem.getInstance().isServerAvailable();
|
||||
boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||
|
||||
if (!usingAlternativeIP && ServerInfo.getServerProperties().getIp().isEmpty()) {
|
||||
if (!usingAlternativeIP && ServerInfo.getServerProperties_Old().getIp().isEmpty()) {
|
||||
Log.infoColor("§e" + locale.get().getString(PluginLang.ENABLE_NOTIFY_EMPTY_IP));
|
||||
}
|
||||
if (usingBungeeWebServer && usingAlternativeIP) {
|
||||
|
@ -61,7 +61,7 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
|
||||
String html = variables.get("html");
|
||||
Verify.nullCheck(html, () -> new BadRequestException("HTML 'html' variable not supplied in the request"));
|
||||
|
||||
Map<String, String> replace = Collections.singletonMap("networkName", ServerInfo.getServerName());
|
||||
Map<String, String> replace = Collections.singletonMap("networkName", ServerInfo.getServerName_Old());
|
||||
boolean export = Settings.ANALYSIS_EXPORT.isTrue();
|
||||
cache(export, uuid, StringSubstitutor.replace(Base64Util.decode(html), replace));
|
||||
|
||||
|
@ -72,6 +72,6 @@ public class CacheInspectPluginsTabRequest extends InfoRequestWithVariables impl
|
||||
|
||||
@Override
|
||||
public void runLocally() {
|
||||
getPluginsTab(player).addTab(ServerInfo.getServerUUID(), variables.get("nav"), html);
|
||||
getPluginsTab(player).addTab(ServerInfo.getServerUUID_Old(), variables.get("nav"), html);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class CacheNetworkPageContentRequest extends InfoRequestWithVariables imp
|
||||
|
||||
public CacheNetworkPageContentRequest(UUID serverUUID, String html) {
|
||||
Verify.nullCheck(serverUUID, html);
|
||||
variables.put("serverName", ServerInfo.getServerName());
|
||||
variables.put("serverName", ServerInfo.getServerName_Old());
|
||||
variables.put("html", Base64Util.encode(html));
|
||||
this.html = html;
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class CacheNetworkPageContentRequest extends InfoRequestWithVariables imp
|
||||
NetworkPageContent serversTab = getNetworkPageContent();
|
||||
serversTab.addElement(serverName, Base64Util.decode(html));
|
||||
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID()));
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID_Old()));
|
||||
|
||||
return DefaultResponses.SUCCESS.get();
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class CacheNetworkPageContentRequest extends InfoRequestWithVariables imp
|
||||
|
||||
@Override
|
||||
public void runLocally() {
|
||||
getNetworkPageContent().addElement(ServerInfo.getServerName(), html);
|
||||
getNetworkPageContent().addElement(ServerInfo.getServerName_Old(), html);
|
||||
}
|
||||
|
||||
public static CacheNetworkPageContentRequest createHandler() {
|
||||
|
@ -50,7 +50,7 @@ public class GenerateAnalysisPageRequest extends InfoRequestWithVariables implem
|
||||
Verify.nullCheck(server, () -> new BadRequestException("Server UUID 'server' variable not supplied in the request."));
|
||||
|
||||
UUID serverUUID = UUID.fromString(server);
|
||||
if (!ServerInfo.getServerUUID().equals(serverUUID)) {
|
||||
if (!ServerInfo.getServerUUID_Old().equals(serverUUID)) {
|
||||
throw new BadRequestException("Requested Analysis page from wrong server.");
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public class GenerateAnalysisPageRequest extends InfoRequestWithVariables implem
|
||||
private String analyseAndGetHtml() throws InternalErrorException {
|
||||
try {
|
||||
runningAnalysis = true;
|
||||
UUID serverUUID = ServerInfo.getServerUUID();
|
||||
UUID serverUUID = ServerInfo.getServerUUID_Old();
|
||||
AnalysisContainer analysisContainer = new AnalysisContainer(Database.getActive().fetch().getServerContainer(serverUUID));
|
||||
return new AnalysisPage(analysisContainer).toHtml();
|
||||
} catch (DBOpException e) {
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* License is provided in the jar as LICENSE also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
||||
*/
|
||||
package com.djrapitops.plan.system.info.request;
|
||||
|
||||
import com.djrapitops.plan.system.update.ShutdownUpdateHook;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* InfoRequest used for Updating the plugin on a network.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class UpdateCancelRequest implements InfoRequest {
|
||||
|
||||
public UpdateCancelRequest() {
|
||||
}
|
||||
|
||||
public static UpdateCancelRequest createHandler() {
|
||||
return new UpdateCancelRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runLocally() {
|
||||
ShutdownUpdateHook.deActivate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response handleRequest(Map<String, String> variables) {
|
||||
ShutdownUpdateHook.deActivate();
|
||||
return DefaultResponses.SUCCESS.get();
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* License is provided in the jar as LICENSE also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
||||
*/
|
||||
package com.djrapitops.plan.system.info.request;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.update.ShutdownUpdateHook;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.BadRequestResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* InfoRequest used for Updating the plugin on a network.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class UpdateRequest implements InfoRequest {
|
||||
|
||||
public UpdateRequest() {
|
||||
}
|
||||
|
||||
public static UpdateRequest createHandler() {
|
||||
return new UpdateRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runLocally() {
|
||||
new ShutdownUpdateHook().register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response handleRequest(Map<String, String> variables) {
|
||||
if (Settings.ALLOW_UPDATE.isTrue()) {
|
||||
new ShutdownUpdateHook().register();
|
||||
return DefaultResponses.SUCCESS.get();
|
||||
} else {
|
||||
return new BadRequestResponse("Update not allowed on this server");
|
||||
}
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ public class BukkitServerInfo extends ServerInfo {
|
||||
database = Database.getActive();
|
||||
|
||||
try {
|
||||
serverInfoFile = new ServerInfoFile(FileSystem.getDataFolder());
|
||||
serverInfoFile = new ServerInfoFile(FileSystem.getDataFolder_Old());
|
||||
} catch (IOException e) {
|
||||
throw new EnableException("Failed to read ServerInfoFile.yml", e);
|
||||
}
|
||||
@ -87,7 +87,7 @@ public class BukkitServerInfo extends ServerInfo {
|
||||
private Server registerServer(UUID serverUUID) throws IOException {
|
||||
String webAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
||||
String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||
int maxPlayers = ServerInfo.getServerProperties().getMaxPlayers();
|
||||
int maxPlayers = ServerInfo.getServerProperties_Old().getMaxPlayers();
|
||||
|
||||
Server server = new Server(-1, serverUUID, name, webAddress, maxPlayers);
|
||||
database.save().serverInfoForThisServer(server);
|
||||
|
@ -55,7 +55,7 @@ public class BungeeServerInfo extends ServerInfo {
|
||||
}
|
||||
|
||||
private void checkIfDefaultIP() throws EnableException {
|
||||
String ip = ServerInfo.getServerProperties().getIp();
|
||||
String ip = ServerInfo.getServerProperties_Old().getIp();
|
||||
if ("0.0.0.0".equals(ip)) {
|
||||
Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
|
||||
Log.info("Player Analytics partially enabled (Use /planbungee to reload config)");
|
||||
@ -64,7 +64,7 @@ public class BungeeServerInfo extends ServerInfo {
|
||||
}
|
||||
|
||||
private Server registerBungeeInfo(Database db) throws EnableException {
|
||||
ServerProperties properties = ServerInfo.getServerProperties();
|
||||
ServerProperties properties = ServerInfo.getServerProperties_Old();
|
||||
UUID serverUUID = generateNewUUID(properties);
|
||||
String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
||||
|
||||
|
@ -28,30 +28,48 @@ public abstract class ServerInfo implements SubSystem {
|
||||
this.serverProperties = serverProperties;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ServerInfo getInstance() {
|
||||
ServerInfo serverInfo = PlanSystem.getInstance().getServerInfo();
|
||||
Verify.nullCheck(serverInfo, () -> new IllegalStateException("ServerInfo was not initialized."));
|
||||
return serverInfo;
|
||||
}
|
||||
|
||||
public static Server getServer() {
|
||||
@Deprecated
|
||||
public static Server getServer_Old() {
|
||||
return getInstance().server;
|
||||
}
|
||||
|
||||
public static ServerProperties getServerProperties() {
|
||||
@Deprecated
|
||||
public static ServerProperties getServerProperties_Old() {
|
||||
return getInstance().serverProperties;
|
||||
}
|
||||
|
||||
public static UUID getServerUUID() {
|
||||
@Deprecated
|
||||
public static UUID getServerUUID_Old() {
|
||||
return getServer_Old().getUuid();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getServerName_Old() {
|
||||
return getServer_Old().getName();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int getServerID_Old() {
|
||||
return getServer_Old().getId();
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public UUID getServerUUID() {
|
||||
return getServer().getUuid();
|
||||
}
|
||||
|
||||
public static String getServerName() {
|
||||
return getServer().getName();
|
||||
}
|
||||
|
||||
public static int getServerID() {
|
||||
return getServer().getId();
|
||||
public ServerProperties getServerProperties() {
|
||||
return serverProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,7 +46,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
new IPUpdateProcessor(uuid, address, now))
|
||||
);
|
||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID()));
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID_Old()));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
@ -60,7 +60,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
|
||||
SessionCache.getInstance().endSession(uuid, System.currentTimeMillis());
|
||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID()));
|
||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID_Old()));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class LocaleSystem implements SubSystem {
|
||||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
File localeFile = FileSystem.getLocaleFile();
|
||||
File localeFile = FileSystem.getLocaleFile_Old();
|
||||
|
||||
if (Settings.WRITE_NEW_LOCALE.isTrue()) {
|
||||
writeNewDefaultLocale(localeFile);
|
||||
|
@ -23,7 +23,6 @@ public enum CmdHelpLang implements Lang {
|
||||
SETUP("Command Help - /planbungee setup", "Toggle set-up mode"),
|
||||
CON("Command Help - /planbungee con", "Debug Bungee-Server connections"),
|
||||
DISABLE("Command Help - /planbungee disable", "Disable the plugin temporarily"),
|
||||
UPDATE("Command Help - /plan update", "Get change log link or update plugin"),
|
||||
|
||||
MANAGE_MOVE("Command Help - /plan manage move", "Move data between Databases"),
|
||||
MANAGE_BACKUP("Command Help - /plan manage backup", "Backup a Database"),
|
||||
|
@ -67,17 +67,6 @@ public enum CommandLang implements Lang {
|
||||
|
||||
DISABLE_DISABLED("Cmd Disable - Disabled", "§aPlan systems are now disabled. You can still use /planbungee reload to restart the plugin."),
|
||||
|
||||
UPDATE_WRONG_URL("Cmd Update - Url mismatch", "§cVersion download url did not start with ${0} and might not be trusted. You can download this version manually here (Direct download):"),
|
||||
UPDATE_CHANGE_LOG("Cmd Update - Change log", "Change Log v${0}:"),
|
||||
UPDATE_CANCEL_SUCCESS("Cmd Update - Cancel Success", "§aCancel operation performed."),
|
||||
UPDATE_NOTIFY_CANCEL("Cmd Update - Notify Cancel", "§aYou can cancel the update on servers that haven't rebooted yet with /plan update cancel."),
|
||||
UPDATE_ONLINE_CHECK("Cmd Update - Online Check", "Checking that all servers are online.."),
|
||||
UPDATE_FAIL_NOT_ONLINE("Cmd Update - Fail Not Online", "§cNot all servers were online or accessible, you can still update available servers using /plan update -u -force"),
|
||||
UPDATE_SCHEDULED("Cmd Update - Scheduled", "§a${0} scheduled for update."),
|
||||
UPDATE_FAIL_FORCED("Cmd Update - Fail Force Notify", "§e${0} failed to update, -force specified, continuing update."),
|
||||
UPDATE_FAIL_CANCEL("Cmd Update - Fail Cacnel", "§cUpdate failed on a server, cancelling update on all servers.."),
|
||||
UPDATE_CANCELLED("Cmd Update - Cancelled", "§cUpdate cancelled."),
|
||||
|
||||
RELOAD_COMPLETE("Cmd Info - Reload Complete", "§aReload Complete"),
|
||||
RELOAD_FAILED("Cmd Info - Reload Failed", "§cSomething went wrong during reload of the plugin, a restart is recommended.");
|
||||
|
||||
|
@ -18,7 +18,6 @@ public enum DeepHelpLang implements Lang {
|
||||
QINSPECT("In Depth Help - /plan qinspect ?", "> §2Quick Inspect Command\\ Displays some information about the player in game."),
|
||||
RELOAD("In Depth Help - /plan reload ?", "> §2Reload Command\\ Restarts the plugin using onDisable and onEnable.\\ §bDoes not support swapping jar on the fly"),
|
||||
SEARCH("In Depth Help - /plan search ?", "> §2Search Command\\ Get a list of Player names that match the given argument.\\§7 Example: /plan search 123 - Finds all users with 123 in their name."),
|
||||
UPDATE("In Depth Help - /plan update ?", "> §2Update Command\\ Used to update the plugin on the next shutdown\\ /plan update - Changelog link\\ /plan update -u - Schedule update to happen on all network servers that are online, next time they reboot.\\ /plan update cancel - Cancel scheduled update on servers that haven't rebooted yet."),
|
||||
WEB("In Depth Help - /plan web ?", "< §2Web User Manage Command.\\ §2/plan web §fList subcommands\\ §2/plan web <subcommand> ? §fIn Depth help"),
|
||||
|
||||
MANAGE_BACKUP("In Depth Help - /plan manage backup ?", "> §2Backup Subcommand\\ Creates a new SQLite database (.db file) with contents of currently active database in the Plan plugin folder."),
|
||||
|
@ -197,7 +197,7 @@ public class UserImportData {
|
||||
|
||||
public UserImportDataBuilder nicknames(String... nicknames) {
|
||||
long time = System.currentTimeMillis();
|
||||
UUID serverUUID = ServerInfo.getServerUUID();
|
||||
UUID serverUUID = ServerInfo.getServerUUID_Old();
|
||||
|
||||
Arrays.stream(nicknames)
|
||||
.map(nick -> new Nickname(nick, time, serverUUID))
|
||||
|
@ -93,7 +93,7 @@ public abstract class Importer {
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = ServerInfo.getServerUUID();
|
||||
UUID uuid = ServerInfo.getServerUUID_Old();
|
||||
Database db = Database.getActive();
|
||||
|
||||
ExecutorService service = Executors.newCachedThreadPool();
|
||||
@ -137,7 +137,7 @@ public abstract class Importer {
|
||||
UserImportRefiner userImportRefiner = new UserImportRefiner(Plan.getInstance(), userImportData);
|
||||
userImportData = userImportRefiner.refineData();
|
||||
|
||||
UUID serverUUID = ServerInfo.getServerUUID();
|
||||
UUID serverUUID = ServerInfo.getServerUUID_Old();
|
||||
Database db = Database.getActive();
|
||||
|
||||
Set<UUID> existingUUIDs = db.fetch().getSavedUUIDs();
|
||||
@ -216,7 +216,7 @@ public abstract class Importer {
|
||||
int mobKills = userImportData.getMobKills();
|
||||
int deaths = userImportData.getDeaths();
|
||||
|
||||
Session session = new Session(0, userImportData.getUuid(), ServerInfo.getServerUUID(), 0L, 0L, mobKills, deaths, 0);
|
||||
Session session = new Session(0, userImportData.getUuid(), ServerInfo.getServerUUID_Old(), 0L, 0L, mobKills, deaths, 0);
|
||||
|
||||
session.setPlayerKills(userImportData.getKills());
|
||||
session.setWorldTimes(new WorldTimes(userImportData.getWorldTimes()));
|
||||
|
@ -27,7 +27,7 @@ public class NameProcessor implements CriticalRunnable {
|
||||
public NameProcessor(UUID uuid, String playerName, String displayName) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
this.nickname = new Nickname(displayName, System.currentTimeMillis(), ServerInfo.getServerUUID());
|
||||
this.nickname = new Nickname(displayName, System.currentTimeMillis(), ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public class PingInsertProcessor implements CriticalRunnable {
|
||||
|
||||
int maxValue = max.getAsInt();
|
||||
|
||||
Ping ping = new Ping(lastDate, ServerInfo.getServerUUID(),
|
||||
Ping ping = new Ping(lastDate, ServerInfo.getServerUUID_Old(),
|
||||
minValue,
|
||||
maxValue,
|
||||
avgValue);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.djrapitops.plan.system.settings;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.config.Setting;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.config.Config;
|
||||
@ -16,7 +17,7 @@ import java.util.List;
|
||||
* @author Rsl1122
|
||||
* @since 2.3.2
|
||||
*/
|
||||
public enum Settings {
|
||||
public enum Settings implements Setting {
|
||||
// Boolean
|
||||
BUNGEE_COPY_CONFIG("Plugin.Bungee-Override.CopyBungeeConfig"),
|
||||
BUNGEE_OVERRIDE_STANDALONE_MODE("Plugin.Bungee-Override.StandaloneMode"),
|
||||
@ -37,7 +38,6 @@ public enum Settings {
|
||||
DISPLAY_PLAYER_IPS("Customization.Display.PlayerIPs"),
|
||||
DISPLAY_GAPS_IN_GRAPH_DATA("Customization.Display.GapsInGraphData"),
|
||||
DATA_GEOLOCATIONS("Data.Geolocations"),
|
||||
ALLOW_UPDATE("Plugin.Allow-Update-Command"),
|
||||
NOTIFY_ABOUT_DEV_RELEASES("Plugin.Notify-About-DEV-Releases"),
|
||||
|
||||
// Integer
|
||||
@ -117,6 +117,7 @@ public enum Settings {
|
||||
this.configPath = path;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ServerSpecificSettings serverSpecific() {
|
||||
if (!Check.isBungeeAvailable()) {
|
||||
throw new IllegalStateException("Not supposed to call this method on Bukkit");
|
||||
@ -125,22 +126,7 @@ public enum Settings {
|
||||
return serverSpecificSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the settings is a boolean, this method should be used.
|
||||
*
|
||||
* @return Boolean value of the config setting, false if not boolean.
|
||||
*/
|
||||
public boolean isTrue() {
|
||||
if (tempValue != null) {
|
||||
return (Boolean) tempValue;
|
||||
}
|
||||
return getConfig().getBoolean(configPath);
|
||||
}
|
||||
|
||||
public boolean isFalse() {
|
||||
return !isTrue();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void save() {
|
||||
try {
|
||||
ConfigSystem.getConfig_Old().save();
|
||||
@ -149,12 +135,31 @@ public enum Settings {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the settings is a boolean, this method should be used.
|
||||
*
|
||||
* @return Boolean value of the config setting, false if not boolean.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isTrue() {
|
||||
if (tempValue != null) {
|
||||
return (Boolean) tempValue;
|
||||
}
|
||||
return getConfig().getBoolean(configPath);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isFalse() {
|
||||
return !isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the settings is a String, this method should be used.
|
||||
*
|
||||
* @return String value of the config setting.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String toString() {
|
||||
if (tempValue != null) {
|
||||
return String.valueOf(tempValue);
|
||||
@ -167,6 +172,7 @@ public enum Settings {
|
||||
*
|
||||
* @return Integer value of the config setting
|
||||
*/
|
||||
@Deprecated
|
||||
public int getNumber() {
|
||||
if (tempValue != null) {
|
||||
return (Integer) tempValue;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user