44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
package eu.univento.core.api.player;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public class Spectator {
|
|
|
|
private static ArrayList<CustomPlayer> spectators = new ArrayList<CustomPlayer>();
|
|
|
|
public Spectator() {
|
|
}
|
|
|
|
public static void add(Player p) {
|
|
for(Player on : Bukkit.getOnlinePlayers()) {
|
|
on.hidePlayer(p);
|
|
}
|
|
spectators.add(CustomPlayer.getPlayer(p.getName()));
|
|
p.setGameMode(GameMode.CREATIVE);
|
|
p.setAllowFlight(true);
|
|
p.setFlying(true);
|
|
}
|
|
|
|
public static void remove(Player p) {
|
|
for(Player on : Bukkit.getOnlinePlayers()) {
|
|
on.showPlayer(p);
|
|
}
|
|
spectators.remove(CustomPlayer.getPlayer(p.getName()));
|
|
p.setGameMode(GameMode.SURVIVAL);
|
|
p.setAllowFlight(false);
|
|
p.setFlying(false);
|
|
}
|
|
|
|
public static ArrayList<CustomPlayer> getSpectators() {
|
|
return spectators;
|
|
}
|
|
|
|
public static boolean is(CustomPlayer p) {
|
|
return spectators.contains(p.getName());
|
|
}
|
|
|
|
} |