Compare commits
2 commits
5c8f198e30
...
11a25dd8e9
Author | SHA1 | Date | |
---|---|---|---|
11a25dd8e9 | |||
433b5fa0be |
17 changed files with 298 additions and 123 deletions
|
@ -112,6 +112,20 @@ public class Translation {
|
||||||
|
|
||||||
// Command: /clearchat
|
// Command: /clearchat
|
||||||
public static String CLEARCHAT = "Der Chat wurde von %sender% geleert.";
|
public static String CLEARCHAT = "Der Chat wurde von %sender% geleert.";
|
||||||
|
public static String[] CLEARCHAT_CURSES = new String[]{
|
||||||
|
"Der Chat wurde von %sender% gemolken.",
|
||||||
|
"Der Chat wurde von %sender% gegessen.",
|
||||||
|
"Der Chat wurde von %sender% ins nichts gebumbst.",
|
||||||
|
"Der Chat wurde von %sender% ins Void geschubst.",
|
||||||
|
"Der Chat wurde von %sender% in die Mülltonne geworfen.",
|
||||||
|
"Der Chat wurde aufgrund von Skill Issues von Chatteilnehmern von %sender% gelöscht.",
|
||||||
|
"Der Chat wurde aufgrund von übermäßigem Cringe von %sender% gelöscht.",
|
||||||
|
"\"You shall not pass!\" wurde von %sender% ausgerufen!",
|
||||||
|
"%sender% hasst euch alle und hat daher den Chatverlauf gelöscht.",
|
||||||
|
"%sender% hat die Chattoilette ordentlich gespült!",
|
||||||
|
"%sender% hat den Gartenschlauch auf den Chat gerichtet.",
|
||||||
|
"Alle Nachrichten des Chats sind auf den Boden gefallen, weil %sender% ihn angerempelt hat."
|
||||||
|
};
|
||||||
|
|
||||||
// Command: /toggledownfall
|
// Command: /toggledownfall
|
||||||
public static String TOGGLEDOWNFALL = "Der Niederschlag wurde umgestellt.";
|
public static String TOGGLEDOWNFALL = "Der Niederschlag wurde umgestellt.";
|
||||||
|
|
|
@ -55,9 +55,15 @@ public abstract class CommandBase implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command code
|
// Command code (from Bukkit, handled internally)
|
||||||
@Override
|
@Override
|
||||||
public abstract 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) {
|
||||||
|
getCommand(new Interactable(sender), command, label, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command code (abstracted)
|
||||||
|
public abstract void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args);
|
||||||
|
|
||||||
// Command completion
|
// Command completion
|
||||||
public abstract TabCompleter getCompletion();
|
public abstract TabCompleter getCompletion();
|
||||||
|
|
|
@ -24,4 +24,5 @@ public class Configuration {
|
||||||
public String inviteLink = "";
|
public String inviteLink = "";
|
||||||
public String defaultSpellingLanguage = "de_DE";
|
public String defaultSpellingLanguage = "de_DE";
|
||||||
public boolean useOldMcTranslationForToggleDownfall = true;
|
public boolean useOldMcTranslationForToggleDownfall = true;
|
||||||
|
public boolean allowChatClearMessageWithProfanity = true;
|
||||||
}
|
}
|
||||||
|
|
140
src/main/java/de/pickshadow/plugin/classes/Interactable.java
Normal file
140
src/main/java/de/pickshadow/plugin/classes/Interactable.java
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
package de.pickshadow.plugin.classes;
|
||||||
|
|
||||||
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
|
import de.pickshadow.plugin.classes.exceptions.NotAPlayerException;
|
||||||
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.WeatherType;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Interactable {
|
||||||
|
// Data
|
||||||
|
private UUID uuid;
|
||||||
|
private Player player;
|
||||||
|
private boolean isConsole;
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
public Interactable(@NotNull UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
isConsole = false;
|
||||||
|
}
|
||||||
|
public Interactable(@NotNull Player player) {
|
||||||
|
uuid = player.getUniqueId();
|
||||||
|
this.player = player;
|
||||||
|
isConsole = false;
|
||||||
|
}
|
||||||
|
public Interactable(@NotNull CommandSender sender) {
|
||||||
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
isConsole = true;
|
||||||
|
} else {
|
||||||
|
player = (Player) sender;
|
||||||
|
uuid = player.getUniqueId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
public boolean isConsole() {
|
||||||
|
return isConsole;
|
||||||
|
}
|
||||||
|
public UUID getUniqueId() throws NotAPlayerException {
|
||||||
|
if (isConsole) throw new NotAPlayerException();
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
public boolean hasPermission(Permission permission) {
|
||||||
|
if (isConsole) return true;
|
||||||
|
else return player.hasPermission(permission);
|
||||||
|
}
|
||||||
|
public boolean hasPermission(String permission) {
|
||||||
|
if (isConsole) return true;
|
||||||
|
else return player.hasPermission(permission);
|
||||||
|
}
|
||||||
|
public String getClientBrand() {
|
||||||
|
if (isConsole) return "tty";
|
||||||
|
else return player.getClientBrandName();
|
||||||
|
}
|
||||||
|
public Component getDisplayName() {
|
||||||
|
if (isConsole) return Miscellaneous.format("<BRANDING>", Types.FormatType.NONE);
|
||||||
|
else return player.displayName();
|
||||||
|
}
|
||||||
|
public Locale getLocale() {
|
||||||
|
if (isConsole) return Locale.US;
|
||||||
|
else return player.locale();
|
||||||
|
}
|
||||||
|
public String getName() {
|
||||||
|
if (isConsole) return "CONSOLE";
|
||||||
|
else return player.getName();
|
||||||
|
}
|
||||||
|
public int getPing() {
|
||||||
|
if (isConsole) return 0;
|
||||||
|
else return player.getPing();
|
||||||
|
}
|
||||||
|
public WeatherType getWeather() throws NotAPlayerException {
|
||||||
|
if (isConsole) throw new NotAPlayerException();
|
||||||
|
else {
|
||||||
|
if (player.getWorld().isClearWeather()) return WeatherType.CLEAR;
|
||||||
|
else if (player.getWorld().isThundering()) return WeatherType.DOWNFALL;
|
||||||
|
else {
|
||||||
|
ObjHolder.logger.crash(getClass(), "Invalid weather type (not clear or downfall)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Location getRespawnLocation() {
|
||||||
|
if (isConsole) return new Location(Bukkit.getWorlds().get(0), 0, -64, 0);
|
||||||
|
else return player.getRespawnLocation();
|
||||||
|
}
|
||||||
|
public float getFallDistance() {
|
||||||
|
if (isConsole) return 0f;
|
||||||
|
else return player.getFallDistance();
|
||||||
|
}
|
||||||
|
public World getWorld() throws NotAPlayerException {
|
||||||
|
if (isConsole) throw new NotAPlayerException();
|
||||||
|
else return player.getWorld();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
public void setDisplayName(@Nullable Component name) {
|
||||||
|
if (!isConsole) player.displayName(name);
|
||||||
|
}
|
||||||
|
public void setRespawnLocation(@NotNull Location location) {
|
||||||
|
setRespawnLocation(location, false);
|
||||||
|
}
|
||||||
|
public void setRespawnLocation(@NotNull Location location, boolean force) {
|
||||||
|
if (!isConsole) player.setRespawnLocation(location, force);
|
||||||
|
}
|
||||||
|
public void setFallDistance(float fallDistance) {
|
||||||
|
if (!isConsole) player.setFallDistance(fallDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other methods
|
||||||
|
public void message(Component message) {
|
||||||
|
if (isConsole) Bukkit.getConsoleSender().sendMessage(message);
|
||||||
|
else player.sendMessage(message);
|
||||||
|
}
|
||||||
|
public void message(String message) {
|
||||||
|
message(MiniMessage.miniMessage().deserialize(message));
|
||||||
|
}
|
||||||
|
public void sudo(String chatMessage) {
|
||||||
|
if (isConsole) Bukkit.dispatchCommand(Bukkit.getConsoleSender(), chatMessage);
|
||||||
|
else player.chat(chatMessage);
|
||||||
|
}
|
||||||
|
public void teleport(Entity entity) {
|
||||||
|
teleport(entity.getLocation());
|
||||||
|
}
|
||||||
|
public void teleport(Location location) {
|
||||||
|
if (!isConsole) player.teleport(location);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
package de.pickshadow.plugin.classes;
|
package de.pickshadow.plugin.classes;
|
||||||
|
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
|
import de.pickshadow.plugin.classes.exceptions.NotAPlayerException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
@ -44,6 +45,9 @@ public class PlayerData {
|
||||||
public PlayerData(@NotNull Player player) {
|
public PlayerData(@NotNull Player player) {
|
||||||
playerId = player.getUniqueId();
|
playerId = player.getUniqueId();
|
||||||
}
|
}
|
||||||
|
public PlayerData(@NotNull Interactable intact) throws NotAPlayerException {
|
||||||
|
playerId = intact.getUniqueId();
|
||||||
|
}
|
||||||
// Used for loading player data off disk
|
// Used for loading player data off disk
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public PlayerData() {}
|
public PlayerData() {}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package de.pickshadow.plugin.classes.exceptions;
|
||||||
|
|
||||||
|
public class NotAPlayerException extends Exception {
|
||||||
|
public NotAPlayerException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,11 +20,11 @@ package de.pickshadow.plugin.commands;
|
||||||
|
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
import de.pickshadow.plugin.classes.Types;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
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.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -34,8 +34,7 @@ public class BroadcastCommand extends CommandBase {
|
||||||
commandNames = new String[]{ "broadcast" };
|
commandNames = new String[]{ "broadcast" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (message.isEmpty()) {
|
if (message.isEmpty()) {
|
||||||
|
@ -45,7 +44,6 @@ public class BroadcastCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bukkit.broadcast(Miscellaneous.format(String.valueOf(message), Types.FormatType.NONE, true));
|
Bukkit.broadcast(Miscellaneous.format(String.valueOf(message), Types.FormatType.NONE, true));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabCompleter getCompletion() {
|
public TabCompleter getCompletion() {
|
||||||
|
|
|
@ -1,26 +1,29 @@
|
||||||
package de.pickshadow.plugin.commands;
|
package de.pickshadow.plugin.commands;
|
||||||
|
|
||||||
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
||||||
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.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
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;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class ClearChatCommand extends CommandBase {
|
public class ClearChatCommand extends CommandBase {
|
||||||
public ClearChatCommand() {
|
public ClearChatCommand() {
|
||||||
commandNames = new String[]{ "clearchat" };
|
commandNames = new String[]{ "clearchat" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
String clearChatMessage = Translation.CLEARCHAT;
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) player.sendMessage(MiniMessage.miniMessage().deserialize("\n".repeat(10000)).append(Miscellaneous.format(Translation.CLEARCHAT.replace("%sender%", sender.getName()))));
|
if (ObjHolder.config.allowChatClearMessageWithProfanity) clearChatMessage = Translation.CLEARCHAT_CURSES[new Random().nextInt(Translation.CLEARCHAT_CURSES.length)];
|
||||||
return true;
|
for (Player player : Bukkit.getOnlinePlayers()) player.sendMessage(MiniMessage.miniMessage().deserialize("\n".repeat(10000)).append(Miscellaneous.format(clearChatMessage.replace("%sender%", intact.getName()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,11 +21,11 @@ package de.pickshadow.plugin.commands;
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
import de.pickshadow.plugin.classes.Types;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
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.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -37,14 +37,9 @@ public class DiscordCommand extends CommandBase {
|
||||||
commandNames = new String[]{ "discord" };
|
commandNames = new String[]{ "discord" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void getCommand(@NotNull Interactable intact, @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 (Objects.equals(ObjHolder.config.inviteLink, "")) intact.message(Miscellaneous.format(Translation.DISCORD_UNAVAILABLE, Types.FormatType.ERROR));
|
||||||
if (Objects.equals(ObjHolder.config.inviteLink, "")) {
|
else intact.message(Miscellaneous.format(Translation.DISCORD_INVITE.replace("%invite%", ObjHolder.config.inviteLink)));
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.DISCORD_UNAVAILABLE, Types.FormatType.ERROR));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.DISCORD_INVITE.replace("%invite%", ObjHolder.config.inviteLink)));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabCompleter getCompletion() {
|
public TabCompleter getCompletion() {
|
||||||
|
|
|
@ -20,12 +20,12 @@ package de.pickshadow.plugin.commands;
|
||||||
|
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
import de.pickshadow.plugin.classes.Types;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HomeCommand extends CommandBase {
|
public class HomeCommand extends CommandBase {
|
||||||
|
@ -33,19 +33,15 @@ public class HomeCommand extends CommandBase {
|
||||||
commandNames = new String[]{ "home"};
|
commandNames = new String[]{ "home"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void getCommand(@NotNull Interactable intact, @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(intact, true)) return;
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
Location coords = intact.getRespawnLocation();
|
||||||
Player player = (Player) sender;
|
if (coords == null) intact.message(Miscellaneous.format(Translation.HOME_MISSING, Types.FormatType.ERROR));
|
||||||
Location coords = player.getRespawnLocation();
|
else {
|
||||||
if (coords == null) {
|
intact.message(Miscellaneous.format(Translation.HOME_TELEPORT));
|
||||||
player.sendMessage(Miscellaneous.format(Translation.HOME_MISSING, Types.FormatType.ERROR));
|
intact.setFallDistance(0f);
|
||||||
} else {
|
intact.teleport(coords);
|
||||||
player.sendMessage(Miscellaneous.format(Translation.HOME_TELEPORT));
|
|
||||||
player.setFallDistance(0f);
|
|
||||||
player.teleport(coords);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabCompleter getCompletion() {
|
public TabCompleter getCompletion() {
|
||||||
|
|
|
@ -21,6 +21,7 @@ package de.pickshadow.plugin.commands;
|
||||||
import de.pickshadow.plugin.BuildConfiguration;
|
import de.pickshadow.plugin.BuildConfiguration;
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.PlayerData;
|
import de.pickshadow.plugin.classes.PlayerData;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
import de.pickshadow.plugin.classes.Types;
|
||||||
|
@ -28,7 +29,6 @@ import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
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.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;
|
||||||
|
@ -42,11 +42,11 @@ public class MsgCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
if (Miscellaneous.isCommandSentByConsole(intact, true)) return;
|
||||||
|
|
||||||
// Define shared variables
|
// Define shared variables
|
||||||
Player player = (Player) sender;
|
Player player = (Player) intact;
|
||||||
Player reciever;
|
Player reciever;
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
|
|
||||||
|
@ -56,19 +56,19 @@ public class MsgCommand extends CommandBase {
|
||||||
// Check args size
|
// Check args size
|
||||||
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));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
// Get reciever and check if online
|
// Get reciever and check if online
|
||||||
reciever = Bukkit.getPlayerExact(args[0]);
|
reciever = Bukkit.getPlayerExact(args[0]);
|
||||||
if (reciever == null) {
|
if (reciever == null) {
|
||||||
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_PLAYER_NOT_ONLINE.replace("%player%", args[0])));
|
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_PLAYER_NOT_ONLINE.replace("%player%", args[0])));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if performing self messaging
|
// Check if performing self messaging
|
||||||
if (!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId()) {
|
if (!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId()) {
|
||||||
player.sendMessage(Miscellaneous.format(Translation.MSG_NO_SELF_MESSAGING, Types.FormatType.ERROR));
|
player.sendMessage(Miscellaneous.format(Translation.MSG_NO_SELF_MESSAGING, Types.FormatType.ERROR));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update player data
|
// Update player data
|
||||||
|
@ -89,21 +89,21 @@ public class MsgCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
player.sendMessage(Miscellaneous.format(Translation.MSG_TO.replace("%sender%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
player.sendMessage(Miscellaneous.format(Translation.MSG_TO.replace("%intact%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
||||||
if (!(!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId())) reciever.sendMessage(Miscellaneous.format(Translation.MSG_FROM.replace("%sender%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
if (!(!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId())) reciever.sendMessage(Miscellaneous.format(Translation.MSG_FROM.replace("%intact%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
||||||
break;
|
break;
|
||||||
case "reply":
|
case "reply":
|
||||||
case "r":
|
case "r":
|
||||||
// Check args size
|
// Check args size
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
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));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
// Get last messaged player
|
// Get last messaged player
|
||||||
PlayerData playerData = ObjHolder.playerDataLoader.getPlayerData(player.getUniqueId());
|
PlayerData playerData = ObjHolder.playerDataLoader.getPlayerData(player.getUniqueId());
|
||||||
if (playerData.lastMessagedPlayer == null) {
|
if (playerData.lastMessagedPlayer == null) {
|
||||||
player.sendMessage(Miscellaneous.format(Translation.MSG_NO_LAST_MESSAGED_PLAYER, Types.FormatType.ERROR));
|
player.sendMessage(Miscellaneous.format(Translation.MSG_NO_LAST_MESSAGED_PLAYER, Types.FormatType.ERROR));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
reciever = Bukkit.getPlayer(playerData.lastMessagedPlayer);
|
reciever = Bukkit.getPlayer(playerData.lastMessagedPlayer);
|
||||||
if (reciever == null) {
|
if (reciever == null) {
|
||||||
|
@ -116,7 +116,7 @@ public class MsgCommand extends CommandBase {
|
||||||
// Check if performing self messaging
|
// Check if performing self messaging
|
||||||
if (!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId()) {
|
if (!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId()) {
|
||||||
player.sendMessage(Miscellaneous.format(Translation.MSG_NO_SELF_MESSAGING, Types.FormatType.ERROR));
|
player.sendMessage(Miscellaneous.format(Translation.MSG_NO_SELF_MESSAGING, Types.FormatType.ERROR));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build message string from args
|
// Build message string from args
|
||||||
|
@ -129,13 +129,12 @@ public class MsgCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.MSG_TO.replace("%sender%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
intact.message(Miscellaneous.format(Translation.MSG_TO.replace("%intact%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
||||||
if (!(!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId())) reciever.sendMessage(Miscellaneous.format(Translation.MSG_FROM.replace("%sender%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
if (!(!BuildConfiguration.allowSelfMessaging && player.getUniqueId() == reciever.getUniqueId())) reciever.sendMessage(Miscellaneous.format(Translation.MSG_FROM.replace("%intact%", player.getName()).replace("%reciever%", reciever.getName()).replace("%message%", message), Types.FormatType.NONE, true));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.crash("Invalid command '" + label + "' for " + getClass().getName());
|
logger.crash("Invalid command '" + label + "' for " + getClass().getName());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabCompleter getCompletion() {
|
public TabCompleter getCompletion() {
|
||||||
|
|
|
@ -21,12 +21,12 @@ package de.pickshadow.plugin.commands;
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
import de.pickshadow.plugin.classes.Types;
|
||||||
import de.pickshadow.plugin.classes.Configuration;
|
import de.pickshadow.plugin.classes.Configuration;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
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.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;
|
||||||
|
@ -41,71 +41,70 @@ public class PluginCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (!sender.hasPermission("pickshadow.commands.pssp") || args.length < 1) {
|
if (!intact.hasPermission("pickshadow.commands.pssp") || args.length < 1) {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_INFO));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_INFO));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "reloadconfig":
|
case "reloadconfig":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG));
|
||||||
Configuration newConfig = ObjHolder.configLoader.loadConfig();
|
Configuration newConfig = ObjHolder.configLoader.loadConfig();
|
||||||
if (newConfig == null) {
|
if (newConfig == null) {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG_FAIL, Types.FormatType.ERROR));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG_FAIL, Types.FormatType.ERROR));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG_SUCCESS));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_CONFIG_SUCCESS));
|
||||||
ObjHolder.config = newConfig;
|
ObjHolder.config = newConfig;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "reloaddata":
|
case "reloaddata":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_DATA));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_DATA));
|
||||||
UUID[] failedReloads = ObjHolder.playerDataLoader.reloadPlayerData();
|
UUID[] failedReloads = ObjHolder.playerDataLoader.reloadPlayerData();
|
||||||
if (failedReloads.length == 0) {
|
if (failedReloads.length == 0) {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_DATA_SUCCESS));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_DATA_SUCCESS));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_DATA_FAIL.replace("%uuids%", Arrays.toString(failedReloads)), Types.FormatType.ERROR));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_RELOAD_DATA_FAIL.replace("%uuids%", Arrays.toString(failedReloads)), Types.FormatType.ERROR));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "gc":
|
case "gc":
|
||||||
Thread gcThread = new Thread(() -> {
|
Thread gcThread = new Thread(() -> {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_GARBAGECOLLECT));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_GARBAGECOLLECT));
|
||||||
Miscellaneous.gc();
|
Miscellaneous.gc();
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_GARBAGECOLLECT_FINISHED));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_GARBAGECOLLECT_FINISHED));
|
||||||
});
|
});
|
||||||
gcThread.start();
|
gcThread.start();
|
||||||
break;
|
break;
|
||||||
case "playerinfo":
|
case "playerinfo":
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) break;
|
if (Miscellaneous.isCommandSentByConsole(intact, true)) break;
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) intact;
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_PLAYERINFO.replace("%playerdata%", ObjHolder.playerDataLoader.getPlayerData(player.getUniqueId()).convertToString())));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_PLAYERINFO.replace("%playerdata%", ObjHolder.playerDataLoader.getPlayerData(player.getUniqueId()).convertToString())));
|
||||||
break;
|
break;
|
||||||
case "scheduler":
|
case "scheduler":
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_ENOUGH_ARGUMENTS.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
intact.message(Miscellaneous.format(Translation.GLOBAL_NOT_ENOUGH_ARGUMENTS.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case "minutely":
|
case "minutely":
|
||||||
case "minute":
|
case "minute":
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "minutely")));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "minutely")));
|
||||||
ObjHolder.scheduler.executeScheduler(Types.SchedulerType.MINUTELY);
|
ObjHolder.scheduler.executeScheduler(Types.SchedulerType.MINUTELY);
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "minutely")));
|
intact.message(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")));
|
intact.message(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER.replace("%timeframe%", "hourly")));
|
||||||
ObjHolder.scheduler.executeScheduler(Types.SchedulerType.HOURLY);
|
ObjHolder.scheduler.executeScheduler(Types.SchedulerType.HOURLY);
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.PLUGINCOMMAND_SCHEDULER_DONE.replace("%timeframe%", "hourly")));
|
intact.message(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: intact.message(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
default: intact.message(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabCompleter getCompletion() {
|
public TabCompleter getCompletion() {
|
||||||
|
|
|
@ -20,13 +20,13 @@ package de.pickshadow.plugin.commands;
|
||||||
|
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
import de.pickshadow.plugin.classes.Types;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
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.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -39,23 +39,23 @@ public class SystemInformationCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
switch (label) {
|
switch (label) {
|
||||||
case "sysinfo":
|
case "sysinfo":
|
||||||
case "info":
|
case "info":
|
||||||
case "stats":
|
case "stats":
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(Objects.requireNonNull(getMessage(0)));
|
intact.message(Objects.requireNonNull(getMessage(0)));
|
||||||
} else {
|
} else {
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "memory":
|
case "memory":
|
||||||
sender.sendMessage(Objects.requireNonNull(getMessage(1)));
|
intact.message(Objects.requireNonNull(getMessage(1)));
|
||||||
break;
|
break;
|
||||||
case "performance":
|
case "performance":
|
||||||
sender.sendMessage(Objects.requireNonNull(getMessage(2)));
|
intact.message(Objects.requireNonNull(getMessage(2)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage())));
|
intact.message(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage())));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,19 +63,18 @@ public class SystemInformationCommand extends CommandBase {
|
||||||
case "ram":
|
case "ram":
|
||||||
case "mem":
|
case "mem":
|
||||||
case "memory":
|
case "memory":
|
||||||
sender.sendMessage(Objects.requireNonNull(getMessage(1)));
|
intact.message(Objects.requireNonNull(getMessage(1)));
|
||||||
break;
|
break;
|
||||||
case "tps":
|
case "tps":
|
||||||
case "mspt":
|
case "mspt":
|
||||||
case "perf":
|
case "perf":
|
||||||
sender.sendMessage(Objects.requireNonNull(getMessage(2)));
|
intact.message(Objects.requireNonNull(getMessage(2)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_EXCEPTION, Types.FormatType.ERROR));
|
intact.message(Miscellaneous.format(Translation.GLOBAL_EXCEPTION, Types.FormatType.ERROR));
|
||||||
logger.error("Invalid label \"" + label + "\"");
|
logger.error("Invalid label \"" + label + "\"");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component getMessage(int messageType) {
|
private Component getMessage(int messageType) {
|
||||||
|
|
|
@ -3,13 +3,12 @@ package de.pickshadow.plugin.commands;
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
|
import de.pickshadow.plugin.classes.exceptions.NotAPlayerException;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -21,28 +20,27 @@ public class ToggleDownfallCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
if (Miscellaneous.isCommandSentByConsole(intact, true)) return;
|
||||||
Player player = (Player) sender;
|
|
||||||
World world = player.getWorld();
|
|
||||||
|
|
||||||
if (world.isClearWeather()) world.setClearWeatherDuration(new Random().nextInt(6000));
|
try {
|
||||||
else if (world.isThundering()) {
|
switch (intact.getWeather()) {
|
||||||
world.setThundering(true);
|
case DOWNFALL:
|
||||||
world.setThunderDuration(new Random().nextInt(6000));
|
intact.getWorld().setClearWeatherDuration(new Random().nextInt(6000));
|
||||||
} else {
|
case CLEAR:
|
||||||
logger.error("Invalid weather state. isClearWeather() and isThundering() are false.");
|
intact.getWorld().setThundering(true);
|
||||||
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_EXCEPTION));
|
intact.getWorld().setThunderDuration(new Random().nextInt(6000));
|
||||||
return true;
|
default: logger.crash("Invalid weather type '" + String.valueOf(intact.getWeather()) + "'");
|
||||||
|
}
|
||||||
|
} catch (NotAPlayerException e) {
|
||||||
|
logger.crash("Tried to operate on console Interactable (THIS SHOULD BE IMPOSSIBLE!)", e.getStackTrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjHolder.config.useOldMcTranslationForToggleDownfall) {
|
if (ObjHolder.config.useOldMcTranslationForToggleDownfall) {
|
||||||
if (player.locale() == Locale.GERMANY) player.sendMessage("Der Niederschlag wurde umgestellt.");
|
if (intact.getLocale() == Locale.GERMANY) intact.message("Der Niederschlag wurde umgestellt.");
|
||||||
else player.sendMessage("Toggled downfall.");
|
else intact.message("Toggled downfall.");
|
||||||
}
|
}
|
||||||
else player.sendMessage(Miscellaneous.format(Translation.TOGGLEDOWNFALL));
|
else intact.message(Miscellaneous.format(Translation.TOGGLEDOWNFALL));
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,7 @@ package de.pickshadow.plugin.commands;
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
import de.pickshadow.plugin.classes.CommandBase;
|
import de.pickshadow.plugin.classes.CommandBase;
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
import de.pickshadow.plugin.classes.Types;
|
||||||
import de.pickshadow.plugin.utils.Miscellaneous;
|
import de.pickshadow.plugin.utils.Miscellaneous;
|
||||||
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
import de.pickshadow.plugin.utils.TabCompletionHelper;
|
||||||
|
@ -44,33 +45,42 @@ public class TrollCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public void getCommand(@NotNull Interactable intact, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (Miscellaneous.isCommandSentByConsole(sender, true)) return true;
|
|
||||||
Player player = (Player) sender;
|
/*
|
||||||
|
TODO
|
||||||
|
========
|
||||||
|
|
||||||
|
The 'target' needs to be rewritten to be a Interactable at some point.
|
||||||
|
Player works, but Interactable would be better.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (Miscellaneous.isCommandSentByConsole(intact, true)) return;
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_ENOUGH_ARGUMENTS.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
intact.message(Miscellaneous.format(Translation.GLOBAL_NOT_ENOUGH_ARGUMENTS.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
Player target = Bukkit.getPlayerExact(args[0]);
|
Player target = Bukkit.getPlayerExact(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_PLAYER_NOT_ONLINE.replace("%player%", args[0]), Types.FormatType.ERROR));
|
intact.message(Miscellaneous.format(Translation.GLOBAL_PLAYER_NOT_ONLINE.replace("%player%", args[0]), Types.FormatType.ERROR));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case "demo":
|
case "demo":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_DEMO.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_DEMO.replace("%target%", args[0])));
|
||||||
target.showDemoScreen();
|
target.showDemoScreen();
|
||||||
break;
|
break;
|
||||||
case "credits":
|
case "credits":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_CREDITS.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_CREDITS.replace("%target%", args[0])));
|
||||||
target.showWinScreen();
|
target.showWinScreen();
|
||||||
break;
|
break;
|
||||||
case "guardian":
|
case "guardian":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_GUARDIAN.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_GUARDIAN.replace("%target%", args[0])));
|
||||||
target.showElderGuardian();
|
target.showElderGuardian();
|
||||||
break;
|
break;
|
||||||
case "hack":
|
case "hack":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_HACK.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_HACK.replace("%target%", args[0])));
|
||||||
String base = "<dark_red><bold><obfuscated>";
|
String base = "<dark_red><bold><obfuscated>";
|
||||||
MiniMessage mm = MiniMessage.miniMessage();
|
MiniMessage mm = MiniMessage.miniMessage();
|
||||||
target.showTitle(Title.title(mm.deserialize(base + "S=)E8tuv9ZM^P)TJZMVP);ZTP)MZIZM989pv(UZ;."), mm.deserialize(""), Title.Times.times(Duration.ofMillis(0L), Duration.ofSeconds(5L), Duration.ofMillis(0L))));
|
target.showTitle(Title.title(mm.deserialize(base + "S=)E8tuv9ZM^P)TJZMVP);ZTP)MZIZM989pv(UZ;."), mm.deserialize(""), Title.Times.times(Duration.ofMillis(0L), Duration.ofSeconds(5L), Duration.ofMillis(0L))));
|
||||||
|
@ -100,7 +110,7 @@ public class TrollCommand extends CommandBase {
|
||||||
}, 20L);
|
}, 20L);
|
||||||
break;
|
break;
|
||||||
case "malware":
|
case "malware":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_MALWARE.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_MALWARE.replace("%target%", args[0])));
|
||||||
for (int i = 0; i < 127; i++) {
|
for (int i = 0; i < 127; i++) {
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
if (finalI == 100) {
|
if (finalI == 100) {
|
||||||
|
@ -117,26 +127,25 @@ public class TrollCommand extends CommandBase {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "creeper":
|
case "creeper":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_CREEPER.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_CREEPER.replace("%target%", args[0])));
|
||||||
target.playSound(Sound.sound(Key.key("entity.creeper.primed"), Sound.Source.MASTER, 1f, 1f));
|
target.playSound(Sound.sound(Key.key("entity.creeper.primed"), Sound.Source.MASTER, 1f, 1f));
|
||||||
break;
|
break;
|
||||||
case "heavens":
|
case "heavens":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_HEAVENS.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_HEAVENS.replace("%target%", args[0])));
|
||||||
Location locationHeavens = target.getLocation();
|
Location locationHeavens = target.getLocation();
|
||||||
locationHeavens.setY(10000);
|
locationHeavens.setY(10000);
|
||||||
target.teleport(locationHeavens);
|
target.teleport(locationHeavens);
|
||||||
break;
|
break;
|
||||||
case "crash":
|
case "crash":
|
||||||
player.sendMessage(Miscellaneous.format(Translation.TROLL_CRASH.replace("%target%", args[0])));
|
intact.message(Miscellaneous.format(Translation.TROLL_CRASH.replace("%target%", args[0])));
|
||||||
for (int i = 0; i < 100001; i++) {
|
for (int i = 0; i < 100001; i++) {
|
||||||
target.spawnParticle(Particle.EXPLOSION_HUGE, target.getLocation(), 100000);
|
target.spawnParticle(Particle.EXPLOSION_HUGE, target.getLocation(), 100000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
player.sendMessage(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
intact.message(Miscellaneous.format(Translation.GLOBAL_INVALID_ARGUMENT.replace("%usage%", command.getUsage()), Types.FormatType.ERROR));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabCompleter getCompletion() {
|
public TabCompleter getCompletion() {
|
||||||
|
|
|
@ -20,12 +20,12 @@ package de.pickshadow.plugin.utils;
|
||||||
|
|
||||||
import de.pickshadow.plugin.base.Translation;
|
import de.pickshadow.plugin.base.Translation;
|
||||||
import de.pickshadow.plugin.base.ObjHolder;
|
import de.pickshadow.plugin.base.ObjHolder;
|
||||||
|
import de.pickshadow.plugin.classes.Interactable;
|
||||||
import de.pickshadow.plugin.classes.Types;
|
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.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;
|
||||||
|
@ -73,8 +73,14 @@ public class Miscellaneous {
|
||||||
return isCommandSentByConsole(sender, false);
|
return isCommandSentByConsole(sender, false);
|
||||||
}
|
}
|
||||||
public static boolean isCommandSentByConsole(CommandSender sender, boolean issueError) {
|
public static boolean isCommandSentByConsole(CommandSender sender, boolean issueError) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
return isCommandSentByConsole(new Interactable(sender), issueError);
|
||||||
if (issueError) sender.sendMessage(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
}
|
||||||
|
public static boolean isCommandSentByConsole(Interactable intact) {
|
||||||
|
return isCommandSentByConsole(intact, false);
|
||||||
|
}
|
||||||
|
public static boolean isCommandSentByConsole(Interactable intact, boolean issueError) {
|
||||||
|
if (intact.isConsole()) {
|
||||||
|
if (issueError) intact.message(Miscellaneous.format(Translation.GLOBAL_NOT_A_PLAYER, Types.FormatType.ERROR));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -11,3 +11,4 @@ enablePrefix: true
|
||||||
inviteLink: ""
|
inviteLink: ""
|
||||||
defaultSpellingLanguage: "de_DE"
|
defaultSpellingLanguage: "de_DE"
|
||||||
useOldMcTranslationForToggleDownfall: true
|
useOldMcTranslationForToggleDownfall: true
|
||||||
|
allowChatClearMessageWithProfanity: true
|
Loading…
Reference in a new issue