Compare commits
No commits in common. "9a6ff804f188c9ef487c09d44297f2f70873c686" and "2f9eaffa12d251ec3aae775a274d372f8a758749" have entirely different histories.
9a6ff804f1
...
2f9eaffa12
15 changed files with 50 additions and 170 deletions
|
@ -26,7 +26,7 @@ public final class BuildConfiguration {
|
||||||
public static final String pluginName = "PickShadow Server Plugin";
|
public static final String pluginName = "PickShadow Server Plugin";
|
||||||
public static final int pluginRelease = 1;
|
public static final int pluginRelease = 1;
|
||||||
public static final Types.VersionType pluginVersionType = Types.VersionType.ALPHA;
|
public static final Types.VersionType pluginVersionType = Types.VersionType.ALPHA;
|
||||||
public static final int pluginTyperelease = 2;
|
public static final int pluginTyperelease = 1;
|
||||||
public static final String[] pluginAuthors = new String[]{ "JeremyStarTM" };
|
public static final String[] pluginAuthors = new String[]{ "JeremyStarTM" };
|
||||||
public static final String[] pluginContributors = new String[]{};
|
public static final String[] pluginContributors = new String[]{};
|
||||||
public static final String pluginLicense = "GNU AGPL v3 (or later)";
|
public static final String pluginLicense = "GNU AGPL v3 (or later)";
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package de.pickshadow.plugin.base;
|
package de.pickshadow.plugin.base;
|
||||||
|
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
|
||||||
import de.pickshadow.plugin.classes.logger.LoggerInstanceImpl;
|
import de.pickshadow.plugin.classes.logger.LoggerInstanceImpl;
|
||||||
import de.pickshadow.plugin.commands.*;
|
import de.pickshadow.plugin.commands.*;
|
||||||
import de.pickshadow.plugin.loaders.ConfigLoader;
|
import de.pickshadow.plugin.loaders.ConfigLoader;
|
||||||
|
@ -33,9 +32,6 @@ public class PluginInitializer {
|
||||||
// Objects
|
// Objects
|
||||||
private final LoggerInstanceImpl logger;
|
private final LoggerInstanceImpl logger;
|
||||||
|
|
||||||
// Lists
|
|
||||||
CommandBase[] commands = new CommandBase[0];
|
|
||||||
|
|
||||||
public PluginInitializer() {
|
public PluginInitializer() {
|
||||||
logger = ObjHolder.logger.getInstance(getClass());
|
logger = ObjHolder.logger.getInstance(getClass());
|
||||||
}
|
}
|
||||||
|
@ -65,14 +61,16 @@ public class PluginInitializer {
|
||||||
return "Could not update active spelling language";
|
return "Could not update active spelling language";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize commands
|
|
||||||
logger.verb("Initializing commands");
|
|
||||||
commands = new CommandBase[]{new BroadcastCommand(), new DiscordCommand(), new HomeCommand(), new PluginCommand(), new SystemInformationCommand(), new TrollCommand(), new MsgCommand(), new ClearChatCommand(), new ToggleDownfallCommand()};
|
|
||||||
|
|
||||||
// Register commands
|
// Register commands
|
||||||
logger.verb("Registering commands");
|
logger.verb("Registering commands");
|
||||||
try {
|
try {
|
||||||
for (CommandBase command : commands) command.registerCommand();
|
new BroadcastCommand().registerCommand();
|
||||||
|
new DiscordCommand().registerCommand();
|
||||||
|
new HomeCommand().registerCommand();
|
||||||
|
new PluginCommand().registerCommand();
|
||||||
|
new SystemInformationCommand().registerCommand();
|
||||||
|
new TrollCommand().registerCommand();
|
||||||
|
new MsgCommand().registerCommand();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
logger.crash("Could not register plugin commands", e.getStackTrace());
|
logger.crash("Could not register plugin commands", e.getStackTrace());
|
||||||
}
|
}
|
||||||
|
@ -94,23 +92,10 @@ public class PluginInitializer {
|
||||||
|
|
||||||
public void uninitialize() {
|
public void uninitialize() {
|
||||||
logger.info("Uninitializing PSSP");
|
logger.info("Uninitializing PSSP");
|
||||||
|
|
||||||
// Close active hunspell instance
|
|
||||||
logger.verb("Closing Hunspell instance");
|
logger.verb("Closing Hunspell instance");
|
||||||
ObjHolder.spellingHelper.setActiveLanguage(null);
|
ObjHolder.spellingHelper.setActiveLanguage(null);
|
||||||
|
|
||||||
// Save player data
|
|
||||||
logger.verb("Saving player data");
|
logger.verb("Saving player data");
|
||||||
for (UUID uuid : ObjHolder.playerDataLoader.getLoadedUUIDs()) ObjHolder.playerDataLoader.savePlayerData(uuid);
|
for (UUID uuid : ObjHolder.playerDataLoader.getLoadedUUIDs()) ObjHolder.playerDataLoader.savePlayerData(uuid);
|
||||||
|
|
||||||
// Unregister commands
|
|
||||||
logger.verb("Unregistering commands");
|
|
||||||
try {
|
|
||||||
for (CommandBase command : commands) command.unregisterCommand();
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.crash("Could not unregister plugin commands", e.getStackTrace(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("Uninitialized PSSP");
|
logger.info("Uninitialized PSSP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package de.pickshadow.plugin.base;
|
||||||
|
|
||||||
import de.pickshadow.plugin.BuildConfiguration;
|
import de.pickshadow.plugin.BuildConfiguration;
|
||||||
import de.pickshadow.plugin.classes.Configuration;
|
import de.pickshadow.plugin.classes.Configuration;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
|
||||||
import de.pickshadow.plugin.classes.logger.LoggerInstanceImpl;
|
import de.pickshadow.plugin.classes.logger.LoggerInstanceImpl;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -30,46 +29,48 @@ import java.util.UUID;
|
||||||
public class Scheduler {
|
public class Scheduler {
|
||||||
LoggerInstanceImpl logger;
|
LoggerInstanceImpl logger;
|
||||||
|
|
||||||
// Keeps track of running bukkit scheduler tasks
|
// Keeps track on how many times the scheduler has been run
|
||||||
private int taskIdMinutely = 0;
|
// Normally this isn't required, this however prevents duplicate
|
||||||
private int taskIdHourly = 0;
|
// scheduler calls in case /pssp scheduler <timeframe> is used.
|
||||||
|
public int execsMinutely = 0;
|
||||||
|
public int execsHourly = 0;
|
||||||
|
|
||||||
public void initializeScheduler() {
|
public void initializeScheduler() {
|
||||||
logger = ObjHolder.logger.getInstance(getClass());
|
logger = ObjHolder.logger.getInstance(getClass());
|
||||||
logger.verb("Initializing scheduler");
|
logger.verb("Initializing scheduler");
|
||||||
taskIdMinutely = Bukkit.getScheduler().runTaskLater(ObjHolder.main, this::runMinuteTasks, 1200L).getTaskId();
|
Bukkit.getScheduler().runTaskLater(ObjHolder.main, () -> runMinuteTasks(execsMinutely), 1200L);
|
||||||
taskIdHourly = Bukkit.getScheduler().runTaskLater(ObjHolder.main, this::runHourTasks, 72000L).getTaskId();
|
Bukkit.getScheduler().runTaskLater(ObjHolder.main, () -> runHourTasks(execsHourly), 72000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeScheduler(Types.SchedulerType type) {
|
public void runMinuteTasks(int execs) {
|
||||||
switch (type) {
|
// If execution count does not match return
|
||||||
case MINUTELY:
|
if (execs != execsMinutely) return;
|
||||||
Bukkit.getScheduler().cancelTask(taskIdMinutely);
|
|
||||||
runMinuteTasks();
|
|
||||||
break;
|
|
||||||
case HOURLY:
|
|
||||||
Bukkit.getScheduler().cancelTask(taskIdHourly);
|
|
||||||
runHourTasks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runMinuteTasks() {
|
|
||||||
// Print announcement
|
// Print announcement
|
||||||
printTaskAnnouncement("minutely");
|
printTaskAnnouncement("minutely");
|
||||||
|
|
||||||
|
// Increase execution count to prevent additional calls
|
||||||
|
execsMinutely++;
|
||||||
|
|
||||||
|
|
||||||
// Save player data
|
// Save player data
|
||||||
for (UUID uuid : ObjHolder.playerDataLoader.getLoadedUUIDs()) ObjHolder.playerDataLoader.savePlayerData(uuid);
|
for (UUID uuid : ObjHolder.playerDataLoader.getLoadedUUIDs()) ObjHolder.playerDataLoader.savePlayerData(uuid);
|
||||||
|
|
||||||
|
|
||||||
// Schedule
|
// Schedule
|
||||||
taskIdMinutely = Bukkit.getScheduler().runTaskLater(ObjHolder.main, this::runMinuteTasks, 1200L).getTaskId();
|
Bukkit.getScheduler().runTaskLater(ObjHolder.main, () -> runMinuteTasks(execsMinutely), 1200L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runHourTasks() {
|
public void runHourTasks(int execs) {
|
||||||
|
// If execution count does not match return
|
||||||
|
if (execs != execsHourly) return;
|
||||||
|
|
||||||
// Print announcement
|
// Print announcement
|
||||||
printTaskAnnouncement("hourly");
|
printTaskAnnouncement("hourly");
|
||||||
|
|
||||||
|
// Increase execution count to prevent additional calls
|
||||||
|
execsHourly++;
|
||||||
|
|
||||||
// Reload configuration file
|
// Reload configuration file
|
||||||
Configuration newConfig = ObjHolder.configLoader.loadConfig();
|
Configuration newConfig = ObjHolder.configLoader.loadConfig();
|
||||||
if (newConfig == null) {
|
if (newConfig == null) {
|
||||||
|
@ -84,7 +85,7 @@ public class Scheduler {
|
||||||
|
|
||||||
|
|
||||||
// Schedule
|
// Schedule
|
||||||
taskIdHourly = Bukkit.getScheduler().runTaskLater(ObjHolder.main, this::runHourTasks, 72000L).getTaskId();
|
Bukkit.getScheduler().runTaskLater(ObjHolder.main, () -> runHourTasks(execsHourly), 72000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printTaskAnnouncement(String timeframe) {
|
private void printTaskAnnouncement(String timeframe) {
|
||||||
|
|
|
@ -109,10 +109,4 @@ public class Translation {
|
||||||
public static String MSG_NO_LAST_MESSAGED_PLAYER = "Du scheinst keinen Spieler in der letzten Zeit angeschrieben zu haben.";
|
public static String MSG_NO_LAST_MESSAGED_PLAYER = "Du scheinst keinen Spieler in der letzten Zeit angeschrieben zu haben.";
|
||||||
public static String MSG_TO = "<gold><bold>%reciever% <reset><gold>« <bold>%sender% <reset><gold>» <reset>%message%";
|
public static String MSG_TO = "<gold><bold>%reciever% <reset><gold>« <bold>%sender% <reset><gold>» <reset>%message%";
|
||||||
public static String MSG_FROM = "<gold><bold>%reciever% <reset><gold>» <bold>%sender% <reset><gold>» <reset>%message%";
|
public static String MSG_FROM = "<gold><bold>%reciever% <reset><gold>» <bold>%sender% <reset><gold>» <reset>%message%";
|
||||||
|
|
||||||
// Command: /clearchat
|
|
||||||
public static String CLEARCHAT = "Der Chat wurde von %sender% geleert.";
|
|
||||||
|
|
||||||
// Command: /toggledownfall
|
|
||||||
public static String TOGGLEDOWNFALL = "Der Niederschlag wurde umgestellt.";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,4 @@ public class Configuration {
|
||||||
public boolean enablePrefix = false;
|
public boolean enablePrefix = false;
|
||||||
public String inviteLink = "";
|
public String inviteLink = "";
|
||||||
public String defaultSpellingLanguage = "de_DE";
|
public String defaultSpellingLanguage = "de_DE";
|
||||||
public boolean useOldMcTranslationForToggleDownfall = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,4 @@ public class Types {
|
||||||
public enum VersionType { RELEASE, RELEASECANDIDATE, BETA, ALPHA }
|
public enum VersionType { RELEASE, RELEASECANDIDATE, BETA, ALPHA }
|
||||||
public enum LoggerLevel { ERROR, WARN, INFO, VERB, DIAG }
|
public enum LoggerLevel { ERROR, WARN, INFO, VERB, DIAG }
|
||||||
public enum FormatType { NONE, ERROR, NORMAL }
|
public enum FormatType { NONE, ERROR, NORMAL }
|
||||||
public enum SchedulerType { MINUTELY, HOURLY }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package de.pickshadow.plugin.commands;
|
|
||||||
|
|
||||||
import de.pickshadow.plugin.base.Translation;
|
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class ClearChatCommand extends CommandBase {
|
|
||||||
public ClearChatCommand() {
|
|
||||||
commandNames = new String[]{ "clearchat" };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) player.sendMessage(MiniMessage.miniMessage().deserialize("\n".repeat(10000)).append(Miscellaneous.format(Translation.CLEARCHAT.replace("%sender%", sender.getName()))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TabCompleter getCompletion() {
|
|
||||||
return TabCompletionHelper.createEmptyCompletion();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,10 @@ public class HomeCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Location coords = player.getRespawnLocation();
|
Location coords = player.getRespawnLocation();
|
||||||
if (coords == null) {
|
if (coords == null) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import de.pickshadow.plugin.utils.TabCompletionHelper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -43,7 +44,10 @@ public class MsgCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Define shared variables
|
// Define shared variables
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -76,7 +77,10 @@ public class PluginCommand extends CommandBase {
|
||||||
gcThread.start();
|
gcThread.start();
|
||||||
break;
|
break;
|
||||||
case "playerinfo":
|
case "playerinfo":
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) break;
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
||||||
|
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())));
|
||||||
|
@ -91,13 +95,13 @@ public class PluginCommand extends CommandBase {
|
||||||
case "minutely":
|
case "minutely":
|
||||||
case "minute":
|
case "minute":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "minutely")));
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "minutely")));
|
||||||
ObjHolder.scheduler.executeScheduler(Types.SchedulerType.MINUTELY);
|
ObjHolder.scheduler.runMinuteTasks(ObjHolder.scheduler.execsMinutely);
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "minutely")));
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "minutely")));
|
||||||
break;
|
break;
|
||||||
case "hourly":
|
case "hourly":
|
||||||
case "hour":
|
case "hour":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "hourly")));
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "hourly")));
|
||||||
ObjHolder.scheduler.executeScheduler(Types.SchedulerType.HOURLY);
|
ObjHolder.scheduler.runHourTasks(ObjHolder.scheduler.execsHourly);
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "hourly")));
|
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "hourly")));
|
||||||
break;
|
break;
|
||||||
default: sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
default: sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
package de.pickshadow.plugin.commands;
|
|
||||||
|
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
|
||||||
import de.pickshadow.plugin.base.Translation;
|
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class ToggleDownfallCommand extends CommandBase {
|
|
||||||
public ToggleDownfallCommand() {
|
|
||||||
commandNames = new String[]{ "toggledownfall" };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
World world = player.getWorld();
|
|
||||||
|
|
||||||
if (world.isClearWeather()) world.setClearWeatherDuration(new Random().nextInt(6000));
|
|
||||||
else if (world.isThundering()) {
|
|
||||||
world.setThundering(true);
|
|
||||||
world.setThunderDuration(new Random().nextInt(6000));
|
|
||||||
} else {
|
|
||||||
logger.error("Invalid weather state. isClearWeather() and isThundering() are false.");
|
|
||||||
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_EXCEPTION));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ObjHolder.config.useOldMcTranslationForToggleDownfall) {
|
|
||||||
if (player.locale() == Locale.GERMANY) player.sendMessage("Der Niederschlag wurde umgestellt.");
|
|
||||||
else player.sendMessage("Toggled downfall.");
|
|
||||||
}
|
|
||||||
else player.sendMessage(Miscellaneous.format(Translation.TOGGLEDOWNFALL));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TabCompleter getCompletion() {
|
|
||||||
return TabCompletionHelper.createEmptyCompletion();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,7 +45,10 @@ public class TrollCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_ENOUGH_ARGUMENTS.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_ENOUGH_ARGUMENTS.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
|
|
|
@ -24,8 +24,6 @@ import de.pickshadow.plugin.classes.Types;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
@ -68,18 +66,6 @@ public class Miscellaneous {
|
||||||
ObjHolder.logger.warn(Miscellaneous.class, "Garbage collector finished");
|
ObjHolder.logger.warn(Miscellaneous.class, "Garbage collector finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if command was sent by console
|
|
||||||
public static boolean isCommandSentByConsole(CommandSender sender) {
|
|
||||||
return isCommandSentByConsole(sender, false);
|
|
||||||
}
|
|
||||||
public static boolean isCommandSentByConsole(CommandSender sender, boolean issueError) {
|
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
|
||||||
if (issueError) sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Data type conversion
|
// Data type conversion
|
||||||
/// Bytes <-> Mebibytes
|
/// Bytes <-> Mebibytes
|
||||||
public static double byteToMib(int bytes, boolean flatten) {
|
public static double byteToMib(int bytes, boolean flatten) {
|
||||||
|
|
|
@ -10,4 +10,3 @@ version: 0
|
||||||
enablePrefix: true
|
enablePrefix: true
|
||||||
inviteLink: ""
|
inviteLink: ""
|
||||||
defaultSpellingLanguage: "de_DE"
|
defaultSpellingLanguage: "de_DE"
|
||||||
useOldMcTranslationForToggleDownfall: true
|
|
||||||
|
|
|
@ -62,15 +62,6 @@ commands:
|
||||||
usage: /reply <Nachricht>
|
usage: /reply <Nachricht>
|
||||||
aliases: [ "r" ]
|
aliases: [ "r" ]
|
||||||
permission: pickshadow.commands.reply
|
permission: pickshadow.commands.reply
|
||||||
clearchat:
|
|
||||||
description: Löscht den Chatverlauf für den gesamten Server.
|
|
||||||
usage: /clearchat
|
|
||||||
aliases: [ "cc", "chatclear" ]
|
|
||||||
permission: pickshadow.commands.clearchat
|
|
||||||
toggledownfall:
|
|
||||||
description: Stellt den Niederschlag um. Erinnering an alte Zeiten.
|
|
||||||
usage: /toggledownfall
|
|
||||||
permission: pickshadow.commands.toggledownfall
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
pickshadow.*:
|
pickshadow.*:
|
||||||
|
@ -90,8 +81,6 @@ permissions:
|
||||||
- pickshadow.commands.broadcast
|
- pickshadow.commands.broadcast
|
||||||
- pickshadow.commands.msg
|
- pickshadow.commands.msg
|
||||||
- pickshadow.commands.reply
|
- pickshadow.commands.reply
|
||||||
- pickshadow.commands.clearchat
|
|
||||||
- pickshadow.commands.toggledownfall
|
|
||||||
pickshadow.commands.discord:
|
pickshadow.commands.discord:
|
||||||
default: not op
|
default: not op
|
||||||
pickshadow.commands.home:
|
pickshadow.commands.home:
|
||||||
|
@ -108,7 +97,3 @@ permissions:
|
||||||
default: not op
|
default: not op
|
||||||
pickshadow.commands.reply:
|
pickshadow.commands.reply:
|
||||||
default: not op
|
default: not op
|
||||||
pickshadow.commands.clearchat:
|
|
||||||
default: op
|
|
||||||
pickshadow.commands.toggledownfall:
|
|
||||||
default: not op
|
|
||||||
|
|
Loading…
Reference in a new issue