Commit 2bad09cc authored by Linus K.'s avatar Linus K.
Browse files

Add clickable buttons to tpa

parent 8371c333
......@@ -5,6 +5,11 @@ import me.linuscde.mcplugins.teleportastic.utils.homes
import me.linuscde.mcplugins.teleportastic.utils.lastLocation
import me.linuscde.mcplugins.teleportastic.utils.teleportTo
import me.linuscde.mcplugins.teleportastic.utils.teleportToLast
import net.md_5.bungee.api.ChatColor
import net.md_5.bungee.api.chat.ClickEvent
import net.md_5.bungee.api.chat.HoverEvent
import net.md_5.bungee.api.chat.TextComponent
import net.md_5.bungee.api.chat.hover.content.Text
import org.bukkit.Bukkit
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
......@@ -35,8 +40,22 @@ class TpaCommand: CommandExecutor {
val req = TpaRequest(sender, requested, System.currentTimeMillis() + REQUEST_DURATION)
REQUESTS.add(req)
sender.sendMessage("${Plugin.prefix} §6Teleport request sent to §c${requested.name}§6.")
requested.sendMessage("${Plugin.prefix} §e${sender.name}§6 requested to teleport to you.")
requested.sendMessage("${Plugin.prefix} §6You can accept this with §c/tpaccept §a or deny it with §c/tpdeny§a.")
val choiceMessage = TextComponent()
for(comp in TextComponent.fromLegacyText("${Plugin.prefix} §e${sender.name}§6 requested to teleport to you. "))
choiceMessage.addExtra(comp)
val accept = TextComponent("[Accept]")
accept.color = ChatColor.DARK_GREEN
accept.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§6Click to accept §e${sender.name}§6's request.\n§7/tpaccept"))
accept.clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/${Plugin.instance.name}:tpaccept")
val deny = TextComponent("[Deny]")
deny.color = ChatColor.DARK_RED
deny.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text("§6Click to deny §e${sender.name}§6's request.\n§7/tpdeny"))
deny.clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/${Plugin.instance.name}:tpdeny")
choiceMessage.addExtra(accept)
choiceMessage.addExtra(" ")
choiceMessage.addExtra(deny)
requested.spigot().sendMessage(choiceMessage)
return true
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment