From 4f41e24da54838b211ae522ee07550cde0920998 Mon Sep 17 00:00:00 2001 From: Aria Date: Fri, 3 Mar 2023 12:16:03 -0700 Subject: [PATCH] Finish migrating messages --- gradle.properties | 2 +- .../dev/zontreck/essentials/Messages.java | 20 +++++++++++++++++++ .../commands/homes/DelHomeCommand.java | 7 ++----- .../commands/homes/HomeCommand.java | 7 ++----- .../commands/homes/HomesCommand.java | 16 +++------------ 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2c6f8a2..0bd90cb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -my_version=1.0.0.0302231751 +my_version=1.0.0.0303231214 my_modgroup=dev.zontreck.essentials my_modid=ariasessentials diff --git a/src/main/java/dev/zontreck/essentials/Messages.java b/src/main/java/dev/zontreck/essentials/Messages.java index 0133a7f..eb7bfc4 100644 --- a/src/main/java/dev/zontreck/essentials/Messages.java +++ b/src/main/java/dev/zontreck/essentials/Messages.java @@ -47,8 +47,18 @@ public class Messages { public static final String NO_MORE_THAN_ONE_TPA; public static final String TPA; + public static final String HOME_FORMAT; + public static final String HOME_HOVER_TEXT; + public static final String HOME_COUNT; + public static final String TELEPORT_REQUEST_ACCEPTED; + public static final String TELEPORTING_HOME; + public static final String TELEPORT_HOME_FAIL; + + public static final String HOME_DELETE_SUCCESS; + public static final String HOME_DELETE_FAIL; + static{ ESSENTIALS_PREFIX = "!Gray![!Dark_Green!AE!Gray!] "; @@ -101,5 +111,15 @@ public class Messages { NO_MORE_THAN_ONE_TPA = ESSENTIALS_PREFIX + "!Dark_Red!You already have a TPA Request active, wait for it to expire, or use the cancel button/command"; TPA = "[0] !Bold!!Dark_Purple! is requesting to teleport to you!\n\n"; + + HOME_FORMAT = "!Dark_Gray![!Gold!Home!Dark_Gray!]!Bold!!Dark_Purple![0]"; + HOME_HOVER_TEXT = "!Bold!!Dark_Green!Click here to go to this home"; + HOME_COUNT = ESSENTIALS_PREFIX + "!Bold!!Dark_Purple!You have [0] total homes."; + + TELEPORTING_HOME = ESSENTIALS_PREFIX + "!Dark_Green!Teleporting home now!"; + TELEPORT_HOME_FAIL = ESSENTIALS_PREFIX + "!Dark_Red!Home not found"; + + HOME_DELETE_FAIL = ESSENTIALS_PREFIX + "!Dark_Red!Home could not be deleted due to an unknown error"; + HOME_DELETE_SUCCESS = ESSENTIALS_PREFIX + "!Dark_Green!Home was successfully deleted"; } } diff --git a/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java b/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java index e4c77ff..1c61725 100644 --- a/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java @@ -5,13 +5,10 @@ import com.mojang.brigadier.arguments.StringArgumentType; import dev.zontreck.essentials.AriasEssentials; import dev.zontreck.essentials.Messages; -import dev.zontreck.libzontreck.chat.ChatColor; -import dev.zontreck.libzontreck.profiles.Profile; import dev.zontreck.libzontreck.util.ChatHelpers; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.network.chat.TextComponent; public class DelHomeCommand { public static void register(CommandDispatcher dispatcher) @@ -37,12 +34,12 @@ public class DelHomeCommand { AriasEssentials.player_homes.get(p.getUUID()).delete(homeName); - ChatHelpers.broadcastTo(p, new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.doColors("!dark_green!Home was deleted successfully")), ctx.getServer()); + ChatHelpers.broadcastTo(p, ChatHelpers.macro(Messages.HOME_DELETE_SUCCESS), ctx.getServer()); }catch(Exception e) { e.printStackTrace(); - ChatHelpers.broadcastTo(ctx.getEntity().getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.doColors("!dark_red!Home could not be deleted due to an unknown error")), ctx.getServer()); + ChatHelpers.broadcastTo(ctx.getEntity().getUUID(), ChatHelpers.macro(Messages.HOME_DELETE_FAIL), ctx.getServer()); } return 0; } diff --git a/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java b/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java index 693b10e..225620e 100644 --- a/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java @@ -11,13 +11,10 @@ import dev.zontreck.essentials.commands.teleport.TeleportContainer; import dev.zontreck.essentials.commands.teleport.TeleportDestination; import dev.zontreck.essentials.homes.Home; import dev.zontreck.essentials.homes.NoSuchHomeException; -import dev.zontreck.libzontreck.chat.ChatColor; -import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException; import dev.zontreck.libzontreck.util.ChatHelpers; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.network.chat.TextComponent; public class HomeCommand { public static void register(CommandDispatcher dispatcher) @@ -46,7 +43,7 @@ public class HomeCommand { TeleportContainer cont = new TeleportContainer(p, dest.Position.asMinecraftVector(), dest.Rotation.asMinecraftVector(), dest.getActualDimension()); TeleportActioner.PerformTeleport(cont); - ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.doColors("!dark_green!Home found! Wormhole opening now...")), ctx.getServer()); + ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(Messages.TELEPORTING_HOME), ctx.getServer()); }catch(CommandSyntaxException e) { e.printStackTrace(); @@ -54,7 +51,7 @@ public class HomeCommand { }catch(NoSuchHomeException e) { - ChatHelpers.broadcastTo(ctx.getEntity().getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.doColors(" !dark_red!Home not found. Maybe it does not exist?")), ctx.getServer()); + ChatHelpers.broadcastTo(ctx.getEntity().getUUID(), ChatHelpers.macro(Messages.TELEPORT_HOME_FAIL), ctx.getServer()); return 0; } diff --git a/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java b/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java index fefb94e..683d66c 100644 --- a/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java @@ -1,12 +1,5 @@ package dev.zontreck.essentials.commands.homes; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; - import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -15,16 +8,13 @@ import dev.zontreck.essentials.AriasEssentials; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.homes.Home; import dev.zontreck.essentials.homes.Homes; -import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.chat.Clickable; import dev.zontreck.libzontreck.chat.HoverTip; import dev.zontreck.libzontreck.util.ChatHelpers; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; public class HomesCommand { public static void register(CommandDispatcher dispatcher) @@ -40,13 +30,13 @@ public class HomesCommand { Homes homes = AriasEssentials.player_homes.get(player.getUUID()); - ChatHelpers.broadcastTo(player.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.doColors(" !Dark_Purple!There are !gold!"+String.valueOf(homes.count())+" !dark_purple!total homes.")), player.server); + ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HOME_COUNT, String.valueOf(homes.count())), player.server); for (Home string : homes.getList()) { - Style st = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.BOLD+ChatColor.DARK_GREEN+"Click here to go to this home")).withClickEvent(Clickable.command("/home "+string.homeName)); + Style st = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatHelpers.macroize(Messages.HOME_HOVER_TEXT))).withClickEvent(Clickable.command("/home "+string.homeName)); - ChatHelpers.broadcastTo(player.getUUID(), new TextComponent(ChatColor.BOLD + ChatColor.MINECOIN_GOLD+"["+ChatColor.resetChat()+ChatColor.UNDERLINE+ChatColor.BOLD+ChatColor.DARK_GREEN+"HOME"+ChatColor.resetChat()+ChatColor.BOLD+ChatColor.MINECOIN_GOLD+"] "+ChatColor.resetChat()+ChatColor.YELLOW+string.homeName).setStyle(st), ctx.getSource().getServer()); + ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HOME_FORMAT, string.homeName).setStyle(st), ctx.getSource().getServer()); } }catch(CommandSyntaxException ex)