From ccf572315f17d3bee2dc0165576ff69957adfbca Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 26 Mar 2023 21:56:38 -0600 Subject: [PATCH] Read the commit description - Admin chat formats now use MiniMessage - Tab header and footers now use MiniMessage - Certain titles from the plugin now use MiniMessage - More commands now use MiniMessage --- .../command/Command_adventure.java | 23 +- .../command/Command_cleanchat.java | 3 +- .../command/Command_mbconfig.java | 2 +- .../command/Command_myadmin.java | 79 ++++-- .../command/Command_orbit.java | 8 +- .../command/Command_potion.java | 2 +- .../command/Command_toggle.java | 232 ++++-------------- .../command/Command_togglechat.java | 21 -- .../command/Command_tprandom.java | 2 +- .../command/Command_trail.java | 12 +- .../command/FreedomCommand.java | 5 - .../totalfreedommod/util/FConverter.java | 2 + 12 files changed, 131 insertions(+), 260 deletions(-) delete mode 100644 commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java create mode 100644 commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java index c8d227cd..9be8f591 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java @@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.GameMode; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -19,12 +20,12 @@ public class Command_adventure extends FreedomCommand { if (isConsole()) { - msg("When used from the console, you must define a target player."); + msgNew("When used from the console, you must define a target player."); return true; } playerSender.setGameMode(GameMode.ADVENTURE); - msg("Your gamemode has been set to adventure."); + msgNew("Your gamemode has been set to adventure."); return true; } @@ -32,13 +33,14 @@ public class Command_adventure extends FreedomCommand if (args[0].equals("-a")) { - for (Player targetPlayer : server.getOnlinePlayers()) - { - targetPlayer.setGameMode(GameMode.ADVENTURE); - } - FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false); - msg("Your gamemode has been set to adventure."); + + server.getOnlinePlayers().forEach(player -> + { + player.setGameMode(GameMode.ADVENTURE); + msgNew("Your gamemode has been set to adventure."); + }); + return true; } @@ -50,9 +52,10 @@ public class Command_adventure extends FreedomCommand return true; } - msg("Setting " + player.getName() + " to game mode adventure."); - msg(player, sender.getName() + " set your game mode to adventure."); + msgNew("Setting to game mode adventure.", Placeholder.unparsed("player", player.getName())); player.setGameMode(GameMode.ADVENTURE); + msgNew(player, " set your game mode to adventure.", Placeholder.unparsed("sender", sender.getName())); + return true; } } \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java index c09019f2..0f1b6804 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java @@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; +import net.kyori.adventure.text.Component; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -17,7 +18,7 @@ public class Command_cleanchat extends FreedomCommand { for (int i = 0; i < 100; i++) { - msg(player, ""); + msg(player, Component.empty()); } }); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java index 8f0922e4..c51ea87c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java @@ -112,7 +112,7 @@ public class Command_mbconfig extends FreedomCommand if (data == null) { - msg(PLAYER_NOT_FOUND, ChatColor.RED); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java index 72f67c27..ecd2d153 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java @@ -4,7 +4,12 @@ import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FConverter; import me.totalfreedom.totalfreedommod.util.FUtil; +import net.kyori.adventure.text.format.TextColor; +import net.kyori.adventure.text.minimessage.tag.Tag; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; +import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -17,7 +22,7 @@ import java.util.Collections; import java.util.List; @CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) -@CommandParameters(description = "Manage your admin entry.", usage = "/ [-o ] | setscformat | clearscformat> | syncroles>") +@CommandParameters(description = "Manage your admin entry.", usage = "/ [-o ] | convertacformat | setacformat | clearacformat> | syncroles>") public class Command_myadmin extends FreedomCommand { @Override @@ -40,14 +45,14 @@ public class Command_myadmin extends FreedomCommand targetPlayer = getPlayer(args[1]); if (targetPlayer == null) { - msg(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } target = getAdmin(targetPlayer); if (target == null) { - msg("That player is not an admin", ChatColor.RED); + msgNew("That player is not an admin"); return true; } @@ -86,8 +91,8 @@ public class Command_myadmin extends FreedomCommand plugin.al.updateTables(); plugin.pl.syncIps(target); - msg(counter + " IPs removed."); - msg(targetPlayer, target.getIps().get(0) + " is now your only IP address"); + msgNew(" IPs removed.", Placeholder.unparsed("count", String.valueOf(counter))); + msgNew(targetPlayer, " is now your only IP address.", Placeholder.unparsed("ip", String.valueOf(target.getIps().get(0)))); return true; } @@ -102,10 +107,11 @@ public class Command_myadmin extends FreedomCommand { if (init == null) { - msg("That IP is not registered to you."); - } else + msgNew("That IP is not registered to you."); + } + else { - msg("That IP does not belong to that player."); + msgNew("That IP does not belong to that player."); } return true; } @@ -114,10 +120,11 @@ public class Command_myadmin extends FreedomCommand { if (init == null) { - msg("You cannot remove your current IP."); - } else + msgNew("You cannot remove your current IP."); + } + else { - msg("You cannot remove that admins current IP."); + msgNew("You cannot remove that admin's current IP."); } return true; } @@ -130,8 +137,26 @@ public class Command_myadmin extends FreedomCommand plugin.pl.syncIps(target); - msg("Removed IP " + args[1]); - msg("Current IPs: " + StringUtils.join(target.getIps(), ", ")); + msgNew("Removed the IP .", Placeholder.unparsed("ip", args[1])); + msgNew("Current IPs: ", Placeholder.unparsed("ip", StringUtils.join(target.getIps(), ", "))); + return true; + } + + case "convertacformat": + { + if (!FConverter.needsConversion(target.getAcFormat())) + { + msgNew("That format does not need to be converted."); + } + else + { + msgNew("Converting format..."); + target.setAcFormat(FConverter.convertAdminChatFormat(target.getAcFormat())); + plugin.al.save(target); + plugin.al.updateTables(); + msgNew("Format conversion complete."); + } + return true; } @@ -139,12 +164,21 @@ public class Command_myadmin extends FreedomCommand case "setscformat": { String format = StringUtils.join(args, " ", 1, args.length); + if (FConverter.needsConversion(format)) + { + msgNew("⚠ Admin chat formats use MiniMessage now. We'll convert your format for you, but consider using MiniMessage next time: https://docs.advntr.dev/minimessage/format.html ⚠"); + format = FConverter.convertAdminChatFormat(format); + } + target.setAcFormat(format); plugin.al.save(target); plugin.al.updateTables(); - msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY); - String example = format.replace("%name%", "ExampleAdmin").replace("%rank%", Rank.ADMIN.getAbbr()).replace("%rankcolor%", Rank.ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog."); - msg(ChatColor.GRAY + "Example: " + FUtil.colorize(example)); + msgNew("Set admin chat format to \"\"", Placeholder.unparsed("format", format)); + msgNew("Example:"); + msgNew(format, Placeholder.unparsed("name", "ExampleAdmin"), + Placeholder.unparsed("rank", Rank.ADMIN.getAbbr()), + TagResolver.resolver("rankcolor", Tag.styling(lol -> lol.color(TextColor.color(Rank.ADMIN.getColor().getColor().getRGB())))), + Placeholder.unparsed("message", "The quick brown fox jumped over the lazy dog.")); return true; } @@ -154,7 +188,7 @@ public class Command_myadmin extends FreedomCommand target.setAcFormat(null); plugin.al.save(target); plugin.al.updateTables(); - msg("Cleared admin chat format.", ChatColor.GRAY); + msgNew("Cleared admin chat format."); return true; } @@ -164,22 +198,23 @@ public class Command_myadmin extends FreedomCommand { if (!ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) { - msg("Role syncing is not enabled.", ChatColor.RED); + msgNew("Role syncing is not enabled."); return true; } PlayerData playerData = plugin.pl.getData(target.getName()); if (playerData.getDiscordID() == null) { - msg("Please run /linkdiscord first!", ChatColor.RED); + msgNew("Please run /linkdiscord first!"); return true; } boolean synced = plugin.dc.syncRoles(target, playerData.getDiscordID()); if (synced) { - msg("Successfully synced your roles.", ChatColor.GREEN); - } else + msgNew("Successfully synced your roles."); + } + else { - msg("Failed to sync your roles, please check the console.", ChatColor.RED); + msgNew("Failed to sync your roles, please check the console."); } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java index 1532d7ae..ab887d44 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java @@ -5,7 +5,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment; import me.totalfreedom.totalfreedommod.punishments.PunishmentType; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; -import org.bukkit.ChatColor; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.GameMode; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -30,7 +30,7 @@ public class Command_orbit extends FreedomCommand if (player == null) { - msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED); + msg(PLAYER_NOT_FOUND); return true; } @@ -42,7 +42,7 @@ public class Command_orbit extends FreedomCommand { if (args[1].equalsIgnoreCase("stop")) { - msg("Stopped orbiting " + player.getName()); + msgNew("Stopped orbiting ", Placeholder.unparsed("player", player.getName())); playerdata.stopOrbiting(); return true; } @@ -53,7 +53,7 @@ public class Command_orbit extends FreedomCommand } catch (NumberFormatException ex) { - msg(ex.getMessage(), ChatColor.RED); + msgNew("" + ex.getMessage()); return true; } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java index 1a34cf83..d2c15831 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java @@ -72,7 +72,7 @@ public class Command_potion extends FreedomCommand if (target == null) { - msg(PLAYER_NOT_FOUND, ChatColor.RED); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java index 308ce7a3..7b8ea040 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java @@ -8,6 +8,7 @@ import me.totalfreedom.totalfreedommod.LoginProcess; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -21,7 +22,7 @@ public class Command_toggle extends FreedomCommand "firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]", "explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "books", "grindstones", "jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44", - "landmines", "tossmob", "gravity"); + "landmines", "tossmob", "gravity", "chat"); @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) @@ -38,82 +39,28 @@ public class Command_toggle extends FreedomCommand switch (args[0].toLowerCase()) { - case "waterplace": - { - toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE); - break; - } - - case "frostwalk": - { - toggle("Frost walker enchantment is", ConfigEntry.ALLOW_FROSTWALKER); - break; - } - - case "fireplace": - { - toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE); - break; - } - - case "lavaplace": - { - toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE); - break; - } - - case "fluidspread": - { - toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD); - break; - } - - case "lavadmg": - { - toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE); - break; - } - - case "firespread": + case "waterplace" -> toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE); + case "frostwalk" -> toggle("Frost walker enchantment is", ConfigEntry.ALLOW_FROSTWALKER); + case "fireplace" -> toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE); + case "lavaplace" -> toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE); + case "fluidspread" -> toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD); + case "lavadmg" -> toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE); + case "firespread" -> { toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD); plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean()); - break; } - - case "prelog": - { - toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG); - break; - } - - case "lockdown": + case "prelog" -> toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG); + case "lockdown" -> { boolean active = !LoginProcess.isLockdownEnabled(); LoginProcess.setLockdownEnabled(active); FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true); - break; } - - case "petprotect": - { - toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT); - break; - } - - case "entitywipe": - { - toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE); - break; - } - - case "firework": - { - toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION); - break; - } - - case "nonuke": + case "petprotect" -> toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT); + case "entitywipe" -> toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE); + case "firework" -> toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION); + case "nonuke" -> { if (args.length >= 2) { @@ -123,7 +70,7 @@ public class Command_toggle extends FreedomCommand } catch (NumberFormatException ex) { - msg("The input provided is not a valid integer."); + msg("The input provided is not a valid integer."); return true; } } @@ -136,7 +83,7 @@ public class Command_toggle extends FreedomCommand } catch (NumberFormatException ex) { - msg("The input provided is not a valid integer."); + msgNew("The input provided is not a valid integer."); return true; } } @@ -145,13 +92,11 @@ public class Command_toggle extends FreedomCommand if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean()) { - msg("Anti-freecam range is set to " + ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks."); - msg("Block throttle rate is set to " + ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds."); + msgNew("Anti-freecam range is set to blocks.", Placeholder.unparsed("range", String.valueOf(ConfigEntry.NUKE_MONITOR_RANGE.getDouble()))); + msgNew("Block throttle rate is set to blocks destroyed per 5 seconds.", Placeholder.unparsed("count", String.valueOf(ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger()))); } - break; } - - case "explosives": + case "explosives" -> { if (args.length == 2) { @@ -161,7 +106,7 @@ public class Command_toggle extends FreedomCommand } catch (NumberFormatException ex) { - msg("The input provided is not a valid integer."); + msg("The input provided is not a valid integer."); return true; } } @@ -170,120 +115,29 @@ public class Command_toggle extends FreedomCommand if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { - msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble()); + msgNew("Radius set to .", Placeholder.unparsed("radius", String.valueOf(ConfigEntry.EXPLOSIVE_RADIUS.getDouble()))); } - break; } - - case "unsafeenchs": - { - toggle("Unsafe enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS); - break; - } - - case "bells": - { - toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS); - break; - } - - case "armorstands": - { - toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS); - break; - } - - case "masterblocks": - { - toggle("Master blocks are", ConfigEntry.ALLOW_MASTERBLOCKS); - break; - } - - case "books": - { - toggle("Books are", ConfigEntry.ALLOW_BOOKS); - break; - } - - case "grindstones": - { - toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES); - break; - } - - case "jukeboxes": - { - toggle("Jukeboxes are", ConfigEntry.ALLOW_JUKEBOXES); - break; - } - - case "spawners": - { - toggle("Spawners are", ConfigEntry.ALLOW_SPAWNERS); - break; - } - - case "4chan": - { - toggle("4chan mode is", ConfigEntry.FOURCHAN_ENABLED); - break; - } - - case "beehives": - { - toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES); - break; - } - - case "respawnanchors": - { - toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS); - break; - } - - case "autotp": - { - toggle("Teleportation on join is", ConfigEntry.AUTO_TP); - break; - } - - case "autoclear": - { - toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR); - break; - } - - case "minecarts": - { - toggle("Minecarts are", ConfigEntry.ALLOW_MINECARTS); - break; - } - - case "landmines": - { - toggle("Landmines are", ConfigEntry.LANDMINES_ENABLED); - break; - } - - case "mp44": - { - toggle("MP44 is", ConfigEntry.MP44_ENABLED); - break; - } - - case "tossmob": - { - toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED); - break; - } - - case "gravity": - { - toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY); - break; - } - - default: + case "unsafeenchs" -> toggle("Unsafe enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS); + case "bells" -> toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS); + case "armorstands" -> toggle("The placement of armor stands is", ConfigEntry.ALLOW_ARMOR_STANDS); + case "masterblocks" -> toggle("Master blocks are", ConfigEntry.ALLOW_MASTERBLOCKS); + case "books" -> toggle("Books are", ConfigEntry.ALLOW_BOOKS); + case "grindstones" -> toggle("Grindstones are", ConfigEntry.ALLOW_GRINDSTONES); + case "jukeboxes" -> toggle("Jukeboxes are", ConfigEntry.ALLOW_JUKEBOXES); + case "spawners" -> toggle("Spawners are", ConfigEntry.ALLOW_SPAWNERS); + case "4chan" -> toggle("4chan mode is", ConfigEntry.FOURCHAN_ENABLED); + case "beehives" -> toggle("Beehives are", ConfigEntry.ALLOW_BEEHIVES); + case "respawnanchors" -> toggle("Respawn anchors are", ConfigEntry.ALLOW_RESPAWN_ANCHORS); + case "autotp" -> toggle("Teleportation on join is", ConfigEntry.AUTO_TP); + case "autoclear" -> toggle("Clearing inventories on join is", ConfigEntry.AUTO_CLEAR); + case "minecarts" -> toggle("Minecarts are", ConfigEntry.ALLOW_MINECARTS); + case "landmines" -> toggle("Landmines are", ConfigEntry.LANDMINES_ENABLED); + case "mp44" -> toggle("MP44 is", ConfigEntry.MP44_ENABLED); + case "tossmob" -> toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED); + case "gravity" -> toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY); + case "chat" -> toggle("Chat is", ConfigEntry.TOGGLE_CHAT); + default -> { msg("Available toggles: "); for (String toggle : toggles) @@ -315,7 +169,7 @@ public class Command_toggle extends FreedomCommand "waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk", "firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs", "bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives", - "respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity"); + "respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity", "chat"); } return Collections.emptyList(); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java deleted file mode 100644 index c2f19d3f..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java +++ /dev/null @@ -1,21 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.FUtil; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) -@CommandParameters(description = "Toggle online players' ability to chat.", usage = "/", aliases = "tc") -public class Command_togglechat extends FreedomCommand -{ - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - ConfigEntry.TOGGLE_CHAT.setBoolean(!ConfigEntry.TOGGLE_CHAT.getBoolean()); - FUtil.adminAction(sender.getName(), "Chat " + (ConfigEntry.TOGGLE_CHAT.getBoolean() ? "enabled" : "disabled") + ".", true); - return true; - } -} \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java index d7109947..0f8c997a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java @@ -21,7 +21,7 @@ public class Command_tprandom extends FreedomCommand int y = playerSender.getWorld().getHighestBlockYAt(x, z) + 1; Location location = new Location(playerSender.getLocation().getWorld(), x, y, z); PaperLib.teleportAsync(playerSender, location); - msg("Poof!", ChatColor.GREEN); + msgNew("Poof!"); return true; } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java index b749a1a3..b2dd23c9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java @@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.api.ShopItem; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -15,26 +16,27 @@ public class Command_trail extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (plugin.sh == null) { - msg("Shop is not enabled.", ChatColor.RED); + if (plugin.sh == null) + { + msgNew("Shop is not enabled."); return true; } if (!plugin.pl.getData(playerSender).hasItem(ShopItem.RAINBOW_TRAIL)) { - msg("You didn't purchase the ability to have a " + ShopItem.RAINBOW_TRAIL.getName() + "! Purchase it from the shop.", ChatColor.RED); + msgNew("You didn't purchase the ability to have a ! Purchase it from the shop.",Placeholder.unparsed("item", ShopItem.RAINBOW_TRAIL.getName())); return true; } if (plugin.tr.contains(playerSender)) { plugin.tr.remove(playerSender); - msg("Trail disabled."); + msgNew("Trail disabled."); } else { plugin.tr.add(playerSender); - msg("Trail enabled. Run this command again to disable it."); + msgNew("Trail enabled. Run this command again to disable it."); } return true; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java index bd31ae55..83bbffcc 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java @@ -160,11 +160,6 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter msg(color + message); } - protected void msg(String message, net.md_5.bungee.api.ChatColor color) - { - msg(color + message); - } - protected boolean isAdmin(Player player) { return plugin.al.isAdmin(player); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java new file mode 100644 index 00000000..88d7e438 --- /dev/null +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java @@ -0,0 +1,2 @@ +package me.totalfreedom.totalfreedommod.util;public class FConverter { +}