|
|
@ -21,12 +21,18 @@ package de.steamwar.bausystem.features.world;
|
|
|
|
|
|
|
|
|
|
|
|
import de.steamwar.bausystem.BauSystem;
|
|
|
|
import de.steamwar.bausystem.BauSystem;
|
|
|
|
import de.steamwar.bausystem.Permission;
|
|
|
|
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.BauMemberUpdateEvent;
|
|
|
|
|
|
|
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
|
|
|
|
|
|
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
|
|
|
import de.steamwar.command.SWCommand;
|
|
|
|
import de.steamwar.command.SWCommand;
|
|
|
|
import de.steamwar.linkage.Linked;
|
|
|
|
import de.steamwar.linkage.Linked;
|
|
|
|
import de.steamwar.network.packets.PacketHandler;
|
|
|
|
import de.steamwar.network.packets.PacketHandler;
|
|
|
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
|
|
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
|
|
|
import org.bukkit.boss.BarColor;
|
|
|
|
|
|
|
|
import org.bukkit.boss.BarStyle;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
@ -61,6 +67,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|
|
|
Permission.removeForceOnlySpectator(player);
|
|
|
|
Permission.removeForceOnlySpectator(player);
|
|
|
|
newSpectator.add(player);
|
|
|
|
newSpectator.add(player);
|
|
|
|
player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
|
|
|
|
player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
|
|
|
|
|
|
|
|
showSpectatorNotice(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (Permission.SUPERVISOR.hasPermission(player)) {
|
|
|
|
if (Permission.SUPERVISOR.hasPermission(player)) {
|
|
|
@ -70,6 +77,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|
|
|
SPECTATORS.remove(player);
|
|
|
|
SPECTATORS.remove(player);
|
|
|
|
newBuilder.add(player);
|
|
|
|
newBuilder.add(player);
|
|
|
|
player.removePotionEffect(PotionEffectType.GLOWING);
|
|
|
|
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())) {
|
|
|
|
if (Permission.SPECTATOR.hasPermission(event.getPlayer())) {
|
|
|
|
SPECTATORS.add(event.getPlayer());
|
|
|
|
SPECTATORS.add(event.getPlayer());
|
|
|
|
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
|
|
|
|
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
|
|
|
|
|
|
|
|
showSpectatorNotice(event.getPlayer());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
event.getPlayer().removePotionEffect(PotionEffectType.GLOWING);
|
|
|
|
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
|
|
|
|
@EventHandler
|
|
|
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
|
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
|
|
SPECTATORS.remove(event.getPlayer());
|
|
|
|
SPECTATORS.remove(event.getPlayer());
|
|
|
|