SteamWar/FightSystem
Archiviert
13
1

Potential Border rejoin fix
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2024-02-11 19:13:47 +01:00
Ursprung e0b6c1b931
Commit 7d7b6226a0
2 geänderte Dateien mit 25 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -203,7 +203,7 @@ public class FightTeam {
Set<UUID> playerSet = new HashSet<>(players.keySet());
playerSet.removeIf(uuid -> {
Player player = Bukkit.getPlayer(uuid);
if(player == null || !player.isOnline()) {
if(player == null) {
removePlayer(players.get(uuid).getEntity());
return true;
}

Datei anzeigen

@ -27,21 +27,19 @@ import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.Region;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.logging.Level;
public class Border {
private final Map<Player, Set<Block>> ghostBarriers = new HashMap<>();
private final Map<Player, Location> lastLocation = new HashMap<>();
private final Map<UUID, Set<Block>> ghostBarriers = new HashMap<>();
private final Map<UUID, Location> lastLocation = new HashMap<>();
private final boolean contain;
private final String resetMessage;
private final String name;
@ -61,22 +59,22 @@ public class Border {
}
public void addPlayer(Player player) {
if(ghostBarriers.containsKey(player) || !player.isOnline())
if(ghostBarriers.containsKey(player.getUniqueId()))
return;
ghostBarriers.put(player, new HashSet<>());
lastLocation.put(player, player.getLocation());
ghostBarriers.put(player.getUniqueId(), new HashSet<>());
lastLocation.put(player.getUniqueId(), player.getLocation());
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was added to border " + name);
}
public boolean contains(Player player) {
return ghostBarriers.containsKey(player);
return ghostBarriers.containsKey(player.getUniqueId());
}
public void removePlayer(Player player) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was removed from border " + name);
lastLocation.remove(player);
Set<Block> blocks = ghostBarriers.remove(player);
lastLocation.remove(player.getUniqueId());
Set<Block> blocks = ghostBarriers.remove(player.getUniqueId());
if(blocks == null || !player.isOnline())
return;
@ -85,11 +83,18 @@ public class Border {
}
private void run() {
for(Map.Entry<Player, Set<Block>> entry : ghostBarriers.entrySet()) {
Player player = entry.getKey();
List<UUID> offline = new ArrayList<>();
for(Map.Entry<UUID, Set<Block>> entry : ghostBarriers.entrySet()) {
UUID uuid = entry.getKey();
Player player = Bukkit.getPlayer(uuid);
if(player == null) {
offline.add(uuid);
continue;
}
Location location = player.getLocation();
if(region.playerInRegion(location) != contain) {
player.teleport(lastLocation.get(player));
player.teleport(lastLocation.get(uuid));
FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
return;
}
@ -122,6 +127,10 @@ public class Border {
lastLocation.put(entry.getKey(), location);
}
offline.forEach(uuid -> FightSystem.getPlugin().getLogger().log(Level.INFO, () -> uuid + " was removed from border " + name));
offline.forEach(ghostBarriers::remove);
offline.forEach(lastLocation::remove);
}
private void borderIteration(Player player, Set<Block> ghostBlocks, Region border) {