diff --git a/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt b/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt index 3e12fc2..52b4f11 100644 --- a/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt +++ b/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt @@ -72,20 +72,29 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener } else { argsList[1] } - val playerString = when { + val playerString: String = when { argsList.size == 2 -> { - argsList[0] + val player = server.getPlayer(args[0]) + player?.uniqueId?.toString() + ?: try { + UUID.fromString(args[0]).toString() + } catch (ex: IllegalArgumentException) { + "bad UUID" + } } sender is Player -> { sender.uniqueId.toString() } else -> { - null + "console" } } - if (playerString == null) { + if (playerString == "console") { sender.sendMessage("Only players can set their own color with the one-arg form.") return false + } else if (playerString == "bad UUID") { + sender.sendMessage("You must pass a UUID or the name of an online player.") + return false } if (colorString == "show") { if (sender is Player && playerString == sender.uniqueId.toString()) { @@ -109,7 +118,8 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener 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}") + val name = server.getOfflinePlayer(UUID.fromString(playerString)).name + sender.sendMessage("Portals created by $name will now be marked with ${portals.getColorFor(playerString).name}") } return true }