13
0

TeamHalle #6

Zusammengeführt
Lixfel hat 16 Commits von TeamHalle nach master 2022-03-26 16:28:22 +01:00 zusammengeführt
2 geänderte Dateien mit 34 neuen und 6 gelöschten Zeilen
Nur Änderungen aus Commit 1de921b7ff werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -172,6 +172,9 @@ public class NPC {
movePacketX.set(move, location.getX());
movePacketY.set(move, location.getY());
movePacketZ.set(move, location.getZ());
namedSpawnX.set(namedSpawn, location.getX());
namedSpawnY.set(namedSpawn, location.getY());
namedSpawnZ.set(namedSpawn, location.getZ());
movePacketYaw.set(move, yaw);
movePacketPitch.set(move, (byte)(int)(location.getPitch() * 256.0 / 360.0));
movePacketOnGround.set(move, true);

Datei anzeigen

@ -36,11 +36,10 @@ import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class TeamPlayer extends BasicListener {
@ -59,12 +58,13 @@ public class TeamPlayer extends BasicListener {
}
private static final List<Cuboid> cuboids = new ArrayList<>();
static {
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Bitte nicht den Weltnamen hardcoden...

Bitte nicht den Weltnamen hardcoden...
Veraltet
Review

Ist die Lobby denn immer die Bukkit.getWorlds().get(0)

Ist die Lobby denn immer die `Bukkit.getWorlds().get(0)`
cuboids.add(new Cuboid(1509, 52, 1464, 1510, 58, 1469));
cuboids.add(new Cuboid(1538, 52, 1464, 1539, 58, 1469));
cuboids.add(new Cuboid(1518, 55, 1433, 1530, 60, 1434));
cuboids.add(new Cuboid(1587, 52, 1471, 1588, 56, 1475));
cuboids.add(new Cuboid(1479, 52, 1461, 1478, 56, 1463));
cuboids.add(new Cuboid(1478, 52, 1461, 1479, 56, 1463));
}
private static final World world = Bukkit.getWorlds().get(0);
@ -92,7 +92,7 @@ public class TeamPlayer extends BasicListener {
private static void forceLoad(World world, boolean setTo) {
for (int x = -10; x < 10; x++) {
for (int z = -10; z < 10; z++) {
world.setChunkForceLoaded(95 + x , 93 + z, setTo);
world.setChunkForceLoaded(95 + x, 93 + z, setTo);
}
}
}
@ -106,8 +106,33 @@ public class TeamPlayer extends BasicListener {
spawnTeamPlayer(world, user);
});
AtomicInteger count = new AtomicInteger();
LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players");
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
count.incrementAndGet();
if (count.get() % 20 * 60 * 60 == 0) {
count.set(0);
List<SteamwarUser> steamwarUsers = SteamwarUser.getServerTeam();
AtomicInteger added = new AtomicInteger();
steamwarUsers.forEach(user -> {
if (!entities.containsKey(user.getUserName())) {
spawnTeamPlayer(world, user);
added.incrementAndGet();
}
});
AtomicInteger removed = new AtomicInteger();
List<String> names = steamwarUsers.stream().map(SteamwarUser::getUserName).collect(Collectors.toList());
new HashSet<>(entities.keySet()).stream().filter(name -> !names.contains(name)).forEach(name -> {
world.getEntitiesByClasses(Villager.class).forEach(entity -> {
if (entity.getName().equals(name)) {
entity.remove();
}
});
entities.remove(name).delete();
removed.incrementAndGet();
});
LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players");
}
world.getEntitiesByClasses(Villager.class).forEach(entity -> {
NPC npc = entities.get(entity.getName());
if (npc != null) {