From e06ee55259b3549a59358a13c095a274bacf6a05 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 30 Dec 2023 14:24:46 -0500 Subject: testing new version --- .../java/net/benjidial/nswp/commands/AllowTPA.java | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/net/benjidial/nswp/commands/AllowTPA.java (limited to 'src/main/java/net/benjidial/nswp/commands/AllowTPA.java') diff --git a/src/main/java/net/benjidial/nswp/commands/AllowTPA.java b/src/main/java/net/benjidial/nswp/commands/AllowTPA.java new file mode 100644 index 0000000..80ecd2d --- /dev/null +++ b/src/main/java/net/benjidial/nswp/commands/AllowTPA.java @@ -0,0 +1,39 @@ +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 AllowTPA extends PlayerCommand { + + public List getTabCompletions(Player sender, String[] args) throws SQLException { + return filterByArg(Database.getOnlineTPADisallowedTo(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(other, sender)) { + sender.sendMessage(other.getName() + " is already allowed to teleport to you."); + return true; + } + + Database.allowTPA(other, sender); + sender.sendMessage(other.getName() + " is now allowed to teleport to you."); + return true; + + } + +} -- cgit v1.2.3