#1181: Consolidate Location conversion code
By: Doc <nachito94@msn.com>
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -108,6 +108,27 @@
|
||||
@@ -108,6 +108,26 @@
|
||||
import net.minecraft.world.scores.ScoreboardTeamBase;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.stream.Collectors;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
+import net.minecraft.network.syncher.DataWatcher;
|
||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||
+import net.minecraft.server.network.LoginListener;
|
||||
+import org.bukkit.Location;
|
||||
@@ -15,6 +13,7 @@
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
+import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -28,7 +27,7 @@
|
||||
public abstract class PlayerList {
|
||||
|
||||
public static final File USERBANLIST_FILE = new File("banned-players.json");
|
||||
@@ -119,14 +140,16 @@
|
||||
@@ -119,14 +139,16 @@
|
||||
private static final int SEND_PLAYER_INFO_INTERVAL = 600;
|
||||
private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||
private final MinecraftServer server;
|
||||
@@ -48,7 +47,7 @@
|
||||
public final WorldNBTStorage playerIo;
|
||||
private boolean doWhiteList;
|
||||
private final LayeredRegistryAccess<RegistryLayer> registries;
|
||||
@@ -138,13 +161,23 @@
|
||||
@@ -138,13 +160,23 @@
|
||||
private static final boolean ALLOW_LOGOUTIVATOR = false;
|
||||
private int sendAllPlayerInfoIn;
|
||||
|
||||
@@ -74,7 +73,7 @@
|
||||
this.server = minecraftserver;
|
||||
this.registries = layeredregistryaccess;
|
||||
this.synchronizedRegistries = (new IRegistryCustom.c(RegistrySynchronization.networkedRegistries(layeredregistryaccess))).freeze();
|
||||
@@ -161,9 +194,15 @@
|
||||
@@ -161,9 +193,15 @@
|
||||
usercache.add(gameprofile);
|
||||
NBTTagCompound nbttagcompound = this.load(entityplayer);
|
||||
ResourceKey resourcekey;
|
||||
@@ -91,7 +90,7 @@
|
||||
Logger logger = PlayerList.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -190,7 +229,8 @@
|
||||
@@ -190,7 +228,8 @@
|
||||
s1 = networkmanager.getRemoteAddress().toString();
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@
|
||||
WorldData worlddata = worldserver1.getLevelData();
|
||||
|
||||
entityplayer.loadGameTypes(nbttagcompound);
|
||||
@@ -200,6 +240,7 @@
|
||||
@@ -200,6 +239,7 @@
|
||||
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
|
||||
|
||||
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.synchronizedRegistries, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation()));
|
||||
@@ -109,7 +108,7 @@
|
||||
playerconnection.send(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(worldserver1.enabledFeatures())));
|
||||
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
|
||||
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
@@ -219,8 +260,10 @@
|
||||
@@ -219,8 +259,10 @@
|
||||
} else {
|
||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
|
||||
}
|
||||
@@ -121,7 +120,7 @@
|
||||
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
ServerPing serverping = this.server.getStatus();
|
||||
|
||||
@@ -231,10 +274,61 @@
|
||||
@@ -231,10 +273,61 @@
|
||||
entityplayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players));
|
||||
this.players.add(entityplayer);
|
||||
this.playersByUUID.put(entityplayer.getUUID(), entityplayer);
|
||||
@@ -186,7 +185,7 @@
|
||||
this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> {
|
||||
entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt());
|
||||
});
|
||||
@@ -248,8 +342,11 @@
|
||||
@@ -248,8 +341,11 @@
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
||||
@@ -200,7 +199,7 @@
|
||||
});
|
||||
|
||||
if (entity != null) {
|
||||
@@ -292,6 +389,8 @@
|
||||
@@ -292,6 +388,8 @@
|
||||
}
|
||||
|
||||
entityplayer.initInventoryMenu();
|
||||
@@ -209,7 +208,7 @@
|
||||
}
|
||||
|
||||
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
|
||||
@@ -324,30 +423,31 @@
|
||||
@@ -324,30 +422,31 @@
|
||||
}
|
||||
|
||||
public void addWorldborderListener(WorldServer worldserver) {
|
||||
@@ -246,7 +245,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,14 +475,15 @@
|
||||
@@ -375,14 +474,15 @@
|
||||
}
|
||||
|
||||
protected void save(EntityPlayer entityplayer) {
|
||||
@@ -264,7 +263,7 @@
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.save();
|
||||
@@ -390,10 +491,24 @@
|
||||
@@ -390,10 +490,24 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -290,7 +289,7 @@
|
||||
this.save(entityplayer);
|
||||
if (entityplayer.isPassenger()) {
|
||||
Entity entity = entityplayer.getRootVehicle();
|
||||
@@ -417,18 +532,66 @@
|
||||
@@ -417,18 +531,66 @@
|
||||
|
||||
if (entityplayer1 == entityplayer) {
|
||||
this.playersByUUID.remove(uuid);
|
||||
@@ -363,7 +362,7 @@
|
||||
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
|
||||
|
||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
|
||||
@@ -436,10 +599,12 @@
|
||||
@@ -436,10 +598,12 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
|
||||
}
|
||||
|
||||
@@ -379,7 +378,7 @@
|
||||
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
|
||||
|
||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
|
||||
@@ -447,13 +612,25 @@
|
||||
@@ -447,13 +611,25 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
|
||||
}
|
||||
|
||||
@@ -408,7 +407,7 @@
|
||||
UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
|
||||
List<EntityPlayer> list = Lists.newArrayList();
|
||||
|
||||
@@ -480,14 +657,24 @@
|
||||
@@ -480,14 +656,24 @@
|
||||
}
|
||||
|
||||
return new EntityPlayer(this.server, this.server.overworld(), gameprofile);
|
||||
@@ -434,7 +433,7 @@
|
||||
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
|
||||
Optional optional;
|
||||
|
||||
@@ -499,6 +686,11 @@
|
||||
@@ -499,6 +685,11 @@
|
||||
|
||||
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile());
|
||||
@@ -446,7 +445,7 @@
|
||||
|
||||
entityplayer1.connection = entityplayer.connection;
|
||||
entityplayer1.restoreFrom(entityplayer, flag);
|
||||
@@ -514,50 +706,112 @@
|
||||
@@ -514,50 +705,112 @@
|
||||
|
||||
boolean flag2 = false;
|
||||
|
||||
@@ -489,7 +488,7 @@
|
||||
+ // entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false); // CraftBukkit - not required, just copies old location into reused entity
|
||||
+ flag2 = !flag && flag3;
|
||||
+ isBedSpawn = true;
|
||||
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
+ location = CraftLocation.toBukkit(vec3d, worldserver1.getWorld(), f1, 0.0F);
|
||||
+ } else if (blockposition != null) {
|
||||
+ entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
|
||||
@@ -500,7 +499,7 @@
|
||||
+ if (location == null) {
|
||||
+ worldserver1 = this.server.getLevel(World.OVERWORLD);
|
||||
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
|
||||
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
|
||||
+ location = CraftLocation.toBukkit(blockposition, worldserver1.getWorld()).add(0.5F, 0.1F, 0.5F);
|
||||
}
|
||||
|
||||
- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
@@ -533,7 +532,7 @@
|
||||
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), (byte) i, entityplayer1.getLastDeathLocation()));
|
||||
+ entityplayer1.spawnIn(worldserver1);
|
||||
+ entityplayer1.unsetRemoved();
|
||||
+ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
|
||||
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot()));
|
||||
+ entityplayer1.setShiftKeyDown(false);
|
||||
|
||||
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeId(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), (byte) i, entityplayer1.getLastDeathLocation()));
|
||||
@@ -582,7 +581,7 @@
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -570,7 +824,18 @@
|
||||
@@ -570,7 +823,18 @@
|
||||
|
||||
public void tick() {
|
||||
if (++this.sendAllPlayerInfoIn > 600) {
|
||||
@@ -602,7 +601,7 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -587,6 +852,25 @@
|
||||
@@ -587,6 +851,25 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -628,7 +627,7 @@
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -665,7 +949,7 @@
|
||||
@@ -665,7 +948,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile gameprofile) {
|
||||
@@ -637,7 +636,7 @@
|
||||
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -689,6 +973,7 @@
|
||||
@@ -689,6 +972,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
|
||||
}
|
||||
|
||||
@@ -645,7 +644,7 @@
|
||||
this.server.getCommands().sendCommands(entityplayer);
|
||||
}
|
||||
|
||||
@@ -721,6 +1006,12 @@
|
||||
@@ -721,6 +1005,12 @@
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
||||
|
||||
@@ -658,7 +657,7 @@
|
||||
if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) {
|
||||
double d4 = d0 - entityplayer.getX();
|
||||
double d5 = d1 - entityplayer.getY();
|
||||
@@ -760,23 +1051,35 @@
|
||||
@@ -760,23 +1050,35 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
@@ -699,7 +698,7 @@
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -832,12 +1135,22 @@
|
||||
@@ -832,12 +1134,22 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
@@ -724,7 +723,7 @@
|
||||
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
|
||||
return ichatbasecomponent;
|
||||
@@ -895,16 +1208,23 @@
|
||||
@@ -895,16 +1207,23 @@
|
||||
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
@@ -752,7 +751,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -913,7 +1233,7 @@
|
||||
@@ -913,7 +1232,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||
@@ -761,7 +760,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -921,13 +1241,13 @@
|
||||
@@ -921,13 +1240,13 @@
|
||||
|
||||
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
|
||||
UUID uuid = entityplayer.getUUID();
|
||||
@@ -777,7 +776,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(entityplayer);
|
||||
@@ -978,13 +1298,20 @@
|
||||
@@ -978,13 +1297,20 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
|
||||
Reference in New Issue
Block a user