From 2ae6522f996399b8f298ae0269c9150d5c722058 Mon Sep 17 00:00:00 2001 From: Mari Date: Sun, 18 Oct 2020 05:20:14 -0400 Subject: [PATCH] Use UUIDs instead of names --- .../minecraftportal/MinecraftPortalPlugin.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt b/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt index b8c403b..ed8bbc0 100644 --- a/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt +++ b/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt @@ -26,6 +26,7 @@ import org.bukkit.event.player.PlayerMoveEvent import org.bukkit.plugin.java.JavaPlugin import org.bukkit.potion.PotionEffectType import java.lang.IllegalStateException +import java.util.* class MinecraftPortalPlugin() : JavaPlugin(), Listener { @@ -76,7 +77,7 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener argsList[0] } sender is Player -> { - sender.name + sender.uniqueId.toString() } else -> { null @@ -87,10 +88,11 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener return false } if (colorString == "show") { - if (sender is Player && playerString == sender.name) { + if (sender is Player && playerString == sender.uniqueId.toString()) { sender.sendMessage("Portals you create are marked with ${portals.getColorFor(playerString).name}.") } else { - sender.sendMessage("Portals created by $playerString are marked with ${portals.getColorFor(playerString).name}.") + val name = server.getOfflinePlayer(UUID.fromString(playerString)).name + sender.sendMessage("Portals created by $name are marked with ${portals.getColorFor(playerString).name}.") } return true } @@ -104,7 +106,7 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener return false } portals.setColorFor(playerString, color) - if (sender is Player && playerString == sender.name) { + if (sender is Player && playerString == sender.uniqueId.toString()) { sender.sendMessage("Your portals will now be marked with ${portals.getColorFor(playerString).name}.") } else { sender.sendMessage("Portals created by $playerString will now be marked with ${portals.getColorFor(playerString).name}") @@ -122,7 +124,7 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener ) if (newPortal != null) { if (newPortal.color == Material.GLASS) { - newPortal.color = portals.getColorFor(e.player.name) + newPortal.color = portals.getColorFor(e.player.uniqueId.toString()) } val replacedPortal = portals.activateAndReplacePortal(newPortal) val otherPortal = portals.getOtherPortal(newPortal)