From 5350242f97d36cfdd8fee4262e136540970d773a Mon Sep 17 00:00:00 2001 From: ciomek Date: Wed, 24 Jun 2026 18:44:00 +0200 Subject: [PATCH] Fixes and colors --- src/main/java/ciomek/quetzal/Utils.java | 24 +++++++++++++++---- .../ciomek/quetzal/commands/HomeCommand.java | 14 +++++------ .../quetzal/commands/TeleportCommand.java | 17 ++++++------- .../quetzal/teleport/TeleportFromRequest.java | 4 ++-- .../quetzal/teleport/TeleportToRequest.java | 4 ++-- 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/main/java/ciomek/quetzal/Utils.java b/src/main/java/ciomek/quetzal/Utils.java index 3d2fd63..420c2c0 100644 --- a/src/main/java/ciomek/quetzal/Utils.java +++ b/src/main/java/ciomek/quetzal/Utils.java @@ -5,24 +5,40 @@ import net.minecraft.core.entity.player.Player; import net.minecraft.server.entity.player.PlayerServer; public class Utils { + public static String msg(String body) { + return "§6[Quetzal]§r " + body; + } + + public static String highlight(String text) { + return "§e" + text + "§r"; + } + + public static String success(String text) { + return "§a" + text + "§r"; + } + + public static String error(String text) { + return "§c" + text + "§r"; + } + public static void TeleportPlayer(Player fromPlayer, Player toPlayer, TickTimer timer) { double startX = round1(fromPlayer.x); double startY = round1(fromPlayer.y); double startZ = round1(fromPlayer.z); - fromPlayer.sendMessage("Teleporting home. Don't move for 5 seconds..."); + fromPlayer.sendMessage(msg("Teleporting to " + highlight(toPlayer.username) + ". " + error("Don't move for 5 seconds..."))); timer.addTickTask(100, (world) -> { if (round1(fromPlayer.x) != startX || round1(fromPlayer.y) != startY || round1(fromPlayer.z) != startZ) { - fromPlayer.sendMessage("Teleport cancelled because you moved."); + fromPlayer.sendMessage(msg(error("Teleport cancelled") + " because you moved.")); return; } ((PlayerServer)fromPlayer).playerNetServerHandler.teleportAndRotate(toPlayer.x, toPlayer.y, toPlayer.z, toPlayer.yRot, toPlayer.xRot); - fromPlayer.sendMessage("Teleported to " + toPlayer.username + "!"); - toPlayer.sendMessage(fromPlayer.username + " teleported to you!"); + fromPlayer.sendMessage(msg(success("Teleported") + " to " + highlight(toPlayer.username) + "!")); + toPlayer.sendMessage(msg(highlight(fromPlayer.username) + " teleported to you!")); }); } diff --git a/src/main/java/ciomek/quetzal/commands/HomeCommand.java b/src/main/java/ciomek/quetzal/commands/HomeCommand.java index 4c127bf..6159d97 100644 --- a/src/main/java/ciomek/quetzal/commands/HomeCommand.java +++ b/src/main/java/ciomek/quetzal/commands/HomeCommand.java @@ -60,13 +60,13 @@ public class HomeCommand implements CommandManager.CommandRegistry, ModInitializ Player player = source.getSender(); if (player == null) { - source.sendMessage("This command can only be run by a player!"); + source.sendMessage(Utils.msg(Utils.error("This command can only be run by a player!"))); return 0; } homes.put(player.username, new double[]{player.x, player.y, player.z}); saveHomes(); - player.sendMessage("Home set."); + player.sendMessage(Utils.msg(Utils.success("Home set."))); return 1; }) ); @@ -80,14 +80,14 @@ public class HomeCommand implements CommandManager.CommandRegistry, ModInitializ IWorldUtils worldUtils = (IWorldUtils) source.getWorld(); if (player == null) { - source.sendMessage("This command can only be run by a player!"); + source.sendMessage(Utils.msg(Utils.error("This command can only be run by a player!"))); return 0; } if (!homes.containsKey(player.username)) { homes.put(player.username, new double[]{player.x, player.y, player.z}); saveHomes(); - player.sendMessage("Home was not set. Setting it to your current location."); + player.sendMessage(Utils.msg(Utils.highlight("Home") + " was not set. Setting it to your " + Utils.highlight("current location") + ".")); return 1; } @@ -97,16 +97,16 @@ public class HomeCommand implements CommandManager.CommandRegistry, ModInitializ double startY = Utils.round1(player.y); double startZ = Utils.round1(player.z); - player.sendMessage("Teleporting home. Don't move for 5 seconds..."); + player.sendMessage(Utils.msg("Teleporting " + Utils.highlight("home") + ". " + Utils.error("Don't move for 5 seconds..."))); worldUtils.addTickCallback(100, (w) -> { if (Utils.round1(player.x) != startX || Utils.round1(player.y) != startY || Utils.round1(player.z) != startZ) { - player.sendMessage("Teleport cancelled because you moved."); + player.sendMessage(Utils.msg(Utils.error("Teleport cancelled") + " because you moved.")); return; } ((PlayerServer)player).playerNetServerHandler.teleport(home[0], home[1], home[2]); - player.sendMessage("Teleported home."); + player.sendMessage(Utils.msg(Utils.success("Teleported home."))); }); return 1; diff --git a/src/main/java/ciomek/quetzal/commands/TeleportCommand.java b/src/main/java/ciomek/quetzal/commands/TeleportCommand.java index d76634b..2cf78a4 100644 --- a/src/main/java/ciomek/quetzal/commands/TeleportCommand.java +++ b/src/main/java/ciomek/quetzal/commands/TeleportCommand.java @@ -1,6 +1,7 @@ package ciomek.quetzal.commands; import ciomek.quetzal.IWorldUtils; +import ciomek.quetzal.Utils; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.ArgumentBuilderLiteral; import com.mojang.brigadier.builder.ArgumentBuilderRequired; @@ -28,7 +29,7 @@ public class TeleportCommand implements CommandManager.CommandRegistry { EntitySelector entitySelector = context.getArgument("player", EntitySelector.class); if (entitySelector.get(source).isEmpty()) { - source.sendMessage("None selected!"); + source.sendMessage(Utils.msg(Utils.error("None selected!"))); return 0; } @@ -39,15 +40,15 @@ public class TeleportCommand implements CommandManager.CommandRegistry { IWorldUtils worldUtils = (IWorldUtils) source.getWorld(); if (player == null) { - source.sendMessage("This command can only be run by a player!"); + source.sendMessage(Utils.msg(Utils.error("This command can only be run by a player!"))); return 0; } worldUtils.addRequestToTeleportTo(player, target); - player.sendMessage("Sent request to " + target.username + "."); + player.sendMessage(Utils.msg("Sent request to " + Utils.highlight(target.username) + ".")); - target.sendMessage("Do you want " + target.username + " to teleport to you?"); + target.sendMessage(Utils.msg("Do you want " + Utils.highlight(player.username) + " to teleport to you?")); return 1; }) ) @@ -64,7 +65,7 @@ public class TeleportCommand implements CommandManager.CommandRegistry { EntitySelector entitySelector = context.getArgument("player", EntitySelector.class); if (entitySelector.get(source).isEmpty()) { - source.sendMessage("None selected!"); + source.sendMessage(Utils.msg(Utils.error("None selected!"))); return 0; } @@ -75,15 +76,15 @@ public class TeleportCommand implements CommandManager.CommandRegistry { IWorldUtils worldUtils = (IWorldUtils) source.getWorld(); if (player == null) { - source.sendMessage("This command can only be run by a player!"); + source.sendMessage(Utils.msg(Utils.error("This command can only be run by a player!"))); return 0; } worldUtils.addRequestToTeleportFrom(player, target); - player.sendMessage("Sent request to " + target.username + "."); + player.sendMessage(Utils.msg("Sent request to " + Utils.highlight(target.username) + ".")); - target.sendMessage("Do you want to teleport to " + target.username + "?"); + target.sendMessage(Utils.msg("Do you want " + Utils.highlight(player.username) + " to teleport to you?")); return 1; }) ) diff --git a/src/main/java/ciomek/quetzal/teleport/TeleportFromRequest.java b/src/main/java/ciomek/quetzal/teleport/TeleportFromRequest.java index 9428cee..b676285 100644 --- a/src/main/java/ciomek/quetzal/teleport/TeleportFromRequest.java +++ b/src/main/java/ciomek/quetzal/teleport/TeleportFromRequest.java @@ -13,12 +13,12 @@ public class TeleportFromRequest extends TeleportRequest { public void accept(TickTimer timer) { - sender.sendMessage(receiver.username + " has accepted the teleportation request. "); + sender.sendMessage(Utils.msg(Utils.highlight(receiver.username) + " has " + Utils.success("accepted") + " the teleportation request.")); Utils.TeleportPlayer(receiver, sender, timer); } public void decline() { - sender.sendMessage(receiver.username + " has declined the teleportation request. "); + sender.sendMessage(Utils.msg(Utils.highlight(receiver.username) + " has " + Utils.error("declined") + " the teleportation request.")); } } diff --git a/src/main/java/ciomek/quetzal/teleport/TeleportToRequest.java b/src/main/java/ciomek/quetzal/teleport/TeleportToRequest.java index 4ad70a8..0192fd5 100644 --- a/src/main/java/ciomek/quetzal/teleport/TeleportToRequest.java +++ b/src/main/java/ciomek/quetzal/teleport/TeleportToRequest.java @@ -13,12 +13,12 @@ public class TeleportToRequest extends TeleportRequest { public void accept(TickTimer timer) { - sender.sendMessage(receiver.username + " has accepted the teleportation request. "); + sender.sendMessage(Utils.msg(Utils.highlight(receiver.username) + " has " + Utils.success("accepted") + " the teleportation request.")); Utils.TeleportPlayer(sender, receiver, timer); } public void decline() { - sender.sendMessage(receiver.username + " has declined the teleportation request. "); + sender.sendMessage(Utils.msg(Utils.highlight(receiver.username) + " has " + Utils.error("declined") + " the teleportation request.")); } }