Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
SPIGOT-2997: Explicitly disallow invalid tiles to be opened
Dieser Commit ist enthalten in:
Ursprung
270755dc06
Commit
27dd3ca45f
@ -1,10 +1,11 @@
|
|||||||
--- a/net/minecraft/server/EntityPlayer.java
|
--- a/net/minecraft/server/EntityPlayer.java
|
||||||
+++ b/net/minecraft/server/EntityPlayer.java
|
+++ b/net/minecraft/server/EntityPlayer.java
|
||||||
@@ -12,6 +12,19 @@
|
@@ -12,6 +12,20 @@
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
|
+import com.google.common.base.Preconditions;
|
||||||
+import org.bukkit.Bukkit;
|
+import org.bukkit.Bukkit;
|
||||||
+import org.bukkit.WeatherType;
|
+import org.bukkit.WeatherType;
|
||||||
+import org.bukkit.craftbukkit.CraftWorld;
|
+import org.bukkit.craftbukkit.CraftWorld;
|
||||||
@ -20,7 +21,7 @@
|
|||||||
public class EntityPlayer extends EntityHuman implements ICrafting {
|
public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||||
|
|
||||||
private static final Logger bR = LogManager.getLogger();
|
private static final Logger bR = LogManager.getLogger();
|
||||||
@@ -44,6 +57,18 @@
|
@@ -44,6 +58,18 @@
|
||||||
public int ping;
|
public int ping;
|
||||||
public boolean viewingCredits;
|
public boolean viewingCredits;
|
||||||
|
|
||||||
@ -39,7 +40,7 @@
|
|||||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
||||||
super(worldserver, gameprofile);
|
super(worldserver, gameprofile);
|
||||||
playerinteractmanager.player = this;
|
playerinteractmanager.player = this;
|
||||||
@@ -67,13 +92,18 @@
|
@@ -67,13 +93,18 @@
|
||||||
|
|
||||||
this.server = minecraftserver;
|
this.server = minecraftserver;
|
||||||
this.bU = minecraftserver.getPlayerList().a((EntityHuman) this);
|
this.bU = minecraftserver.getPlayerList().a((EntityHuman) this);
|
||||||
@ -59,7 +60,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
@@ -86,6 +116,7 @@
|
@@ -86,6 +117,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void a(DataConverterManager dataconvertermanager) {
|
public static void a(DataConverterManager dataconvertermanager) {
|
||||||
@@ -119,8 +150,33 @@
|
@@ -119,8 +151,33 @@
|
||||||
nbttagcompound1.set("Entity", nbttagcompound2);
|
nbttagcompound1.set("Entity", nbttagcompound2);
|
||||||
nbttagcompound.set("RootVehicle", nbttagcompound1);
|
nbttagcompound.set("RootVehicle", nbttagcompound1);
|
||||||
}
|
}
|
||||||
@ -101,7 +102,7 @@
|
|||||||
|
|
||||||
public void levelDown(int i) {
|
public void levelDown(int i) {
|
||||||
super.levelDown(i);
|
super.levelDown(i);
|
||||||
@@ -151,6 +207,11 @@
|
@@ -151,6 +208,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void A_() {
|
public void A_() {
|
||||||
@ -113,7 +114,7 @@
|
|||||||
this.playerInteractManager.a();
|
this.playerInteractManager.a();
|
||||||
--this.invulnerableTicks;
|
--this.invulnerableTicks;
|
||||||
if (this.noDamageTicks > 0) {
|
if (this.noDamageTicks > 0) {
|
||||||
@@ -210,7 +271,7 @@
|
@@ -210,7 +272,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getHealth() != this.lastHealthSent || this.cc != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cd) {
|
if (this.getHealth() != this.lastHealthSent || this.cc != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cd) {
|
||||||
@ -122,7 +123,7 @@
|
|||||||
this.lastHealthSent = this.getHealth();
|
this.lastHealthSent = this.getHealth();
|
||||||
this.cc = this.foodData.getFoodLevel();
|
this.cc = this.foodData.getFoodLevel();
|
||||||
this.cd = this.foodData.getSaturationLevel() == 0.0F;
|
this.cd = this.foodData.getSaturationLevel() == 0.0F;
|
||||||
@@ -231,6 +292,12 @@
|
@@ -231,6 +293,12 @@
|
||||||
this.a(IScoreboardCriteria.i, MathHelper.f((float) this.bX));
|
this.a(IScoreboardCriteria.i, MathHelper.f((float) this.bX));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +136,7 @@
|
|||||||
if (this.getArmorStrength() != this.bY) {
|
if (this.getArmorStrength() != this.bY) {
|
||||||
this.bY = this.getArmorStrength();
|
this.bY = this.getArmorStrength();
|
||||||
this.a(IScoreboardCriteria.j, MathHelper.f((float) this.bY));
|
this.a(IScoreboardCriteria.j, MathHelper.f((float) this.bY));
|
||||||
@@ -255,6 +322,16 @@
|
@@ -255,6 +323,16 @@
|
||||||
this.o();
|
this.o();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +153,7 @@
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
|
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
|
||||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
|
||||||
@@ -265,12 +342,11 @@
|
@@ -265,12 +343,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void a(IScoreboardCriteria iscoreboardcriteria, int i) {
|
private void a(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||||
@ -167,7 +168,7 @@
|
|||||||
|
|
||||||
scoreboardscore.setScore(i);
|
scoreboardscore.setScore(i);
|
||||||
}
|
}
|
||||||
@@ -319,31 +395,61 @@
|
@@ -319,31 +396,61 @@
|
||||||
boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
|
boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
|
||||||
|
|
||||||
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
|
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
|
||||||
@ -189,15 +190,15 @@
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage();
|
+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage();
|
||||||
|
+
|
||||||
|
+ String deathmessage = chatmessage.toPlainText();
|
||||||
|
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
|
||||||
|
|
||||||
- if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
|
- if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
|
||||||
- if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
|
- if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
|
||||||
- this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage());
|
- this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage());
|
||||||
- } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
|
- } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
|
||||||
- this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage());
|
- this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage());
|
||||||
+ String deathmessage = chatmessage.toPlainText();
|
|
||||||
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
|
|
||||||
+
|
|
||||||
+ String deathMessage = event.getDeathMessage();
|
+ String deathMessage = event.getDeathMessage();
|
||||||
+
|
+
|
||||||
+ if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override?
|
+ if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override?
|
||||||
@ -243,7 +244,7 @@
|
|||||||
|
|
||||||
scoreboardscore.incrementScore();
|
scoreboardscore.incrementScore();
|
||||||
}
|
}
|
||||||
@@ -402,13 +508,15 @@
|
@@ -402,13 +509,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPvP() {
|
private boolean canPvP() {
|
||||||
@ -261,7 +262,7 @@
|
|||||||
this.world.kill(this);
|
this.world.kill(this);
|
||||||
if (!this.viewingCredits) {
|
if (!this.viewingCredits) {
|
||||||
this.viewingCredits = true;
|
this.viewingCredits = true;
|
||||||
@@ -429,7 +537,10 @@
|
@@ -429,7 +538,10 @@
|
||||||
this.b((Statistic) AchievementList.y);
|
this.b((Statistic) AchievementList.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +274,7 @@
|
|||||||
this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false));
|
this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false));
|
||||||
this.lastSentExp = -1;
|
this.lastSentExp = -1;
|
||||||
this.lastHealthSent = -1.0F;
|
this.lastHealthSent = -1.0F;
|
||||||
@@ -474,6 +585,7 @@
|
@@ -474,6 +586,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(boolean flag, boolean flag1, boolean flag2) {
|
public void a(boolean flag, boolean flag1, boolean flag2) {
|
||||||
@ -281,7 +282,7 @@
|
|||||||
if (this.isSleeping()) {
|
if (this.isSleeping()) {
|
||||||
this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
|
this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
|
||||||
}
|
}
|
||||||
@@ -552,23 +664,52 @@
|
@@ -552,23 +665,55 @@
|
||||||
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
|
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,6 +324,9 @@
|
|||||||
+
|
+
|
||||||
+ Container container;
|
+ Container container;
|
||||||
+ if (iinventory instanceof ITileEntityContainer) {
|
+ if (iinventory instanceof ITileEntityContainer) {
|
||||||
|
+ if (iinventory instanceof TileEntity) {
|
||||||
|
+ Preconditions.checkArgument(((TileEntity) iinventory).getWorld() != null, "Container must have world to be opened");
|
||||||
|
+ }
|
||||||
+ container = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
|
+ container = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ container = new ContainerChest(this.inventory, iinventory, this);
|
+ container = new ContainerChest(this.inventory, iinventory, this);
|
||||||
@ -337,7 +341,7 @@
|
|||||||
if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) {
|
if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) {
|
||||||
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true);
|
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true);
|
||||||
} else {
|
} else {
|
||||||
@@ -582,18 +723,21 @@
|
@@ -582,18 +727,21 @@
|
||||||
if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) {
|
if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) {
|
||||||
this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), (byte) 2));
|
this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), (byte) 2));
|
||||||
this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.Y, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F));
|
this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.Y, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F));
|
||||||
@ -361,7 +365,7 @@
|
|||||||
|
|
||||||
this.activeContainer.windowId = this.containerCounter;
|
this.activeContainer.windowId = this.containerCounter;
|
||||||
this.activeContainer.addSlotListener(this);
|
this.activeContainer.addSlotListener(this);
|
||||||
@@ -601,8 +745,14 @@
|
@@ -601,8 +749,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openTrade(IMerchant imerchant) {
|
public void openTrade(IMerchant imerchant) {
|
||||||
@ -377,7 +381,7 @@
|
|||||||
this.activeContainer.windowId = this.containerCounter;
|
this.activeContainer.windowId = this.containerCounter;
|
||||||
this.activeContainer.addSlotListener(this);
|
this.activeContainer.addSlotListener(this);
|
||||||
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e();
|
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e();
|
||||||
@@ -622,13 +772,20 @@
|
@@ -622,13 +776,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||||
@ -399,7 +403,7 @@
|
|||||||
this.activeContainer.windowId = this.containerCounter;
|
this.activeContainer.windowId = this.containerCounter;
|
||||||
this.activeContainer.addSlotListener(this);
|
this.activeContainer.addSlotListener(this);
|
||||||
}
|
}
|
||||||
@@ -665,6 +822,11 @@
|
@@ -665,6 +826,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()));
|
||||||
@ -411,7 +415,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setContainerData(Container container, int i, int j) {
|
public void setContainerData(Container container, int i, int j) {
|
||||||
@@ -679,6 +841,7 @@
|
@@ -679,6 +845,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeInventory() {
|
public void closeInventory() {
|
||||||
@ -419,7 +423,7 @@
|
|||||||
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
|
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
|
||||||
this.s();
|
this.s();
|
||||||
}
|
}
|
||||||
@@ -760,7 +923,16 @@
|
@@ -760,7 +927,16 @@
|
||||||
|
|
||||||
public void triggerHealthUpdate() {
|
public void triggerHealthUpdate() {
|
||||||
this.lastHealthSent = -1.0E8F;
|
this.lastHealthSent = -1.0E8F;
|
||||||
@ -436,7 +440,7 @@
|
|||||||
|
|
||||||
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||||
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, (byte) (flag ? 2 : 0)));
|
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, (byte) (flag ? 2 : 0)));
|
||||||
@@ -821,6 +993,8 @@
|
@@ -821,6 +997,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(EnumGamemode enumgamemode) {
|
public void a(EnumGamemode enumgamemode) {
|
||||||
@ -445,7 +449,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) {
|
||||||
@@ -831,6 +1005,7 @@
|
@@ -831,6 +1009,7 @@
|
||||||
|
|
||||||
this.updateAbilities();
|
this.updateAbilities();
|
||||||
this.cw();
|
this.cw();
|
||||||
@ -453,7 +457,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSpectator() {
|
public boolean isSpectator() {
|
||||||
@@ -846,6 +1021,7 @@
|
@@ -846,6 +1025,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean a(int i, String s) {
|
public boolean a(int i, String s) {
|
||||||
@ -461,7 +465,7 @@
|
|||||||
if ("seed".equals(s) && !this.server.aa()) {
|
if ("seed".equals(s) && !this.server.aa()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) {
|
} else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) {
|
||||||
@@ -859,6 +1035,15 @@
|
@@ -859,6 +1039,15 @@
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -477,7 +481,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String A() {
|
public String A() {
|
||||||
@@ -870,6 +1055,12 @@
|
@@ -870,6 +1059,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(PacketPlayInSettings packetplayinsettings) {
|
public void a(PacketPlayInSettings packetplayinsettings) {
|
||||||
@ -490,7 +494,7 @@
|
|||||||
this.locale = packetplayinsettings.a();
|
this.locale = packetplayinsettings.a();
|
||||||
this.cg = packetplayinsettings.c();
|
this.cg = packetplayinsettings.c();
|
||||||
this.ch = packetplayinsettings.d();
|
this.ch = packetplayinsettings.d();
|
||||||
@@ -958,7 +1149,7 @@
|
@@ -958,7 +1153,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public IChatBaseComponent getPlayerListName() {
|
public IChatBaseComponent getPlayerListName() {
|
||||||
@ -499,7 +503,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void a(EnumHand enumhand) {
|
public void a(EnumHand enumhand) {
|
||||||
@@ -975,11 +1166,150 @@
|
@@ -975,11 +1170,150 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void M() {
|
public void M() {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren