diff options
author | Benji Dial <benji@benjidial.net> | 2023-12-30 14:24:46 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2023-12-30 14:24:46 -0500 |
commit | e06ee55259b3549a59358a13c095a274bacf6a05 (patch) | |
tree | a6e8b1b33434ee2c7de7028d4abad77b7fbe8296 /src/main/java/net/benjidial/nswp/commands/TPA.java | |
parent | ef65431d405a713b138a55054e78497883f27e54 (diff) | |
download | new-simple-waypoints-e06ee55259b3549a59358a13c095a274bacf6a05.tar.gz |
testing new version
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/TPA.java')
-rw-r--r-- | src/main/java/net/benjidial/nswp/commands/TPA.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/net/benjidial/nswp/commands/TPA.java b/src/main/java/net/benjidial/nswp/commands/TPA.java new file mode 100644 index 0000000..e160fc0 --- /dev/null +++ b/src/main/java/net/benjidial/nswp/commands/TPA.java @@ -0,0 +1,40 @@ +package net.benjidial.nswp.commands; + +import net.benjidial.nswp.Database; + +import org.bukkit.entity.Player; +import org.bukkit.Bukkit; + +import java.sql.SQLException; +import java.util.List; + +public class TPA extends PlayerCommand { + + public List<String> getTabCompletions(Player sender, String[] args) throws SQLException { + return filterByArg(Database.getOnlineTPAAllowedFrom(sender), args, 0); + } + + public boolean doCommand(Player sender, String[] args) throws SQLException { + + if (args.length != 1) + return false; + + Player other = Bukkit.getPlayer(args[0]); + if (other == null) { + sender.sendMessage("Could not find " + args[0] + ". Are they online?"); + return true; + } + + if (!Database.isTPAAllowed(sender, other)) { + sender.sendMessage("You are not allowed to teleport to " + other.getName() + "."); + sender.sendMessage("They must first run /wtpallow " + sender.getName()); + return true; + } + + Database.setWBack(sender, sender.getLocation()); + sender.teleport(other); + return true; + + } + +} |