13
0

Optimize stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-03-26 15:49:29 +01:00
Ursprung 6e1b0f70dd
Commit 4b0f432815
2 geänderte Dateien mit 19 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -22,13 +22,8 @@ package de.steamwar.lobby.display;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_15_R1.DataWatcher;
import net.minecraft.server.v1_15_R1.DataWatcherRegistry;
import net.minecraft.server.v1_15_R1.EntityHuman;
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
@ -135,7 +130,6 @@ public class NPC {
this.uuid = uuid;
this.name = name;
this.location = location;
byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0);
GameProfile profile = new GameProfile(uuid, name);
addPlayerInfo = playerInfoPacket(addPlayer, profile);
@ -147,15 +141,14 @@ public class NPC {
namedSpawn = namedSpawnConstructor.invoke();
namedSpawnEntity.set(namedSpawn, entityId);
namedSpawnUUID.set(namedSpawn, uuid);
namedSpawnX.set(namedSpawn, location.getX());
namedSpawnY.set(namedSpawn, location.getY());
namedSpawnZ.set(namedSpawn, location.getZ());
namedSpawnYaw.set(namedSpawn, yaw);
namedSpawnPitch.set(namedSpawn, (byte)(int)(location.getPitch() * 256.0 / 360.0));
headRotation = headRotationConstructor.invoke();
headRotationEntity.set(headRotation, entityId);
headRotationYaw.set(headRotation, yaw);
move = movePacketConstructor.invoke();
movePacketEntity.set(move, entityId);
setPackets(location);
display = new Displayable(location, this::show, this::hide, this::move);
}
@ -165,11 +158,14 @@ public class NPC {
return;
}
this.location = location;
setPackets(location);
display.setLocation(location);
}
private void setPackets(Location location) {
byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0);
byte pitch = (byte)(int)(location.getPitch() * 256.0 / 360.0);
headRotationYaw.set(headRotation, yaw);
move = movePacketConstructor.invoke();
movePacketEntity.set(move, entityId);
movePacketX.set(move, location.getX());
movePacketY.set(move, location.getY());
movePacketZ.set(move, location.getZ());
@ -181,10 +177,12 @@ public class NPC {
namedSpawnZ.set(namedSpawn, location.getZ());
namedSpawnYaw.set(namedSpawn, yaw);
namedSpawnPitch.set(namedSpawn, pitch);
display.setLocation(location);
}
private boolean isSimilarLocation(Location location) {
if (this.location == null) {
return false;
}
if (Location.normalizeYaw(this.location.getYaw()) != Location.normalizeYaw(location.getYaw())) {
return false;
}
@ -197,10 +195,7 @@ public class NPC {
if (Math.abs(this.location.getY() - location.getY()) > 0.1) {
return false;
}
if (Math.abs(this.location.getZ() - location.getZ()) > 0.1) {
return false;
}
return true;
return !(Math.abs(this.location.getZ() - location.getZ()) > 0.1);
}
public Location getLocation() {
@ -227,10 +222,8 @@ public class NPC {
private void move(Player player) {
TinyProtocol.instance.sendPacket(player, headRotation);
if (move != null) {
TinyProtocol.instance.sendPacket(player, move);
}
}
public void delete() {
display.delete();

Datei anzeigen

@ -110,7 +110,7 @@ public class TeamPlayer extends BasicListener {
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) {
if (count.get() % (20 * 60 * 60) == 0) {
count.set(0);
List<SteamwarUser> steamwarUsers = SteamwarUser.getServerTeam();
AtomicInteger added = new AtomicInteger();
@ -131,8 +131,10 @@ public class TeamPlayer extends BasicListener {
entities.remove(name).delete();
removed.incrementAndGet();
});
if (added.get() > 0 || removed.get() > 0) {
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) {