Update gc and add scheduler subcommand
This commit is contained in:
parent
5d51ae33b0
commit
407a123566
4 changed files with 41 additions and 9 deletions
|
@ -53,6 +53,9 @@ public class Translation {
|
||||||
public static String PLUGINCOMMAND_RELOAD_DATA_SUCCESS = "Alle Spielerdaten wurden erfolgreich neugeladen.";
|
public static String PLUGINCOMMAND_RELOAD_DATA_SUCCESS = "Alle Spielerdaten wurden erfolgreich neugeladen.";
|
||||||
public static String PLUGINCOMMAND_RELOAD_DATA_FAIL = "Nicht alle Spielerdaten konnten erfolgreich neugeladen werden, folgende UUIDs sind betroffen:\n%uuids%";
|
public static String PLUGINCOMMAND_RELOAD_DATA_FAIL = "Nicht alle Spielerdaten konnten erfolgreich neugeladen werden, folgende UUIDs sind betroffen:\n%uuids%";
|
||||||
public static String PLUGINCOMMAND_GARBAGECOLLECT = "Starte Garbage Collector, der Server könnte für ein paar Millisekunden einfrieren.";
|
public static String PLUGINCOMMAND_GARBAGECOLLECT = "Starte Garbage Collector, der Server könnte für ein paar Millisekunden einfrieren.";
|
||||||
|
public static String PLUGINCOMMAND_GARBAGECOLLECT_FINISHED = "Der Garbage Collector wurde gestartet und hat erfolgreich den Arbeitsspeicher entleert.";
|
||||||
|
public static String PLUGINCOMMAND_SCHEDULER = "Der Scheduler \"%timeframe%\" wurde gestartet und führt seine Hintergrundaufgaben aus, bitte warten.";
|
||||||
|
public static String PLUGINCOMMAND_SCHEDULER_DONE = "Der Scheduler \"%timeframe%\" wurde ausgeführt. Für eventuelle Fehler gucken sie sich bitte die Serverkonsole an.";
|
||||||
public static String PLUGINCOMMAND_PLAYERINFO = "Deine Spielerinformationen:\n%playerdata%";
|
public static String PLUGINCOMMAND_PLAYERINFO = "Deine Spielerinformationen:\n%playerdata%";
|
||||||
|
|
||||||
// Command: /sysinfo
|
// Command: /sysinfo
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class PluginCommand extends CommandBase {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_INFO));
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_INFO));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "reloadconfig":
|
case "reloadconfig":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG));
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG));
|
||||||
|
@ -68,19 +69,45 @@ public class PluginCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "gc":
|
case "gc":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_GARBAGECOLLECT));
|
Thread gcThread = new Thread(() -> {
|
||||||
Miscellaneous.gc();
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_GARBAGECOLLECT));
|
||||||
|
Miscellaneous.gc();
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_GARBAGECOLLECT_FINISHED));
|
||||||
|
});
|
||||||
|
gcThread.start();
|
||||||
break;
|
break;
|
||||||
case "playerinfo":
|
case "playerinfo":
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_PLAYERINFO.replace("%playerdata%", ObjHolder.playerDataLoader.getPlayerData(player.getUniqueId()).convertToString())));
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_PLAYERINFO.replace("%playerdata%", ObjHolder.playerDataLoader.getPlayerData(player.getUniqueId()).convertToString())));
|
||||||
break;
|
break;
|
||||||
default:
|
case "scheduler":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
if (args.length < 2) {
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_ENOUGH_ARGUMENTS.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args[1]) {
|
||||||
|
case "minutely":
|
||||||
|
case "minute":
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "minutely")));
|
||||||
|
ObjHolder.scheduler.runMinuteTasks(ObjHolder.scheduler.execsMinutely);
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "minutely")));
|
||||||
|
break;
|
||||||
|
case "hourly":
|
||||||
|
case "hour":
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "hourly")));
|
||||||
|
ObjHolder.scheduler.runHourTasks(ObjHolder.scheduler.execsHourly);
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "hourly")));
|
||||||
|
break;
|
||||||
|
default: sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +116,12 @@ public class PluginCommand extends CommandBase {
|
||||||
return (commandSender, command, name, args) -> {
|
return (commandSender, command, name, args) -> {
|
||||||
if (commandSender.hasPermission("atc.commands.pickshadow")) {
|
if (commandSender.hasPermission("atc.commands.pickshadow")) {
|
||||||
ArrayList<String[]> completion = new ArrayList<>();
|
ArrayList<String[]> completion = new ArrayList<>();
|
||||||
completion.add(new String[]{ "reloadconfig", "reloaddata", "gc", "playerinfo" });
|
completion.add(new String[]{ "reloadconfig", "reloaddata", "gc", "scheduler", "playerinfo" });
|
||||||
|
if (args.length > 2) {
|
||||||
|
if (args[0].equals("scheduler")) {
|
||||||
|
completion.add(new String[]{"minutely", "hourly"});
|
||||||
|
}
|
||||||
|
}
|
||||||
return TabCompletionHelper.processDynamicCompletion(completion, args);
|
return TabCompletionHelper.processDynamicCompletion(completion, args);
|
||||||
} else {
|
} else {
|
||||||
return TabCompletionHelper.processEmptyCompletion(args);
|
return TabCompletionHelper.processEmptyCompletion(args);
|
||||||
|
|
|
@ -18,13 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package de.pickshadow.plugin.loaders;
|
package de.pickshadow.plugin.loaders;
|
||||||
|
|
||||||
import de.pickshadow.plugin.Main;
|
|
||||||
import de.pickshadow.plugin.ObjHolder;
|
import de.pickshadow.plugin.ObjHolder;
|
||||||
import de.pickshadow.plugin.classes.Configuration;
|
import de.pickshadow.plugin.classes.Configuration;
|
||||||
import de.pickshadow.plugin.classes.logger.LoggerImpl;
|
|
||||||
import de.pickshadow.plugin.classes.logger.LoggerInstanceImpl;
|
import de.pickshadow.plugin.classes.logger.LoggerInstanceImpl;
|
||||||
import de.pickshadow.plugin.utils.FileOperations;
|
import de.pickshadow.plugin.utils.FileOperations;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.yaml.snakeyaml.LoaderOptions;
|
import org.yaml.snakeyaml.LoaderOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.composer.ComposerException;
|
import org.yaml.snakeyaml.composer.ComposerException;
|
||||||
|
|
|
@ -35,7 +35,7 @@ commands:
|
||||||
permission: pickshadow.commands.home
|
permission: pickshadow.commands.home
|
||||||
pssp:
|
pssp:
|
||||||
description: Verwaltet das PickShadow Server Plugin.
|
description: Verwaltet das PickShadow Server Plugin.
|
||||||
usage: /pssp <reloadconfig|reloaddata|gc|playerinfo>
|
usage: /pssp <reloadconfig|reloaddata|gc <minutely|hourly>|playerinfo>
|
||||||
aliases: [ "pickshadow" ]
|
aliases: [ "pickshadow" ]
|
||||||
sysinfo:
|
sysinfo:
|
||||||
description: Zeigt Informationen zum Server an.
|
description: Zeigt Informationen zum Server an.
|
||||||
|
|
Loading…
Reference in a new issue