This commit is contained in:
night0721 2022-07-10 22:33:56 +01:00
parent 6c2f7216a3
commit 5f55a90a7e

View file

@ -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<UUID> 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<String> onTabComplete(CommandSender sender, String[] args) {
return null;
}
}