SPIGOT-3034: PlayerKickEvent.setLeaveMessage(String) doesn't actually do anything

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2022-03-16 19:49:07 +11:00
parent c46dd07f70
commit 6796896e63
3 changed files with 92 additions and 90 deletions

View File

@@ -34,7 +34,7 @@
public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -194,6 +221,20 @@
@@ -194,6 +221,21 @@
public int latency;
public boolean wonGame;
@@ -50,12 +50,13 @@
+ public boolean joining = true;
+ public boolean sentListPacket = false;
+ public Integer clientViewDistance;
+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // CraftBukkit end
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -256,12 +297,56 @@
@@ -256,12 +298,56 @@
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
this.maxUpStep = 1.0F;
this.fudgeSpawnLocation(worldserver);
@@ -113,7 +114,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -319,17 +404,26 @@
@@ -319,17 +405,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@@ -141,7 +142,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -356,7 +450,20 @@
@@ -356,7 +451,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@@ -163,7 +164,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -374,7 +481,7 @@
@@ -374,7 +482,7 @@
nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ());
nbttagcompound.putBoolean("SpawnForced", this.respawnForced);
nbttagcompound.putFloat("SpawnAngle", this.respawnAngle);
@@ -172,7 +173,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -382,9 +489,33 @@
@@ -382,9 +490,33 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
@@ -206,7 +207,7 @@
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
float f1 = (f - 1.0F) / f;
@@ -443,6 +574,11 @@
@@ -443,6 +575,11 @@
@Override
public void tick() {
@@ -218,7 +219,7 @@
this.gameMode.tick();
--this.spawnInvulnerableTime;
if (this.invulnerableTime > 0) {
@@ -498,7 +634,7 @@
@@ -498,7 +635,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@@ -227,7 +228,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -529,6 +665,12 @@
@@ -529,6 +666,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@@ -240,7 +241,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -543,6 +685,16 @@
@@ -543,6 +686,16 @@
CriterionTriggers.LOCATION.trigger(this);
}
@@ -257,7 +258,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -585,7 +737,8 @@
@@ -585,7 +738,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
@@ -267,7 +268,7 @@
scoreboardscore.setScore(i);
});
}
@@ -593,9 +746,47 @@
@@ -593,9 +747,47 @@
@Override
public void die(DamageSource damagesource) {
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
@@ -317,7 +318,7 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> {
if (!future.isSuccess()) {
@@ -629,12 +820,18 @@
@@ -629,12 +821,18 @@
if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@@ -340,7 +341,7 @@
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -671,10 +868,12 @@
@@ -671,10 +869,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
@@ -355,7 +356,7 @@
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -692,7 +891,8 @@
@@ -692,7 +892,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
@@ -365,7 +366,7 @@
}
}
@@ -736,18 +936,20 @@
@@ -736,18 +937,20 @@
}
private boolean isPvpAllowed() {
@@ -389,7 +390,7 @@
} else {
return shapedetectorshape;
}
@@ -756,11 +958,20 @@
@@ -756,11 +959,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@@ -413,7 +414,7 @@
this.unRide();
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -771,6 +982,8 @@
@@ -771,6 +983,8 @@
return this;
} else {
@@ -422,7 +423,7 @@
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true));
@@ -780,22 +993,52 @@
@@ -780,22 +994,52 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@@ -481,7 +482,7 @@
worldserver1.getProfiler().pop();
this.triggerDimensionChangeTriggers(worldserver1);
this.connection.send(new PacketPlayOutAbilities(this.getAbilities()));
@@ -813,12 +1056,31 @@
@@ -813,12 +1057,31 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -513,7 +514,7 @@
private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
@@ -835,17 +1097,17 @@
@@ -835,17 +1098,17 @@
}
@Override
@@ -536,7 +537,7 @@
}
return optional1;
@@ -855,13 +1117,21 @@
@@ -855,13 +1118,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level.dimension();
@@ -561,7 +562,7 @@
this.enteredNetherPosition = null;
}
@@ -878,12 +1148,10 @@
@@ -878,12 +1149,10 @@
this.containerMenu.broadcastChanges();
}
@@ -577,7 +578,7 @@
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
} else if (!this.bedInRange(blockposition, enumdirection)) {
return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY);
@@ -907,7 +1175,36 @@
@@ -907,7 +1176,36 @@
}
}
@@ -615,7 +616,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -920,9 +1217,8 @@
@@ -920,9 +1218,8 @@
return either;
}
}
@@ -626,7 +627,7 @@
}
@Override
@@ -949,6 +1245,24 @@
@@ -949,6 +1246,24 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@@ -651,7 +652,7 @@
if (this.isSleeping()) {
this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
}
@@ -1030,8 +1344,9 @@
@@ -1030,8 +1345,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos()));
}
@@ -662,7 +663,7 @@
}
@Override
@@ -1039,13 +1354,35 @@
@@ -1039,13 +1355,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@@ -698,7 +699,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage((new ChatMessage("container.spectatorCantOpen")).withStyle(EnumChatFormat.RED), true);
@@ -1053,9 +1390,11 @@
@@ -1053,9 +1391,11 @@
return OptionalInt.empty();
} else {
@@ -712,7 +713,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1068,13 +1407,24 @@
@@ -1068,13 +1408,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@@ -739,7 +740,7 @@
this.initMenu(this.containerMenu);
}
@@ -1097,6 +1447,7 @@
@@ -1097,6 +1448,7 @@
@Override
public void closeContainer() {
@@ -747,7 +748,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1126,7 +1477,7 @@
@@ -1126,7 +1478,7 @@
@Override
public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i);
@@ -756,7 +757,7 @@
scoreboardscore.add(i);
});
}
@@ -1134,7 +1485,7 @@
@@ -1134,7 +1486,7 @@
@Override
public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0);
@@ -765,7 +766,7 @@
}
@Override
@@ -1150,7 +1501,7 @@
@@ -1150,7 +1502,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
@@ -774,7 +775,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1185,8 +1536,17 @@
@@ -1185,8 +1537,17 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@@ -792,7 +793,7 @@
@Override
public void displayClientMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.sendMessage(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT, SystemUtils.NIL_UUID);
@@ -1240,7 +1600,7 @@
@@ -1240,7 +1601,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -801,7 +802,7 @@
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
@@ -1367,7 +1727,20 @@
@@ -1367,7 +1728,20 @@
return s;
}
@@ -822,7 +823,7 @@
this.chatVisibility = packetplayinsettings.chatVisibility();
this.canChatColor = packetplayinsettings.chatColors();
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
@@ -1438,7 +1811,7 @@
@@ -1438,7 +1812,7 @@
this.camera = (Entity) (entity == null ? this : entity);
if (entity1 != this.camera) {
this.connection.send(new PacketPlayOutCamera(this.camera));
@@ -831,7 +832,7 @@
}
}
@@ -1467,7 +1840,7 @@
@@ -1467,7 +1841,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@@ -840,7 +841,7 @@
}
@Override
@@ -1488,9 +1861,16 @@
@@ -1488,9 +1862,16 @@
return this.advancements;
}
@@ -857,7 +858,7 @@
if (worldserver == this.level) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1510,6 +1890,9 @@
@@ -1510,6 +1891,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@@ -867,7 +868,7 @@
}
@@ -1668,4 +2051,145 @@
@@ -1668,4 +2052,145 @@
public boolean allowsListing() {
return this.allowsListing;
}