Dieser Commit ist enthalten in:
Ursprung
6e1b0f70dd
Commit
4b0f432815
@ -22,13 +22,8 @@ package de.steamwar.lobby.display;
|
|||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import com.mojang.authlib.GameProfile;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -135,7 +130,6 @@ public class NPC {
|
|||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0);
|
|
||||||
|
|
||||||
GameProfile profile = new GameProfile(uuid, name);
|
GameProfile profile = new GameProfile(uuid, name);
|
||||||
addPlayerInfo = playerInfoPacket(addPlayer, profile);
|
addPlayerInfo = playerInfoPacket(addPlayer, profile);
|
||||||
@ -147,15 +141,14 @@ public class NPC {
|
|||||||
namedSpawn = namedSpawnConstructor.invoke();
|
namedSpawn = namedSpawnConstructor.invoke();
|
||||||
namedSpawnEntity.set(namedSpawn, entityId);
|
namedSpawnEntity.set(namedSpawn, entityId);
|
||||||
namedSpawnUUID.set(namedSpawn, uuid);
|
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();
|
headRotation = headRotationConstructor.invoke();
|
||||||
headRotationEntity.set(headRotation, entityId);
|
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);
|
display = new Displayable(location, this::show, this::hide, this::move);
|
||||||
}
|
}
|
||||||
@ -165,11 +158,14 @@ public class NPC {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
setPackets(location);
|
||||||
|
display.setLocation(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPackets(Location location) {
|
||||||
byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0);
|
byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0);
|
||||||
byte pitch = (byte)(int)(location.getPitch() * 256.0 / 360.0);
|
byte pitch = (byte)(int)(location.getPitch() * 256.0 / 360.0);
|
||||||
headRotationYaw.set(headRotation, yaw);
|
headRotationYaw.set(headRotation, yaw);
|
||||||
move = movePacketConstructor.invoke();
|
|
||||||
movePacketEntity.set(move, entityId);
|
|
||||||
movePacketX.set(move, location.getX());
|
movePacketX.set(move, location.getX());
|
||||||
movePacketY.set(move, location.getY());
|
movePacketY.set(move, location.getY());
|
||||||
movePacketZ.set(move, location.getZ());
|
movePacketZ.set(move, location.getZ());
|
||||||
@ -181,10 +177,12 @@ public class NPC {
|
|||||||
namedSpawnZ.set(namedSpawn, location.getZ());
|
namedSpawnZ.set(namedSpawn, location.getZ());
|
||||||
namedSpawnYaw.set(namedSpawn, yaw);
|
namedSpawnYaw.set(namedSpawn, yaw);
|
||||||
namedSpawnPitch.set(namedSpawn, pitch);
|
namedSpawnPitch.set(namedSpawn, pitch);
|
||||||
display.setLocation(location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSimilarLocation(Location location) {
|
private boolean isSimilarLocation(Location location) {
|
||||||
|
if (this.location == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (Location.normalizeYaw(this.location.getYaw()) != Location.normalizeYaw(location.getYaw())) {
|
if (Location.normalizeYaw(this.location.getYaw()) != Location.normalizeYaw(location.getYaw())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -197,10 +195,7 @@ public class NPC {
|
|||||||
if (Math.abs(this.location.getY() - location.getY()) > 0.1) {
|
if (Math.abs(this.location.getY() - location.getY()) > 0.1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Math.abs(this.location.getZ() - location.getZ()) > 0.1) {
|
return !(Math.abs(this.location.getZ() - location.getZ()) > 0.1);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
@ -227,10 +222,8 @@ public class NPC {
|
|||||||
|
|
||||||
private void move(Player player) {
|
private void move(Player player) {
|
||||||
TinyProtocol.instance.sendPacket(player, headRotation);
|
TinyProtocol.instance.sendPacket(player, headRotation);
|
||||||
if (move != null) {
|
|
||||||
TinyProtocol.instance.sendPacket(player, move);
|
TinyProtocol.instance.sendPacket(player, move);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
display.delete();
|
display.delete();
|
||||||
|
@ -110,7 +110,7 @@ public class TeamPlayer extends BasicListener {
|
|||||||
LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players");
|
LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players");
|
||||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
if (count.get() % 20 * 60 * 60 == 0) {
|
if (count.get() % (20 * 60 * 60) == 0) {
|
||||||
count.set(0);
|
count.set(0);
|
||||||
List<SteamwarUser> steamwarUsers = SteamwarUser.getServerTeam();
|
List<SteamwarUser> steamwarUsers = SteamwarUser.getServerTeam();
|
||||||
AtomicInteger added = new AtomicInteger();
|
AtomicInteger added = new AtomicInteger();
|
||||||
@ -131,8 +131,10 @@ public class TeamPlayer extends BasicListener {
|
|||||||
entities.remove(name).delete();
|
entities.remove(name).delete();
|
||||||
removed.incrementAndGet();
|
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");
|
LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
world.getEntitiesByClasses(Villager.class).forEach(entity -> {
|
world.getEntitiesByClasses(Villager.class).forEach(entity -> {
|
||||||
NPC npc = entities.get(entity.getName());
|
NPC npc = entities.get(entity.getName());
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren