1
0
Fork 0

Use UUIDs instead of names

main
Mari 4 years ago
parent f285fa37cc
commit 2ae6522f99
  1. 12
      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.plugin.java.JavaPlugin
import org.bukkit.potion.PotionEffectType import org.bukkit.potion.PotionEffectType
import java.lang.IllegalStateException import java.lang.IllegalStateException
import java.util.*
class MinecraftPortalPlugin() : JavaPlugin(), Listener class MinecraftPortalPlugin() : JavaPlugin(), Listener
{ {
@ -76,7 +77,7 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener
argsList[0] argsList[0]
} }
sender is Player -> { sender is Player -> {
sender.name sender.uniqueId.toString()
} }
else -> { else -> {
null null
@ -87,10 +88,11 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener
return false return false
} }
if (colorString == "show") { 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}.") sender.sendMessage("Portals you create are marked with ${portals.getColorFor(playerString).name}.")
} else { } 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 return true
} }
@ -104,7 +106,7 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener
return false return false
} }
portals.setColorFor(playerString, color) 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}.") sender.sendMessage("Your portals will now be marked with ${portals.getColorFor(playerString).name}.")
} else { } else {
sender.sendMessage("Portals created by $playerString will now be marked with ${portals.getColorFor(playerString).name}") 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 != null) {
if (newPortal.color == Material.GLASS) { 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 replacedPortal = portals.activateAndReplacePortal(newPortal)
val otherPortal = portals.getOtherPortal(newPortal) val otherPortal = portals.getOtherPortal(newPortal)

Loading…
Cancel
Save