From 5f55a90a7e3ef73feb659664b04279ba6623bc15 Mon Sep 17 00:00:00 2001 From: night0721 Date: Sun, 10 Jul 2022 22:33:56 +0100 Subject: [PATCH] ??? --- .../nullvalkyrie/commands/VanishCommand.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java diff --git a/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java b/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java new file mode 100644 index 0000000..186c347 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java @@ -0,0 +1,46 @@ +package com.night.nullvalkyrie.commands; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class VanishCommand extends Command { + private final List vanished = new ArrayList<>(); + public VanishCommand() { + super( + "vanish", + new String[]{}, + "Turn yourself into invisible", + "" + ); + } + @Override + public void onCommand(CommandSender sender, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + if(vanished.contains(player.getUniqueId())) { + vanished.remove(player.getUniqueId()); + for (Player target : Bukkit.getOnlinePlayers()) { + target.showPlayer(player); + } + player.sendMessage(ChatColor.GREEN + "You are now seen by people"); + } else { + vanished.add(player.getUniqueId()); + for (Player target: Bukkit.getOnlinePlayers()){ + target.hidePlayer(player); + } + player.sendMessage(ChatColor.GREEN + "You are now vanished"); + } + } + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; + } +}