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; + } +}