Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
Brutally enforce the passing of enderchest to CraftPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
robotia committed Mar 15, 2016
1 parent d75f648 commit f0dfe2b
Showing 1 changed file with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.potion.PotionEffect;
import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective;
@@ -58,15 +61,41 @@
@@ -58,15 +61,43 @@
import net.minecraft.world.Teleporter;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
Expand All @@ -41,6 +41,8 @@
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
Expand All @@ -59,7 +61,7 @@
public abstract class ServerConfigurationManager
{
public static final File field_152613_a = new File("banned-players.json");
@@ -82,8 +111,8 @@
@@ -82,8 +113,8 @@
private final UserListOps ops;
private final UserListWhitelist whiteListedPlayers;
private final Map field_148547_k;
Expand All @@ -70,7 +72,7 @@
protected int maxPlayers;
private int viewDistance;
private WorldSettings.GameType gameType;
@@ -91,8 +120,17 @@
@@ -91,8 +122,17 @@
private int playerPingIndex;
private static final String __OBFID = "CL_00001423";

Expand All @@ -88,7 +90,7 @@
this.bannedPlayers = new UserListBans(field_152613_a);
this.bannedIPs = new BanList(field_152614_b);
this.ops = new UserListOps(field_152615_c);
@@ -131,12 +169,32 @@
@@ -131,12 +171,32 @@
s1 = p_72355_1_.getSocketAddress().toString();
}

Expand Down Expand Up @@ -123,31 +125,31 @@
nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8)));
nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ));
nethandlerplayserver.sendPacket(new S39PacketPlayerAbilities(p_72355_2_.capabilities));
@@ -145,6 +203,7 @@
@@ -145,6 +205,7 @@
p_72355_2_.func_147099_x().func_150884_b(p_72355_2_);
this.func_96456_a((ServerScoreboard)worldserver.getScoreboard(), p_72355_2_);
this.mcServer.func_147132_au();
+ /* CraftBukkit start - login message is handled in the event
ChatComponentTranslation chatcomponenttranslation;

if (!p_72355_2_.getCommandSenderName().equalsIgnoreCase(s))
@@ -158,6 +217,7 @@
@@ -158,6 +219,7 @@

chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW);
this.sendChatMsg(chatcomponenttranslation);
+ // CraftBukkit end*/
this.playerLoggedIn(p_72355_2_);
nethandlerplayserver.setPlayerLocation(p_72355_2_.posX, p_72355_2_.posY, p_72355_2_.posZ, p_72355_2_.rotationYaw, p_72355_2_.rotationPitch);
this.updateTimeAndWeatherForPlayer(p_72355_2_, worldserver);
@@ -172,6 +232,7 @@
@@ -172,6 +234,7 @@
while (iterator.hasNext())
{
PotionEffect potioneffect = (PotionEffect)iterator.next();
+ try { Potion p = Potion.potionTypes[potioneffect.getPotionID()]; } catch(Exception e){continue;} // Thermos handle corrupt potion data
nethandlerplayserver.sendPacket(new S1DPacketEntityEffect(p_72355_2_.getEntityId(), potioneffect));
}

@@ -192,7 +253,7 @@
@@ -192,7 +255,7 @@
}
}

Expand All @@ -156,15 +158,15 @@
{
HashSet hashset = new HashSet();
Iterator iterator = p_96456_1_.getTeams().iterator();
@@ -225,6 +286,7 @@
@@ -225,6 +288,7 @@

public void setPlayerManager(WorldServer[] p_72364_1_)
{
+ if (this.playerNBTManagerObj != null) return; // CraftBukkit
this.playerNBTManagerObj = p_72364_1_[0].getSaveHandler().getSaveHandler();
}

@@ -248,7 +310,7 @@
@@ -248,7 +312,7 @@

public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP p_72380_1_)
{
Expand All @@ -173,15 +175,15 @@
NBTTagCompound nbttagcompound1;

if (p_72380_1_.getCommandSenderName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null)
@@ -279,6 +341,7 @@
@@ -279,6 +343,7 @@
return ((SaveHandler)this.playerNBTManagerObj).getPlayerNBT(player);
}
}
+
protected void writePlayerData(EntityPlayerMP p_72391_1_)
{
if (p_72391_1_.playerNetServerHandler == null) return;
@@ -294,18 +357,61 @@
@@ -294,18 +359,61 @@

public void playerLoggedIn(EntityPlayerMP p_72377_1_)
{
Expand Down Expand Up @@ -247,7 +249,7 @@
}

public void updatePlayerPertinentChunks(EntityPlayerMP p_72358_1_)
@@ -313,14 +419,33 @@
@@ -313,14 +421,33 @@
p_72358_1_.getServerForPlayer().getPlayerManager().updatePlayerPertinentChunks(p_72358_1_);
}

Expand Down Expand Up @@ -283,7 +285,7 @@
{
worldserver.removePlayerEntityDangerously(p_72367_1_.ridingEntity);
logger.debug("removing player mount");
@@ -329,9 +454,35 @@
@@ -329,9 +456,35 @@
worldserver.removeEntity(p_72367_1_);
worldserver.getPlayerManager().removePlayer(p_72367_1_);
this.playerEntityList.remove(p_72367_1_);
Expand Down Expand Up @@ -322,7 +324,7 @@
}

public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_)
@@ -352,7 +503,7 @@
@@ -352,7 +505,7 @@
}
else if (!this.func_152607_e(p_148542_2_))
{
Expand All @@ -331,7 +333,7 @@
}
else if (this.bannedIPs.func_152708_a(p_148542_1_))
{
@@ -368,10 +519,75 @@
@@ -368,10 +521,75 @@
}
else
{
Expand Down Expand Up @@ -408,7 +410,7 @@
public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_)
{
UUID uuid = EntityPlayer.func_146094_a(p_148545_1_);
@@ -410,80 +626,305 @@
@@ -410,80 +628,305 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
}

Expand Down Expand Up @@ -559,8 +561,8 @@
+ CraftPlayer cp = (CraftPlayer)par1EntityPlayerMP.bukkitEntity;
+ if ( cp != null )
+ {
+ try { cp.enderChest.inventory = entityplayermp1.getInventoryEnderChest(); } catch(Exception e) {}
+ try { cp.inventory.inventory = entityplayermp1.inventory; } catch(Exception e) {}
+ try { cp.enderChest.inventory = entityplayermp1.getInventoryEnderChest(); } catch(Exception e) {cp.enderChest = new CraftInventory(entityplayermp1.getInventoryEnderChest());}
+ try { cp.inventory.inventory = entityplayermp1.inventory; } catch(Exception e) {cp.inventory = new CraftInventoryPlayer(entityplayermp1.inventory); }
+ entityplayermp1.bukkitEntity = cp;
+ cp.setHandle(entityplayermp1);
+ }
Expand Down Expand Up @@ -752,7 +754,7 @@
return entityplayermp1;
}

@@ -492,34 +933,112 @@
@@ -492,34 +935,112 @@
transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter());
}

Expand Down Expand Up @@ -885,7 +887,7 @@
}

public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter)
@@ -605,6 +1124,109 @@
@@ -605,6 +1126,109 @@
p_82448_1_.setWorld(p_82448_4_);
}

Expand Down Expand Up @@ -995,7 +997,7 @@
public void sendPlayerInfoToAllPlayers()
{
if (++this.playerPingIndex > 600)
@@ -612,11 +1234,13 @@
@@ -612,11 +1236,13 @@
this.playerPingIndex = 0;
}

Expand All @@ -1009,7 +1011,7 @@
}

public void sendPacketToAllPlayers(Packet p_148540_1_)
@@ -877,13 +1501,24 @@
@@ -877,13 +1503,24 @@
for (int j = 0; j < this.playerEntityList.size(); ++j)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);
Expand All @@ -1036,7 +1038,7 @@
if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
{
entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
@@ -941,13 +1576,16 @@
@@ -941,13 +1578,16 @@
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(8, p_72354_2_.getWeightedThunderStrength(1.0F)));
Expand All @@ -1054,7 +1056,7 @@
p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem));
}

@@ -961,9 +1599,17 @@
@@ -961,9 +1601,17 @@
return this.maxPlayers;
}

Expand All @@ -1073,7 +1075,7 @@
}

public void setWhiteListEnabled(boolean p_72371_1_)
@@ -1032,12 +1678,30 @@
@@ -1032,12 +1680,30 @@

public void removeAllPlayers()
{
Expand Down

0 comments on commit f0dfe2b

Please sign in to comment.