SteamWar/BauSystem2.0
Archiviert
12
0

Update Permission #220

Zusammengeführt
YoyoNow hat 35 Commits von PermissionUpdate nach master 2024-02-17 08:53:31 +01:00 zusammengeführt
3 geänderte Dateien mit 19 neuen und 0 gelöschten Zeilen
Nur Änderungen aus Commit 96b84a798b werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -29,6 +29,7 @@ LIST_NEXT_PAGE=§eNext page
# Permissions # Permissions
NO_PERMISSION = You are not allowed to use that here NO_PERMISSION = You are not allowed to use that here
SPECTATOR = §fSpectator
# Scoreboard # Scoreboard
SCOREBOARD_TIME = Time SCOREBOARD_TIME = Time

Datei anzeigen

@ -29,6 +29,7 @@ LIST_NEXT_PAGE=§eNächste Seite
# Permission # Permission
NO_PERMISSION = Du darfst dies hier nicht nutzen NO_PERMISSION = Du darfst dies hier nicht nutzen
SPECTATOR = §fZuschauer
# Scoreboard # Scoreboard
SCOREBOARD_TIME = Uhrzeit SCOREBOARD_TIME = Uhrzeit

Datei anzeigen

@ -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());