Robotia 9 years ago
parent
commit
ca715024ee
  1. 118
      patches/net/minecraft/server/management/ServerConfigurationManager.java.patch

118
patches/net/minecraft/server/management/ServerConfigurationManager.java.patch

@ -199,7 +199,7 @@
+ { + {
+ entityplayermp1.playerNetServerHandler.sendPacket(packet); + entityplayermp1.playerNetServerHandler.sendPacket(packet);
+ } + }
} + }
+ // CraftBukkit end + // CraftBukkit end
+ for (int i = 0; i < this.playerEntityList.size(); ++i) + for (int i = 0; i < this.playerEntityList.size(); ++i)
+ { + {
@ -213,7 +213,7 @@
+ +
+ // .name -> .listName + // .name -> .listName
+ p_72377_1_.playerNetServerHandler.sendPacket(new S38PacketPlayerListItem(entityplayermp1.listName, true, entityplayermp1.ping)); + p_72377_1_.playerNetServerHandler.sendPacket(new S38PacketPlayerListItem(entityplayermp1.listName, true, entityplayermp1.ping));
+ } }
+ // CraftBukkit end + // CraftBukkit end
+ kcauldron.updater.DefaultUpdateCallback.INSTANCE.onPlayerJoin(playerJoinEvent); + kcauldron.updater.DefaultUpdateCallback.INSTANCE.onPlayerJoin(playerJoinEvent);
} }
@ -303,15 +303,15 @@
} }
else if (this.bannedIPs.func_152708_a(p_148542_1_)) else if (this.bannedIPs.func_152708_a(p_148542_1_))
{ {
@@ -368,10 +512,75 @@ @@ -368,9 +512,74 @@
} }
else else
{ {
- return this.playerEntityList.size() >= this.maxPlayers ? "The server is full!" : null; - return this.playerEntityList.size() >= this.maxPlayers ? "The server is full!" : null;
+ return this.playerEntityList.size() >= this.maxPlayers ? org.spigotmc.SpigotConfig.serverFullMessage : null; + return this.playerEntityList.size() >= this.maxPlayers ? org.spigotmc.SpigotConfig.serverFullMessage : null;
} + }
} + }
+
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayerMP attemptLogin(NetHandlerLoginServer loginlistener, GameProfile gameprofile, String hostname) + public EntityPlayerMP attemptLogin(NetHandlerLoginServer loginlistener, GameProfile gameprofile, String hostname)
+ { + {
@ -363,7 +363,7 @@
+ { + {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot + event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot
+ } + }
+ } }
+ +
+ this.cserver.getPluginManager().callEvent(event); + this.cserver.getPluginManager().callEvent(event);
+ +
@ -374,13 +374,12 @@
+ } + }
+ +
+ return entity; + return entity;
+ } }
+ // CraftBukkit end + // CraftBukkit end
+
public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_) public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_)
{ {
UUID uuid = EntityPlayer.func_146094_a(p_148545_1_); @@ -410,80 +619,204 @@
@@ -410,80 +619,200 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object); return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
} }
@ -432,15 +431,8 @@
{ {
- object = new ItemInWorldManager(this.mcServer.worldServerForDimension(p_72368_1_.dimension)); - object = new ItemInWorldManager(this.mcServer.worldServerForDimension(p_72368_1_.dimension));
+ object = new ItemInWorldManager(this.mcServer.worldServerForDimension(0)); + object = new ItemInWorldManager(this.mcServer.worldServerForDimension(0));
} + }
+
- EntityPlayerMP entityplayermp1 = new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(p_72368_1_.dimension), p_72368_1_.getGameProfile(), (ItemInWorldManager)object);
- entityplayermp1.playerNetServerHandler = p_72368_1_.playerNetServerHandler;
- entityplayermp1.clonePlayer(p_72368_1_, p_72368_3_);
- entityplayermp1.dimension = p_72368_2_;
- entityplayermp1.setEntityId(p_72368_1_.getEntityId());
- WorldServer worldserver = this.mcServer.worldServerForDimension(p_72368_1_.dimension);
- this.func_72381_a(entityplayermp1, p_72368_1_, worldserver);
+ return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object); + return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
+ // */ + // */
+ return player; + return player;
@ -489,8 +481,15 @@
+ { + {
+ return null; + return null;
+ } + }
+ } }
+
- EntityPlayerMP entityplayermp1 = new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(p_72368_1_.dimension), p_72368_1_.getGameProfile(), (ItemInWorldManager)object);
- entityplayermp1.playerNetServerHandler = p_72368_1_.playerNetServerHandler;
- entityplayermp1.clonePlayer(p_72368_1_, p_72368_3_);
- entityplayermp1.dimension = p_72368_2_;
- entityplayermp1.setEntityId(p_72368_1_.getEntityId());
- WorldServer worldserver = this.mcServer.worldServerForDimension(p_72368_1_.dimension);
- this.func_72381_a(entityplayermp1, p_72368_1_, worldserver);
+ // Phase 3 - remove current player from current dimension + // Phase 3 - remove current player from current dimension
+ par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removePlayerFromTrackers(par1EntityPlayerMP); + par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removePlayerFromTrackers(par1EntityPlayerMP);
+ // par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removeEntityFromAllTrackingPlayers(par1EntityPlayerMP); // CraftBukkit + // par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removeEntityFromAllTrackingPlayers(par1EntityPlayerMP); // CraftBukkit
@ -519,8 +518,7 @@
+ { + {
+ chunkcoordinates1 = EntityPlayer.verifyRespawnCoordinates(this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension), + chunkcoordinates1 = EntityPlayer.verifyRespawnCoordinates(this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension),
+ bedSpawnChunkCoords, spawnForced); + bedSpawnChunkCoords, spawnForced);
+
- if (chunkcoordinates1 != null)
+ if (chunkcoordinates1 != null) + if (chunkcoordinates1 != null)
+ { + {
+ isBedSpawn = true; + isBedSpawn = true;
@ -537,7 +535,8 @@
+ location = new Location(toWorld, toWorld.getSpawnLocation().getX(), toWorld.getSpawnLocation().getY(), toWorld.getSpawnLocation().getZ()); // use the spawnpoint as location + location = new Location(toWorld, toWorld.getSpawnLocation().getX(), toWorld.getSpawnLocation().getY(), toWorld.getSpawnLocation().getZ()); // use the spawnpoint as location
+ } + }
+ } + }
+
- if (chunkcoordinates1 != null)
+ if (location == null) + if (location == null)
{ {
- entityplayermp1.setLocationAndAngles((double)((float)chunkcoordinates1.posX + 0.5F), (double)((float)chunkcoordinates1.posY + 0.1F), (double)((float)chunkcoordinates1.posZ + 0.5F), 0.0F, 0.0F); - entityplayermp1.setLocationAndAngles((double)((float)chunkcoordinates1.posX + 0.5F), (double)((float)chunkcoordinates1.posY + 0.1F), (double)((float)chunkcoordinates1.posZ + 0.5F), 0.0F, 0.0F);
@ -549,18 +548,22 @@
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
+ this.cserver.getPluginManager().callEvent(respawnEvent); + this.cserver.getPluginManager().callEvent(respawnEvent);
+ +
+ // Spigot Start
+ if (par1EntityPlayerMP.playerNetServerHandler.isDisconnected()) { return par1EntityPlayerMP; }
+ // Spigot End
+
+ if (!spawnForced) // mods override plugins + if (!spawnForced) // mods override plugins
{ {
- entityplayermp1.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(0, 0.0F)); - entityplayermp1.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(0, 0.0F));
+ location = respawnEvent.getRespawnLocation(); + location = respawnEvent.getRespawnLocation();
} }
+ par1EntityPlayerMP.reset(); + par1EntityPlayerMP.reset();
} + }
+ else + else
+ // plugin + // plugin
+ { + {
+ location.setWorld(this.mcServer.worldServerForDimension(targetDimension).getWorld()); + location.setWorld(this.mcServer.worldServerForDimension(targetDimension).getWorld());
+ } }
- worldserver.theChunkProviderServer.loadChunk((int)entityplayermp1.posX >> 4, (int)entityplayermp1.posZ >> 4); - worldserver.theChunkProviderServer.loadChunk((int)entityplayermp1.posX >> 4, (int)entityplayermp1.posZ >> 4);
+ WorldServer targetWorld = ((CraftWorld) location.getWorld()).getHandle(); + WorldServer targetWorld = ((CraftWorld) location.getWorld()).getHandle();
@ -621,12 +624,22 @@
return entityplayermp1; return entityplayermp1;
} }
@@ -492,34 +821,112 @@ @@ -492,34 +825,112 @@
transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter()); transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter());
} }
- public void transferPlayerToDimension(EntityPlayerMP p_72356_1_, int p_72356_2_, Teleporter teleporter) - public void transferPlayerToDimension(EntityPlayerMP p_72356_1_, int p_72356_2_, Teleporter teleporter)
+ public void transferPlayerToDimension(EntityPlayerMP p_72356_1_, int p_72356_2_, Teleporter teleporter) // mods such as Twilight Forest call this method directly + public void transferPlayerToDimension(EntityPlayerMP p_72356_1_, int p_72356_2_, Teleporter teleporter) // mods such as Twilight Forest call this method directly
+ {
+ this.transferPlayerToDimension(p_72356_1_, p_72356_2_, teleporter, TeleportCause.MOD); // use our mod cause
+ }
+
+ public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int par2, TeleportCause cause)
+ {
+ this.transferPlayerToDimension(par1EntityPlayerMP, par2, mcServer.worldServerForDimension(par2).getDefaultTeleporter(), cause);
+ }
+
+ public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int targetDimension, Teleporter teleporter, TeleportCause cause) // Cauldron - add TeleportCause
{ {
- int j = p_72356_1_.dimension; - int j = p_72356_1_.dimension;
- WorldServer worldserver = this.mcServer.worldServerForDimension(p_72356_1_.dimension); - WorldServer worldserver = this.mcServer.worldServerForDimension(p_72356_1_.dimension);
@ -642,16 +655,6 @@
- this.updateTimeAndWeatherForPlayer(p_72356_1_, worldserver1); - this.updateTimeAndWeatherForPlayer(p_72356_1_, worldserver1);
- this.syncPlayerInventory(p_72356_1_); - this.syncPlayerInventory(p_72356_1_);
- Iterator iterator = p_72356_1_.getActivePotionEffects().iterator(); - Iterator iterator = p_72356_1_.getActivePotionEffects().iterator();
+ this.transferPlayerToDimension(p_72356_1_, p_72356_2_, teleporter, TeleportCause.MOD); // use our mod cause
+ }
+ public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int par2, TeleportCause cause)
+ {
+ this.transferPlayerToDimension(par1EntityPlayerMP, par2, mcServer.worldServerForDimension(par2).getDefaultTeleporter(), cause);
+ }
+
+ public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int targetDimension, Teleporter teleporter, TeleportCause cause) // Cauldron - add TeleportCause
+ {
+ // Allow Forge hotloading on teleport + // Allow Forge hotloading on teleport
+ WorldServer fromWorld = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension); + WorldServer fromWorld = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
+ WorldServer exitWorld = this.mcServer.worldServerForDimension(targetDimension); + WorldServer exitWorld = this.mcServer.worldServerForDimension(targetDimension);
@ -729,7 +732,7 @@
+ this.updateTimeAndWeatherForPlayer(par1EntityPlayerMP, exitWorld); + this.updateTimeAndWeatherForPlayer(par1EntityPlayerMP, exitWorld);
+ this.syncPlayerInventory(par1EntityPlayerMP); + this.syncPlayerInventory(par1EntityPlayerMP);
+ Iterator iterator = par1EntityPlayerMP.getActivePotionEffects().iterator(); + Iterator iterator = par1EntityPlayerMP.getActivePotionEffects().iterator();
+
while (iterator.hasNext()) while (iterator.hasNext())
{ {
- PotionEffect potioneffect = (PotionEffect)iterator.next(); - PotionEffect potioneffect = (PotionEffect)iterator.next();
@ -753,7 +756,7 @@
} }
public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter) public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter)
@@ -605,6 +1012,109 @@ @@ -605,6 +1016,109 @@
p_82448_1_.setWorld(p_82448_4_); p_82448_1_.setWorld(p_82448_4_);
} }
@ -863,7 +866,7 @@
public void sendPlayerInfoToAllPlayers() public void sendPlayerInfoToAllPlayers()
{ {
if (++this.playerPingIndex > 600) if (++this.playerPingIndex > 600)
@@ -612,11 +1122,13 @@ @@ -612,11 +1126,13 @@
this.playerPingIndex = 0; this.playerPingIndex = 0;
} }
@ -877,7 +880,7 @@
} }
public void sendPacketToAllPlayers(Packet p_148540_1_) public void sendPacketToAllPlayers(Packet p_148540_1_)
@@ -877,13 +1389,24 @@ @@ -877,13 +1393,24 @@
for (int j = 0; j < this.playerEntityList.size(); ++j) for (int j = 0; j < this.playerEntityList.size(); ++j)
{ {
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);
@ -904,7 +907,7 @@
if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_) if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
{ {
entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_); entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
@@ -941,13 +1464,16 @@ @@ -941,13 +1468,16 @@
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F)); p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, p_72354_2_.getRainStrength(1.0F))); p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, p_72354_2_.getRainStrength(1.0F)));
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, p_72354_2_.getWeightedThunderStrength(1.0F))); p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, p_72354_2_.getWeightedThunderStrength(1.0F)));
@ -922,7 +925,7 @@
p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem)); p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem));
} }
@@ -961,9 +1487,17 @@ @@ -961,9 +1491,17 @@
return this.maxPlayers; return this.maxPlayers;
} }
@ -941,14 +944,13 @@
} }
public void setWhiteListEnabled(boolean p_72371_1_) public void setWhiteListEnabled(boolean p_72371_1_)
@@ -1032,12 +1566,30 @@ @@ -1032,11 +1570,29 @@
public void removeAllPlayers() public void removeAllPlayers()
{ {
- for (int i = 0; i < this.playerEntityList.size(); ++i) - for (int i = 0; i < this.playerEntityList.size(); ++i)
+ while (!this.playerEntityList.isEmpty()) + while (!this.playerEntityList.isEmpty())
{ + {
- ((EntityPlayerMP)this.playerEntityList.get(i)).playerNetServerHandler.kickPlayerFromServer("Server closed");
+ // Spigot start + // Spigot start
+ EntityPlayerMP p = (EntityPlayerMP) this.playerEntityList.get(0); + EntityPlayerMP p = (EntityPlayerMP) this.playerEntityList.get(0);
+ p.playerNetServerHandler.kickPlayerFromServer(this.mcServer.server.getShutdownMessage()); + p.playerNetServerHandler.kickPlayerFromServer(this.mcServer.server.getShutdownMessage());
@ -958,19 +960,25 @@
+ this.playerEntityList.remove(0); // Prevent shutdown hang if already disconnected + this.playerEntityList.remove(0); // Prevent shutdown hang if already disconnected
+ } + }
+ // Spigot end + // Spigot end
} + }
} + }
+
+ // CraftBukkit start - Support multi-line messages + // CraftBukkit start - Support multi-line messages
+ public void sendMessage(IChatComponent[] ichatbasecomponent) + public void sendMessage(IChatComponent[] ichatbasecomponent)
+ { + {
+ for (IChatComponent component : ichatbasecomponent) + for (IChatComponent component : ichatbasecomponent)
+ { {
- ((EntityPlayerMP)this.playerEntityList.get(i)).playerNetServerHandler.kickPlayerFromServer("Server closed");
+ sendChatMsgImpl(component, true); + sendChatMsgImpl(component, true);
+ } }
+ } }
+ // CraftBukkit end + // CraftBukkit end
+
public void sendChatMsgImpl(IChatComponent p_148544_1_, boolean p_148544_2_) public void sendChatMsgImpl(IChatComponent p_148544_1_, boolean p_148544_2_)
{ {
this.mcServer.addChatMessage(p_148544_1_); @@ -1103,4 +1659,4 @@
{
return this.whiteListEnforced;
}
-}
+}

Loading…
Cancel
Save