|
|
|
@ -21,12 +21,18 @@ package de.steamwar.bausystem.features.world;
|
|
|
|
|
|
|
|
|
|
import de.steamwar.bausystem.BauSystem;
|
|
|
|
|
import de.steamwar.bausystem.Permission;
|
|
|
|
|
import de.steamwar.bausystem.region.Color;
|
|
|
|
|
import de.steamwar.bausystem.region.GlobalRegion;
|
|
|
|
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
|
|
|
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
|
|
|
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
|
|
|
|
import de.steamwar.command.SWCommand;
|
|
|
|
|
import de.steamwar.linkage.Linked;
|
|
|
|
|
import de.steamwar.network.packets.PacketHandler;
|
|
|
|
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
import org.bukkit.boss.BarColor;
|
|
|
|
|
import org.bukkit.boss.BarStyle;
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
@ -61,6 +67,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|
|
|
|
Permission.removeForceOnlySpectator(player);
|
|
|
|
|
newSpectator.add(player);
|
|
|
|
|
player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
|
|
|
|
|
showSpectatorNotice(player);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (Permission.SUPERVISOR.hasPermission(player)) {
|
|
|
|
@ -70,6 +77,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|
|
|
|
SPECTATORS.remove(player);
|
|
|
|
|
newBuilder.add(player);
|
|
|
|
|
player.removePotionEffect(PotionEffectType.GLOWING);
|
|
|
|
|
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "spectator");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -81,11 +89,20 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|
|
|
|
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
|
|
|
|
|
SPECTATORS.add(event.getPlayer());
|
|
|
|
|
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
|
|
|
|
|
showSpectatorNotice(event.getPlayer());
|
|
|
|
|
} else {
|
|
|
|
|
event.getPlayer().removePotionEffect(PotionEffectType.GLOWING);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void showSpectatorNotice(Player player) {
|
|
|
|
|
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "spectator");
|
|
|
|
|
bossbar.setTitle(BauSystem.MESSAGE.parse("SPECTATOR", player));
|
|
|
|
|
bossbar.setColor(BarColor.WHITE);
|
|
|
|
|
bossbar.setStyle(BarStyle.SOLID);
|
|
|
|
|
bossbar.setProgress(1.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
|
|
|
SPECTATORS.remove(event.getPlayer());
|
|
|
|
|