HullHider v2 #408
@ -165,6 +165,11 @@ public class PacketProcessor implements Listener {
|
|||||||
entityServer.addPlayer(player);
|
entityServer.addPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addREntity(int entityId, REntity entity) {
|
||||||
|
entities.put(entityId, entity);
|
||||||
|
FightSystem.getHullHider().updateREntity(entity);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
entityServer.addPlayer(e.getPlayer());
|
entityServer.addPlayer(e.getPlayer());
|
||||||
@ -235,7 +240,7 @@ public class PacketProcessor implements Listener {
|
|||||||
|
|
||||||
execSync(() -> {
|
execSync(() -> {
|
||||||
SteamwarUser user = SteamwarUser.get(userId);
|
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());
|
team.addEntry(user.getUserName());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -257,8 +262,10 @@ public class PacketProcessor implements Listener {
|
|||||||
|
|
||||||
execSync(() -> {
|
execSync(() -> {
|
||||||
REntity entity = entities.get(entityId);
|
REntity entity = entities.get(entityId);
|
||||||
if(entity != null)
|
if(entity != null) {
|
||||||
entity.move(locX, locY, locZ, pitch, yaw, headYaw);
|
entity.move(locX, locY, locZ, pitch, yaw, headYaw);
|
||||||
|
FightSystem.getHullHider().updateREntity(entity);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +274,10 @@ public class PacketProcessor implements Listener {
|
|||||||
|
|
||||||
execSync(() -> {
|
execSync(() -> {
|
||||||
REntity entity = entities.remove(entityId);
|
REntity entity = entities.remove(entityId);
|
||||||
if(entity != null)
|
if(entity != null) {
|
||||||
|
FightSystem.getHullHider().despawnREntity(entity);
|
||||||
entity.die();
|
entity.die();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +298,7 @@ public class PacketProcessor implements Listener {
|
|||||||
private void tntSpawn() throws IOException {
|
private void tntSpawn() throws IOException {
|
||||||
int entityId = source.readInt();
|
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 {
|
private void entityVelocity() throws IOException {
|
||||||
@ -344,13 +353,13 @@ public class PacketProcessor implements Listener {
|
|||||||
private void arrowSpawn() throws IOException {
|
private void arrowSpawn() throws IOException {
|
||||||
int entityId = source.readInt();
|
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 {
|
private void fireballSpawn() throws IOException {
|
||||||
int entityId = source.readInt();
|
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 {
|
private void send(ChatMessageType type) throws IOException {
|
||||||
@ -581,6 +590,7 @@ public class PacketProcessor implements Listener {
|
|||||||
private void endReplay() {
|
private void endReplay() {
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
entityServer.close();
|
entityServer.close();
|
||||||
|
entities.values().forEach(FightSystem.getHullHider()::despawnREntity);
|
||||||
entities.clear();
|
entities.clear();
|
||||||
|
|
||||||
freezer.disable();
|
freezer.disable();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
@ -47,6 +48,7 @@ public class Hull {
|
|||||||
|
|
||||||
private final Set<Player> players = new HashSet<>();
|
private final Set<Player> players = new HashSet<>();
|
||||||
private final Set<Entity> entities = new HashSet<>();
|
private final Set<Entity> entities = new HashSet<>();
|
||||||
|
private final Set<REntity> rentities = new HashSet<>();
|
||||||
|
|
||||||
public Hull(FightTeam team) {
|
public Hull(FightTeam team) {
|
||||||
this.region = team.getSchemRegion();
|
this.region = team.getSchemRegion();
|
||||||
@ -92,7 +94,7 @@ public class Hull {
|
|||||||
public void addPlayer(Player player) {
|
public void addPlayer(Player player) {
|
||||||
if(players.add(player)) {
|
if(players.add(player)) {
|
||||||
for(Entity entity : entities)
|
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) {
|
public void removePlayer(Player player, boolean activeRemoval) {
|
||||||
if(players.remove(player) && activeRemoval) {
|
if(players.remove(player) && activeRemoval) {
|
||||||
for(Entity entity : entities)
|
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(region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) { //TODO more precise
|
||||||
if(entities.add(entity)) {
|
if(entities.add(entity)) {
|
||||||
for(Player player : players)
|
for(Player player : players)
|
||||||
player.hideEntity(FightSystem.getPlugin(), entity); //TODO 1.15-
|
player.hideEntity(FightSystem.getPlugin(), entity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(entities.remove(entity)) {
|
if(entities.remove(entity)) {
|
||||||
for(Player player : players)
|
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);
|
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() {
|
public void initialize() {
|
||||||
visibility.clear();
|
visibility.clear();
|
||||||
occluding.clear();
|
occluding.clear();
|
||||||
@ -176,7 +193,16 @@ public class Hull {
|
|||||||
if(uncoveredSet.contains(new IntVector(entity.getLocation()))) { //TODO more precise
|
if(uncoveredSet.contains(new IntVector(entity.getLocation()))) { //TODO more precise
|
||||||
it.remove();
|
it.remove();
|
||||||
for(Player player : players)
|
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;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
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 static final boolean ENABLED = TechHiderWrapper.ENABLED && Core.getVersion() >= 18;
|
||||||
private final Map<FightTeam, Hull> hulls = new HashMap<>();
|
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() {
|
public HullHider() {
|
||||||
if(ENABLED)
|
if(ENABLED)
|
||||||
Fight.teams().forEach(team -> hulls.put(team, new Hull(team)));
|
Fight.teams().forEach(team -> hulls.put(team, new Hull(team)));
|
||||||
@ -63,7 +59,7 @@ public class HullHider implements Listener {
|
|||||||
new StateDependent(ENABLED, FightState.Schem) {
|
new StateDependent(ENABLED, FightState.Schem) {
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> updatePlayer(player));
|
Bukkit.getOnlinePlayers().forEach(HullHider.this::updatePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -140,4 +136,12 @@ public class HullHider implements Listener {
|
|||||||
public void onDeath(EntityDeathEvent e) {
|
public void onDeath(EntityDeathEvent e) {
|
||||||
hulls.values().forEach(hull -> hull.removeEntity(e.getEntity()));
|
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