Added confirmation for tping when out of spec.

master
Joey Hines 2018-09-22 14:18:06 -05:00
parent 669e507b03
commit a548ef779a
1 changed files with 19 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -12,6 +13,7 @@ import xyz.etztech.core.CoreUtils;
import xyz.etztech.core.web.CoreWeb;
import xyz.etztech.qol.QoL;
import xyz.etztech.qol.other.LinkCommand;
;import xyz.etztech.qol.EtzTechUtil;
import java.util.HashMap;
import java.util.Map;
@ -20,6 +22,7 @@ public class CommandPreprocessListener implements Listener {
QoL plugin;
Map<Player, String> confirm_tp = new HashMap<>();
public CommandPreprocessListener(QoL plugin) {
this.plugin = plugin;
@ -50,6 +53,22 @@ public class CommandPreprocessListener implements Listener {
if (StringUtils.isNotEmpty(webhook)) {
CoreWeb.asyncPost(plugin, webhook, post);
}
if (base.equals("tp")) {
if (command.equals(confirm_tp.get(sender))) {
confirm_tp.remove(sender);
}
else if (sender.getGameMode() != GameMode.SPECTATOR) {
event.setCancelled(true);
TextComponent message = new TextComponent(ChatColor.GREEN + "You are TPing out of spec, run command again to confirm.");
confirm_tp.remove(sender);
confirm_tp.put(sender, command);
sender.spigot().sendMessage(message);
}
}
}
}