Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
e0b6c1b931
Commit
7d7b6226a0
@ -203,7 +203,7 @@ public class FightTeam {
|
|||||||
Set<UUID> playerSet = new HashSet<>(players.keySet());
|
Set<UUID> playerSet = new HashSet<>(players.keySet());
|
||||||
playerSet.removeIf(uuid -> {
|
playerSet.removeIf(uuid -> {
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
if(player == null || !player.isOnline()) {
|
if(player == null) {
|
||||||
removePlayer(players.get(uuid).getEntity());
|
removePlayer(players.get(uuid).getEntity());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,21 +27,19 @@ import de.steamwar.fightsystem.states.StateDependentTask;
|
|||||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Border {
|
public class Border {
|
||||||
|
|
||||||
private final Map<Player, Set<Block>> ghostBarriers = new HashMap<>();
|
private final Map<UUID, Set<Block>> ghostBarriers = new HashMap<>();
|
||||||
private final Map<Player, Location> lastLocation = new HashMap<>();
|
private final Map<UUID, Location> lastLocation = new HashMap<>();
|
||||||
private final boolean contain;
|
private final boolean contain;
|
||||||
private final String resetMessage;
|
private final String resetMessage;
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -61,22 +59,22 @@ public class Border {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(Player player) {
|
public void addPlayer(Player player) {
|
||||||
if(ghostBarriers.containsKey(player) || !player.isOnline())
|
if(ghostBarriers.containsKey(player.getUniqueId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ghostBarriers.put(player, new HashSet<>());
|
ghostBarriers.put(player.getUniqueId(), new HashSet<>());
|
||||||
lastLocation.put(player, player.getLocation());
|
lastLocation.put(player.getUniqueId(), player.getLocation());
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was added to border " + name);
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was added to border " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Player player) {
|
public boolean contains(Player player) {
|
||||||
return ghostBarriers.containsKey(player);
|
return ghostBarriers.containsKey(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(Player player) {
|
public void removePlayer(Player player) {
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was removed from border " + name);
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was removed from border " + name);
|
||||||
lastLocation.remove(player);
|
lastLocation.remove(player.getUniqueId());
|
||||||
Set<Block> blocks = ghostBarriers.remove(player);
|
Set<Block> blocks = ghostBarriers.remove(player.getUniqueId());
|
||||||
if(blocks == null || !player.isOnline())
|
if(blocks == null || !player.isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -85,11 +83,18 @@ public class Border {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
private void run() {
|
||||||
for(Map.Entry<Player, Set<Block>> entry : ghostBarriers.entrySet()) {
|
List<UUID> offline = new ArrayList<>();
|
||||||
Player player = entry.getKey();
|
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();
|
Location location = player.getLocation();
|
||||||
if(region.playerInRegion(location) != contain) {
|
if(region.playerInRegion(location) != contain) {
|
||||||
player.teleport(lastLocation.get(player));
|
player.teleport(lastLocation.get(uuid));
|
||||||
FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -122,6 +127,10 @@ public class Border {
|
|||||||
|
|
||||||
lastLocation.put(entry.getKey(), location);
|
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) {
|
private void borderIteration(Player player, Set<Block> ghostBlocks, Region border) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren