3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00

SPIGOT-5052: PlayerPortalEvent not called when nether is disabled

Dieser Commit ist enthalten in:
md_5 2019-06-12 18:24:57 +10:00
Ursprung 28ea3fd105
Commit 9e95da121e

Datei anzeigen

@ -135,13 +135,13 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -166,7 +257,33 @@ @@ -166,8 +257,34 @@
} }
nbttagcompound.set("recipeBook", this.recipeBook.save()); nbttagcompound.set("recipeBook", this.recipeBook.save());
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
+ } }
+
+ // CraftBukkit start - World fallback code, either respawn location or global spawn + // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) { + public void spawnIn(World world) {
+ super.spawnIn(world); + super.spawnIn(world);
@ -164,11 +164,12 @@
+ } + }
+ this.dimension = ((WorldServer) this.world).getWorldProvider().getDimensionManager(); + this.dimension = ((WorldServer) this.world).getWorldProvider().getDimensionManager();
+ this.playerInteractManager.a((WorldServer) world); + this.playerInteractManager.a((WorldServer) world);
} + }
+ // CraftBukkit end + // CraftBukkit end
+
public void a(int i) { public void a(int i) {
float f = (float) this.getExpToLevel(); float f = (float) this.getExpToLevel();
float f1 = (f - 1.0F) / f;
@@ -221,6 +338,11 @@ @@ -221,6 +338,11 @@
@Override @Override
@ -348,7 +349,7 @@
this.decouple(); this.decouple();
this.getWorldServer().removePlayer(this); this.getWorldServer().removePlayer(this);
if (!this.viewingCredits) { if (!this.viewingCredits) {
@@ -518,10 +706,16 @@ @@ -518,10 +706,12 @@
} else { } else {
WorldServer worldserver = this.server.getWorldServer(dimensionmanager1); WorldServer worldserver = this.server.getWorldServer(dimensionmanager1);
@ -358,15 +359,11 @@
WorldData worlddata = this.world.getWorldData(); WorldData worlddata = this.world.getWorldData();
+ // CraftBukkit start + // CraftBukkit start
+ if (worldserver1 == null) {
+ return null;
+ }
+
+ /* + /*
this.playerConnection.sendPacket(new PacketPlayOutRespawn(dimensionmanager, worlddata.getType(), this.playerInteractManager.getGameMode())); this.playerConnection.sendPacket(new PacketPlayOutRespawn(dimensionmanager, worlddata.getType(), this.playerInteractManager.getGameMode()));
this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
PlayerList playerlist = this.server.getPlayerList(); PlayerList playerlist = this.server.getPlayerList();
@@ -529,6 +723,8 @@ @@ -529,6 +719,8 @@
playerlist.d(this); playerlist.d(this);
worldserver.removePlayer(this); worldserver.removePlayer(this);
this.dead = false; this.dead = false;
@ -375,13 +372,21 @@
double d0 = this.locX; double d0 = this.locX;
double d1 = this.locY; double d1 = this.locY;
double d2 = this.locZ; double d2 = this.locZ;
@@ -555,6 +751,52 @@ @@ -538,6 +730,7 @@
float f2 = f1;
worldserver.getMethodProfiler().enter("moving");
+ if (worldserver1 == null) { } else // CraftBukkit - empty to fall through to null to event
if (dimensionmanager1 == DimensionManager.OVERWORLD && dimensionmanager == DimensionManager.NETHER) {
this.cu = new Vec3D(this.locX, this.locY, this.locZ);
d0 /= 8.0D;
@@ -555,6 +748,52 @@
f = 0.0F; f = 0.0F;
} }
+ // CraftBukkit start + // CraftBukkit start
+ Location enter = this.getBukkitEntity().getLocation(); + Location enter = this.getBukkitEntity().getLocation();
+ Location exit = new Location(worldserver1.getWorld(), d0, d1, d2, f1, f); + Location exit = (worldserver1 == null) ? null : new Location(worldserver1.getWorld(), d0, d1, d2, f1, f);
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause); + PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause);
+ Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null) { + if (event.isCancelled() || event.getTo() == null) {
@ -428,7 +433,7 @@
this.setPositionRotation(d0, d1, d2, f1, f); this.setPositionRotation(d0, d1, d2, f1, f);
worldserver.getMethodProfiler().exit(); worldserver.getMethodProfiler().exit();
worldserver.getMethodProfiler().enter("placing"); worldserver.getMethodProfiler().enter("placing");
@@ -566,12 +808,13 @@ @@ -566,12 +805,13 @@
d0 = MathHelper.a(d0, d4, d6); d0 = MathHelper.a(d0, d4, d6);
d2 = MathHelper.a(d2, d5, d7); d2 = MathHelper.a(d2, d5, d7);
this.setPositionRotation(d0, d1, d2, f1, f); this.setPositionRotation(d0, d1, d2, f1, f);
@ -443,7 +448,7 @@
for (int l = -2; l <= 2; ++l) { for (int l = -2; l <= 2; ++l) {
for (int i1 = -2; i1 <= 2; ++i1) { for (int i1 = -2; i1 <= 2; ++i1) {
@@ -581,11 +824,20 @@ @@ -581,11 +821,20 @@
int i2 = k + i1 * 0 - l * 1; int i2 = k + i1 * 0 - l * 1;
boolean flag2 = j1 < 0; boolean flag2 = j1 < 0;
@ -465,7 +470,7 @@
this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F); this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F);
this.setMot(Vec3D.a); this.setMot(Vec3D.a);
} else if (!worldserver1.getTravelAgent().a(this, f2)) { } else if (!worldserver1.getTravelAgent().a(this, f2)) {
@@ -614,11 +866,16 @@ @@ -614,11 +863,16 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastHealthSent = -1.0F; this.lastHealthSent = -1.0F;
this.lastFoodSent = -1; this.lastFoodSent = -1;
@ -483,7 +488,7 @@
DimensionManager dimensionmanager = worldserver.worldProvider.getDimensionManager(); DimensionManager dimensionmanager = worldserver.worldProvider.getDimensionManager();
DimensionManager dimensionmanager1 = this.world.worldProvider.getDimensionManager(); DimensionManager dimensionmanager1 = this.world.worldProvider.getDimensionManager();
@@ -655,9 +912,16 @@ @@ -655,9 +909,16 @@
this.activeContainer.c(); this.activeContainer.c();
} }
@ -502,7 +507,7 @@
this.a(StatisticList.SLEEP_IN_BED); this.a(StatisticList.SLEEP_IN_BED);
CriterionTriggers.q.a(this); CriterionTriggers.q.a(this);
}); });
@@ -665,6 +929,7 @@ @@ -665,6 +926,7 @@
@Override @Override
public void wakeup(boolean flag, boolean flag1, boolean flag2) { public void wakeup(boolean flag, boolean flag1, boolean flag2) {
@ -510,7 +515,7 @@
if (this.isSleeping()) { if (this.isSleeping()) {
this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2)); this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2));
} }
@@ -752,8 +1017,9 @@ @@ -752,8 +1014,9 @@
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
} }
@ -521,7 +526,7 @@
} }
@Override @Override
@@ -768,6 +1034,17 @@ @@ -768,6 +1031,17 @@
this.nextContainerCounter(); this.nextContainerCounter();
Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this); Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this);
@ -539,7 +544,7 @@
if (container == null) { if (container == null) {
if (this.isSpectator()) { if (this.isSpectator()) {
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true);
@@ -775,9 +1052,11 @@ @@ -775,9 +1049,11 @@
return OptionalInt.empty(); return OptionalInt.empty();
} else { } else {
@ -553,7 +558,7 @@
return OptionalInt.of(this.containerCounter); return OptionalInt.of(this.containerCounter);
} }
} }
@@ -790,13 +1069,24 @@ @@ -790,13 +1066,24 @@
@Override @Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -580,7 +585,7 @@
this.activeContainer.addSlotListener(this); this.activeContainer.addSlotListener(this);
} }
@@ -841,6 +1131,11 @@ @@ -841,6 +1128,11 @@
public void a(Container container, NonNullList<ItemStack> nonnulllist) { public void a(Container container, NonNullList<ItemStack> nonnulllist) {
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
@ -592,7 +597,7 @@
} }
@Override @Override
@@ -850,6 +1145,7 @@ @@ -850,6 +1142,7 @@
@Override @Override
public void closeInventory() { public void closeInventory() {
@ -600,7 +605,7 @@
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
this.m(); this.m();
} }
@@ -884,7 +1180,7 @@ @@ -884,7 +1177,7 @@
@Override @Override
public void a(Statistic<?> statistic, int i) { public void a(Statistic<?> statistic, int i) {
this.serverStatisticManager.b(this, statistic, i); this.serverStatisticManager.b(this, statistic, i);
@ -609,7 +614,7 @@
scoreboardscore.addScore(i); scoreboardscore.addScore(i);
}); });
} }
@@ -892,7 +1188,7 @@ @@ -892,7 +1185,7 @@
@Override @Override
public void a(Statistic<?> statistic) { public void a(Statistic<?> statistic) {
this.serverStatisticManager.setStatistic(this, statistic, 0); this.serverStatisticManager.setStatistic(this, statistic, 0);
@ -618,24 +623,25 @@
} }
@Override @Override
@@ -941,7 +1237,16 @@ @@ -941,8 +1234,17 @@
public void triggerHealthUpdate() { public void triggerHealthUpdate() {
this.lastHealthSent = -1.0E8F; this.lastHealthSent = -1.0E8F;
+ this.lastSentExp = -1; // CraftBukkit - Added to reset + this.lastSentExp = -1; // CraftBukkit - Added to reset
+ } }
+
+ // CraftBukkit start - Support multi-line messages + // CraftBukkit start - Support multi-line messages
+ public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
+ for (IChatBaseComponent component : ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) {
+ this.sendMessage(component); + this.sendMessage(component);
+ } + }
} + }
+ // CraftBukkit end + // CraftBukkit end
+
@Override @Override
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
@@ -996,12 +1301,14 @@ this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT));
@@ -996,12 +1298,14 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastHealthSent = -1.0F; this.lastHealthSent = -1.0F;
this.lastFoodSent = -1; this.lastFoodSent = -1;
@ -651,7 +657,7 @@
} }
@Override @Override
@@ -1063,6 +1370,18 @@ @@ -1063,6 +1367,18 @@
@Override @Override
public void a(EnumGamemode enumgamemode) { public void a(EnumGamemode enumgamemode) {
@ -670,7 +676,7 @@
this.playerInteractManager.setGameMode(enumgamemode); this.playerInteractManager.setGameMode(enumgamemode);
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
if (enumgamemode == EnumGamemode.SPECTATOR) { if (enumgamemode == EnumGamemode.SPECTATOR) {
@@ -1113,6 +1432,17 @@ @@ -1113,6 +1429,17 @@
} }
public void a(PacketPlayInSettings packetplayinsettings) { public void a(PacketPlayInSettings packetplayinsettings) {
@ -688,7 +694,7 @@
this.locale = packetplayinsettings.b(); this.locale = packetplayinsettings.b();
this.ck = packetplayinsettings.d(); this.ck = packetplayinsettings.d();
this.cl = packetplayinsettings.e(); this.cl = packetplayinsettings.e();
@@ -1149,13 +1479,13 @@ @@ -1149,13 +1476,13 @@
if (entity instanceof EntityHuman) { if (entity instanceof EntityHuman) {
this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()})); this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()}));
} else { } else {
@ -704,7 +710,7 @@
} }
@Override @Override
@@ -1179,7 +1509,7 @@ @@ -1179,7 +1506,7 @@
this.spectatedEntity = (Entity) (entity == null ? this : entity); this.spectatedEntity = (Entity) (entity == null ? this : entity);
if (entity1 != this.spectatedEntity) { if (entity1 != this.spectatedEntity) {
this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity)); this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
@ -713,7 +719,7 @@
} }
} }
@@ -1208,7 +1538,7 @@ @@ -1208,7 +1535,7 @@
@Nullable @Nullable
public IChatBaseComponent getPlayerListName() { public IChatBaseComponent getPlayerListName() {
@ -722,7 +728,7 @@
} }
@Override @Override
@@ -1226,21 +1556,33 @@ @@ -1226,21 +1553,33 @@
} }
public void J() { public void J() {
@ -756,7 +762,7 @@
if (worldserver == this.world) { if (worldserver == this.world) {
this.playerConnection.a(d0, d1, d2, f, f1); this.playerConnection.a(d0, d1, d2, f, f1);
} else { } else {
@@ -1263,6 +1605,9 @@ @@ -1263,6 +1602,9 @@
this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().a(this, worldserver);
this.server.getPlayerList().updateClient(this); this.server.getPlayerList().updateClient(this);
} }
@ -766,7 +772,7 @@
} }
@@ -1314,4 +1659,144 @@ @@ -1314,4 +1656,144 @@
return entityitem; return entityitem;
} }
} }