Solved ClickTP simple skript - Click on chat to /tpaccept or /tpdeny

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Pie3

New Member
Nov 16, 2018
6
0
0
25
Category: Teleportation
Suggested name: ClickTP
What I want:
I want a plugin that will replace the essentialsX /tpa and /tpahere messages with clickable [accept] and [deny] buttons that will run the /tpaccept and /tpdeny commands.
I have removed the essentials messages in the messages_en.properties config, so now all is left is for /tpa and /tpahere to send the specified message.
aZwOUrd.png

When you click [accept] it will run command /tpaccept
When you click [deny] it will run command /tpdeny
When you point at them, there should be a tooltip message.

Be cautious of the following things:
Make sure it doesn't send the message if you tpa to yourself.
Make sure it doesn't send the message to the other player if he has essentialsX tptoggle on disabled.
Make sure otherplayer doesn't have a tp request already that isn't expired or canceled from the same person.

My attempt:
code_language.skript:
import:
import:
    org.bukkit.Bukkit
on load:
    set {Essentials} to Bukkit.getServer().getPluginManager().getPlugin("Essentials")
# {Essentials}.getUser(arg-1).requestAlreadySent(player)
command /ptpa <player>:
    permission: essentials.tpa
    aliases: /pcall
    trigger:
        set {_tptoggle} to value of placeholder "essentials_is_teleport_enabled" from arg-1
        if arg-1 is player:
            send "&cYou cannot teleport to yourself." to player
        else if {_tptoggle} is "no":
            send "&c%arg-1% has teleportation disabled." to player
        else:
            send "&b%player% &9requests to teleport to you. &a<ttp:&9Click to &aaccept &9most recent teleport request.><cmd:/tpaccept>[Accept]<reset> &c<ttp:&9Click to &cdeny &9most recent teleport request.><cmd:/tpdeny>[Deny]<reset>" to arg-1
            send "&aSent request to &f%arg-1%&a." to player
I can't figure out how to import and use requestSentAlready from essentials
and instead of sending message on if and elseif i want it to do nothing

addons I used: skript mirror + erstatz

Ideas for permissions:
No permissions.
When I'd like it by: Hopefully less than a month, not important when
[doublepost=1542659884,1542414305][/doublepost]



UPDATE

Alright after a lot of struggle and support from
discord this is my final command, if anyone wants to use it feel free, please let me know so I can feel proud of myself.

Requirements: Ersatz addon, essentialsX plugin, placeholderAPI plugin, skriptmirror addon

1. delete these from essentialsX messages_en.properties config:
teleportHereRequest=
teleportRequest=
teleportRequestTimeoutInfo=
typeTpaccept=
typeTpdeny=

2. change /tpa and /tpahere aliases to neverusethiscommand and neverusethiscommand2 inside the essentials jar in plugin.yml


3. use my skript:

code_language.skript:
import:
    org.bukkit.Bukkit
command /tpa [<text>]:
    permission: essentials.tpa
    aliases: /pcall, ptpask
    trigger:
        if length of arg-1 < 16:
            if arg-1 parsed as player is online:
                set {_arg1} to arg-1 parsed as player
                set {_tptoggle} to value of placeholder "essentials_is_teleport_enabled" from {_arg1}
                set {_Essentials} to Bukkit.getServer().getPluginManager().getPlugin("Essentials")
                set {_uuid} to uuid of player
                set {_alreadysent} to {_Essentials}.getUser({_arg1}).getTeleportRequest()
                if {_arg1} is player:
                    send "&cYou cannot teleport to yourself." to player
                else if {_tptoggle} is "no":
                    send "&c%arg-1% has teleportation disabled." to player
                else if "%{_alreadysent}%" = "%{_uuid}%":
                    send "&cYou have already sent a teleport request to &7%{_arg1}%&c."
                else:
                    execute player command "/neverusethiscommand %arg-1%"
                    send "&b%player% &9requests to teleport to you. &a<ttp:&9Click to &aaccept &9most recent teleport request.><cmd:/tpaccept>[Accept]<reset> &c<ttp:&9Click to &cdeny &9most recent teleport request.><cmd:/tpdeny>[Deny]<reset>" to {_arg1}
            else:
                send "&cPlayer not found." to player
        else if arg-1 is not set:
            send "&7Usage: /tpa <player>" to player
        else:
            send "&cPlayer not found." to player
command /tpahere [<text>]:
    permission: essentials.tpahere
    aliases: /askhere, teleporthere
    trigger:
        if length of arg-1 < 16:
            if arg-1 parsed as player is online:
                set {_arg1h} to arg-1 parsed as player
                set {_tptoggleh} to value of placeholder "essentials_is_teleport_enabled" from {_arg1h}
                set {_Essentials} to Bukkit.getServer().getPluginManager().getPlugin("Essentials")
                set {_uuidh} to uuid of player
                set {_alreadysenth} to {_Essentials}.getUser({_arg1h}).getTeleportRequest()
                if {_arg1h} is player:
                    send "&cYou cannot teleport to yourself." to player
                else if {_tptoggleh} is "no":
                    send "&c%arg-1% has teleportation disabled." to player
                else if "%{_alreadysenth}%" = "%{_uuidh}%":
                    send "&cYou have already sent a teleport request to &7%{_arg1h}%&c."
                else:
                    execute player command "/neverusethiscommand2 %arg-1%"
                    send "&b%player% &9requests you teleport to them. &a<ttp:&9Click to &aaccept &9most recent teleport request.><cmd:/tpaccept>[Accept]<reset> &c<ttp:&9Click to &cdeny &9most recent teleport request.><cmd:/tpdeny>[Deny]<reset>" to {_arg1h}
            else:
                send "&cPlayer not found." to player
        else if arg-1 is not set:
            send "&7Usage: /tpahere <player>" to player
        else:
            send "&cPlayer not found." to player

if you have any advice/suggestions for my skript please tell me since i am very new to this community!
 
Last edited: