diff --git a/src/de/steamwar/lobby/listener/TeleporterListener.java b/src/de/steamwar/lobby/listener/TeleporterListener.java index f7fd0d7..db3d08c 100644 --- a/src/de/steamwar/lobby/listener/TeleporterListener.java +++ b/src/de/steamwar/lobby/listener/TeleporterListener.java @@ -32,7 +32,7 @@ public class TeleporterListener extends BasicListener { private static final World world = Bukkit.getWorlds().get(0); private static final Location spawn = world.getSpawnLocation().clone().add(0.5, 0, 0.5); - private static final Location team = new Location(world,1524.5,55,1440.5); + private static final Location team = new Location(world,2719.5, 59, 1311.5); private static final Location map = new Location(world,2336.5,38,1423.5); private static final Location bau = new Location(world,1951,66.1,1337, -38, -5); private static final Location arenen = new Location(world,2255.5,21,1450.5); diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index 566616c..040f842 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -49,15 +49,12 @@ public class TeamPlayer extends BasicListener { private static final List cuboids = new ArrayList<>(); static { - cuboids.add(new Cuboid(1509, 52, 1464, 1510, 58, 1470)); - cuboids.add(new Cuboid(1538, 52, 1464, 1539, 58, 1470)); - cuboids.add(new Cuboid(1518, 55, 1433, 1531, 60, 1434)); - cuboids.add(new Cuboid(1587, 52, 1471, 1588, 56, 1476)); - cuboids.add(new Cuboid(1478, 52, 1461, 1479, 56, 1464)); + cuboids.add(new Cuboid(2743, 58, 2306, 2744, 59, 1316)); } private static final World world = Bukkit.getWorlds().get(0); private static final Map entities = new HashMap<>(); + private static final Map villagers = new HashMap<>(); private Set players = new HashSet<>(); @@ -69,7 +66,7 @@ public class TeamPlayer extends BasicListener { } public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) { - Location location = new Location(world, 1524.5, 52, 1484.5); + Location location = new Location(world, 2790.5, 69, 1311.5); String name = steamwarUser.getUserName(); NPC npc = new NPC(location, steamwarUser.getUUID(), name); Villager villager = (Villager) world.spawnEntity(location, EntityType.VILLAGER); @@ -78,28 +75,16 @@ public class TeamPlayer extends BasicListener { villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false, false)); villager.setCustomName(name); villager.setProfession(Villager.Profession.NONE); + villagers.put(name, villager); entities.put(name, npc); } public static void cleanup() { - forceLoad(world, true); - world.getEntitiesByClasses(Villager.class).forEach(Entity::remove); - forceLoad(world, false); - } - - 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); - } - } + villagers.values().forEach(Entity::remove); + entities.values().forEach(NPC::delete); } { - forceLoad(world, true); - world.getEntitiesByClasses(Villager.class).forEach(Entity::remove); - forceLoad(world, false); - SteamwarUser.getServerTeam().forEach(user -> { spawnTeamPlayer(world, user); }); @@ -121,11 +106,7 @@ public class TeamPlayer extends BasicListener { AtomicInteger removed = new AtomicInteger(); List 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(); - } - }); + villagers.remove(name).remove(); entities.remove(name).delete(); removed.incrementAndGet(); });