HullHider v2 #408
@ -165,6 +165,11 @@ public class PacketProcessor implements Listener {
|
||||
entityServer.addPlayer(player);
|
||||
}
|
||||
|
||||
private void addREntity(int entityId, REntity entity) {
|
||||
entities.put(entityId, entity);
|
||||
FightSystem.getHullHider().updateREntity(entity);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
entityServer.addPlayer(e.getPlayer());
|
||||
@ -235,7 +240,7 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
execSync(() -> {
|
||||
SteamwarUser user = SteamwarUser.get(userId);
|
||||
entities.put(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
|
||||
addREntity(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
|
||||
team.addEntry(user.getUserName());
|
||||
});
|
||||
}
|
||||
@ -257,8 +262,10 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
execSync(() -> {
|
||||
REntity entity = entities.get(entityId);
|
||||
if(entity != null)
|
||||
if(entity != null) {
|
||||
entity.move(locX, locY, locZ, pitch, yaw, headYaw);
|
||||
FightSystem.getHullHider().updateREntity(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -267,8 +274,10 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
execSync(() -> {
|
||||
REntity entity = entities.remove(entityId);
|
||||
if(entity != null)
|
||||
if(entity != null) {
|
||||
FightSystem.getHullHider().despawnREntity(entity);
|
||||
entity.die();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -289,7 +298,7 @@ public class PacketProcessor implements Listener {
|
||||
private void tntSpawn() throws IOException {
|
||||
int entityId = source.readInt();
|
||||
|
||||
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn)));
|
||||
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn)));
|
||||
}
|
||||
|
||||
private void entityVelocity() throws IOException {
|
||||
@ -344,13 +353,13 @@ public class PacketProcessor implements Listener {
|
||||
private void arrowSpawn() throws IOException {
|
||||
int entityId = source.readInt();
|
||||
|
||||
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.ARROW, Config.SpecSpawn)));
|
||||
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.ARROW, Config.SpecSpawn)));
|
||||
}
|
||||
|
||||
private void fireballSpawn() throws IOException {
|
||||
int entityId = source.readInt();
|
||||
|
||||
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn)));
|
||||
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn)));
|
||||
}
|
||||
|
||||
private void send(ChatMessageType type) throws IOException {
|
||||
@ -581,6 +590,7 @@ public class PacketProcessor implements Listener {
|
||||
private void endReplay() {
|
||||
HandlerList.unregisterAll(this);
|
||||
entityServer.close();
|
||||
entities.values().forEach(FightSystem.getHullHider()::despawnREntity);
|
||||
entities.clear();
|
||||
|
||||
freezer.disable();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
@ -47,6 +48,7 @@ public class Hull {
|
||||
|
||||
private final Set<Player> players = new HashSet<>();
|
||||
private final Set<Entity> entities = new HashSet<>();
|
||||
private final Set<REntity> rentities = new HashSet<>();
|
||||
|
||||
public Hull(FightTeam team) {
|
||||
this.region = team.getSchemRegion();
|
||||
@ -92,7 +94,7 @@ public class Hull {
|
||||
public void addPlayer(Player player) {
|
||||
if(players.add(player)) {
|
||||
for(Entity entity : entities)
|
||||
player.hideEntity(FightSystem.getPlugin(), entity); //TODO 1.15-
|
||||
player.hideEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +102,7 @@ public class Hull {
|
||||
public void removePlayer(Player player, boolean activeRemoval) {
|
||||
if(players.remove(player) && activeRemoval) {
|
||||
for(Entity entity : entities)
|
||||
player.showEntity(FightSystem.getPlugin(), entity); //TODO 1.15-
|
||||
player.showEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,12 +111,12 @@ public class Hull {
|
||||
if(region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) { //TODO more precise
|
||||
if(entities.add(entity)) {
|
||||
for(Player player : players)
|
||||
player.hideEntity(FightSystem.getPlugin(), entity); //TODO 1.15-
|
||||
player.hideEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
} else {
|
||||
if(entities.remove(entity)) {
|
||||
for(Player player : players)
|
||||
player.showEntity(FightSystem.getPlugin(), entity); //TODO 1.15-
|
||||
player.showEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,6 +125,21 @@ public class Hull {
|
||||
entities.remove(entity);
|
||||
}
|
||||
|
||||
public void checkREntity(REntity entity) {
|
||||
Location location = new Location(Config.world, entity.getX(), entity.getY(), entity.getZ());
|
||||
if(region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) { //TODO more precise
|
||||
if(rentities.add(entity))
|
||||
entity.hide(true);
|
||||
} else {
|
||||
if(rentities.remove(entity))
|
||||
entity.hide(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeREntity(REntity entity) {
|
||||
rentities.remove(entity);
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
visibility.clear();
|
||||
occluding.clear();
|
||||
@ -176,7 +193,16 @@ public class Hull {
|
||||
if(uncoveredSet.contains(new IntVector(entity.getLocation()))) { //TODO more precise
|
||||
it.remove();
|
||||
for(Player player : players)
|
||||
player.showEntity(FightSystem.getPlugin(), entity); //TODO 1.15-
|
||||
player.showEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<REntity> rit = rentities.iterator();
|
||||
while(rit.hasNext()) {
|
||||
REntity entity = rit.next();
|
||||
if(uncoveredSet.contains(new IntVector(new Location(Config.world, entity.getX(), entity.getY(), entity.getZ())))) { //TODO more precise
|
||||
it.remove();
|
||||
entity.hide(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
@ -50,11 +51,6 @@ public class HullHider implements Listener {
|
||||
private static final boolean ENABLED = TechHiderWrapper.ENABLED && Core.getVersion() >= 18;
|
||||
private final Map<FightTeam, Hull> hulls = new HashMap<>();
|
||||
|
||||
//SpawnPackets: PacketPlayOutSpawnEntity, PacketPlayOutSpawnEntityWeather, PacketPlayOutSpawnEntityLiving, PacketPlayOutSpawnEntityPainting, PacketPlayOutSpawnEntityPlayer
|
||||
//One-timePackets: PacketPlayOutEntityAnimation, PacketPlayOutBlockBreakAnimation, PacketPlayOutEntityStatus, PacketPlayOutEntityPosition, PacketPlayOutEntityPositionAndRotation, PacketPlayOutEntityRotation, PacketPlayOutEntityMovement, EntityHeadLook, EntitySoundEffect, CollectItem, EntityTeleport,
|
||||
//Permanent: EntityMetadata, AttachEntity, EntityEquipment, SetPassengers, EntityProperties, EntityEffect, RemoveEntityEffect
|
||||
//Other: Effect, Particle, Explosion
|
||||
//Death: DestroyEntities
|
||||
public HullHider() {
|
||||
if(ENABLED)
|
||||
Fight.teams().forEach(team -> hulls.put(team, new Hull(team)));
|
||||
@ -63,7 +59,7 @@ public class HullHider implements Listener {
|
||||
new StateDependent(ENABLED, FightState.Schem) {
|
||||
@Override
|
||||
public void enable() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> updatePlayer(player));
|
||||
Bukkit.getOnlinePlayers().forEach(HullHider.this::updatePlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,4 +136,12 @@ public class HullHider implements Listener {
|
||||
public void onDeath(EntityDeathEvent e) {
|
||||
hulls.values().forEach(hull -> hull.removeEntity(e.getEntity()));
|
||||
}
|
||||
|
||||
public void updateREntity(REntity e) {
|
||||
hulls.values().forEach(hull -> hull.checkREntity(e));
|
||||
}
|
||||
|
||||
public void despawnREntity(REntity e) {
|
||||
hulls.values().forEach(hull -> hull.removeREntity(e));
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren