mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Add API for quit reason
This commit is contained in:
parent
5b1f73e2dc
commit
4b0e4655fd
4 changed files with 107 additions and 84 deletions
|
@ -65,7 +65,26 @@
|
|||
if (this.delayedDisconnect != null) {
|
||||
this.disconnect(this.delayedDisconnect);
|
||||
}
|
||||
@@ -176,6 +202,7 @@
|
||||
@@ -141,8 +167,10 @@
|
||||
|
||||
this.handlingFault = true;
|
||||
if (this.channel.isOpen()) {
|
||||
+ net.minecraft.server.level.ServerPlayer player = this.getPlayer(); // Paper - Add API for quit reason
|
||||
if (throwable instanceof TimeoutException) {
|
||||
Connection.LOGGER.debug("Timeout", throwable);
|
||||
+ if (player != null) player.quitReason = org.bukkit.event.player.PlayerQuitEvent.QuitReason.TIMED_OUT; // Paper - Add API for quit reason
|
||||
this.disconnect((Component) Component.translatable("disconnect.timeout"));
|
||||
} else {
|
||||
MutableComponent ichatmutablecomponent = Component.translatable("disconnect.genericReason", "Internal Exception: " + String.valueOf(throwable));
|
||||
@@ -155,6 +183,7 @@
|
||||
disconnectiondetails = new DisconnectionDetails(ichatmutablecomponent);
|
||||
}
|
||||
|
||||
+ if (player != null) player.quitReason = org.bukkit.event.player.PlayerQuitEvent.QuitReason.ERRONEOUS_STATE; // Paper - Add API for quit reason
|
||||
if (flag) {
|
||||
Connection.LOGGER.debug("Failed to sent packet", throwable);
|
||||
if (this.getSending() == PacketFlow.CLIENTBOUND) {
|
||||
@@ -176,6 +205,7 @@
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +92,7 @@
|
|||
}
|
||||
|
||||
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) {
|
||||
@@ -205,7 +232,7 @@
|
||||
@@ -205,7 +235,7 @@
|
||||
}
|
||||
|
||||
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
|
||||
|
@ -82,7 +101,7 @@
|
|||
}
|
||||
|
||||
private void validateListener(ProtocolInfo<?> state, PacketListener listener) {
|
||||
@@ -418,12 +445,26 @@
|
||||
@@ -418,12 +448,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +128,7 @@
|
|||
}
|
||||
|
||||
if (!this.isConnected() && !this.disconnectionHandled) {
|
||||
@@ -431,7 +472,7 @@
|
||||
@@ -431,7 +475,7 @@
|
||||
}
|
||||
|
||||
if (this.channel != null) {
|
||||
|
@ -118,7 +137,7 @@
|
|||
}
|
||||
|
||||
if (this.tickCount++ % 20 == 0) {
|
||||
@@ -464,12 +505,15 @@
|
||||
@@ -464,12 +508,15 @@
|
||||
}
|
||||
|
||||
public void disconnect(DisconnectionDetails disconnectionInfo) {
|
||||
|
@ -135,7 +154,7 @@
|
|||
this.disconnectionDetails = disconnectionInfo;
|
||||
}
|
||||
|
||||
@@ -537,7 +581,7 @@
|
||||
@@ -537,7 +584,7 @@
|
||||
}
|
||||
|
||||
public void configurePacketHandler(ChannelPipeline pipeline) {
|
||||
|
@ -144,7 +163,7 @@
|
|||
public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception {
|
||||
super.write(channelhandlercontext, object, channelpromise);
|
||||
}
|
||||
@@ -661,6 +705,27 @@
|
||||
@@ -661,6 +708,27 @@
|
||||
|
||||
packetlistener1.onDisconnect(disconnectiondetails);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
@Nullable
|
||||
private Vec3 startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -258,7 +293,35 @@
|
||||
@@ -258,7 +293,36 @@
|
||||
private final CommandSource commandSource;
|
||||
private int containerCounter;
|
||||
public boolean wonGame;
|
||||
|
@ -146,11 +146,12 @@
|
|||
+ public boolean isRealPlayer; // Paper
|
||||
+ public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
|
||||
+ public @Nullable String clientBrandName = null; // Paper - Brand support
|
||||
+ public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
|
||||
+
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||
this.chatVisibility = ChatVisiblity.FULL;
|
||||
@@ -266,7 +329,7 @@
|
||||
@@ -266,7 +330,7 @@
|
||||
this.canChatColor = true;
|
||||
this.lastActionTime = Util.getMillis();
|
||||
this.requestedViewDistance = 2;
|
||||
|
@ -159,7 +160,7 @@
|
|||
this.lastSectionPos = SectionPos.of(0, 0, 0);
|
||||
this.chunkTrackingView = ChunkTrackingView.EMPTY;
|
||||
this.respawnDimension = Level.OVERWORLD;
|
||||
@@ -340,6 +403,13 @@
|
||||
@@ -340,6 +404,13 @@
|
||||
public void sendSystemMessage(Component message) {
|
||||
ServerPlayer.this.sendSystemMessage(message);
|
||||
}
|
||||
|
@ -173,7 +174,7 @@
|
|||
};
|
||||
this.textFilter = server.createTextFilterForPlayer(this);
|
||||
this.gameMode = server.createGameModeForPlayer(this);
|
||||
@@ -349,17 +419,71 @@
|
||||
@@ -349,17 +420,71 @@
|
||||
this.server = server;
|
||||
this.stats = server.getPlayerList().getPlayerStats(this);
|
||||
this.advancements = server.getPlayerList().getPlayerAdvancements(this);
|
||||
|
@ -188,8 +189,8 @@
|
|||
+ this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper
|
||||
+ this.bukkitPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // Use method to resend items in hands in case of client desync, because the item use got cancelled.
|
||||
+ // For example, when cancelling the leash event
|
||||
+ public void resendItemInHands() {
|
||||
|
@ -235,9 +236,9 @@
|
|||
+ }
|
||||
+
|
||||
+ return blockposition;
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
@Override
|
||||
public BlockPos adjustSpawnLocation(ServerLevel world, BlockPos basePos) {
|
||||
AABB axisalignedbb = this.getDimensions(Pose.STANDING).makeBoundingBox(Vec3.ZERO);
|
||||
|
@ -248,7 +249,7 @@
|
|||
int i = Math.max(0, this.server.getSpawnRadius(world));
|
||||
int j = Mth.floor(world.getWorldBorder().getDistanceToBorder((double) basePos.getX(), (double) basePos.getZ()));
|
||||
|
||||
@@ -395,14 +519,20 @@
|
||||
@@ -395,14 +520,20 @@
|
||||
|
||||
Objects.requireNonNull(basePos);
|
||||
crashreportsystemdetails.setDetail("Origin", basePos::toString);
|
||||
|
@ -271,7 +272,7 @@
|
|||
});
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
@@ -440,7 +570,7 @@
|
||||
@@ -440,7 +571,7 @@
|
||||
dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(NbtOps.INSTANCE, nbt.get("warden_spawn_tracker")));
|
||||
logger = ServerPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
|
@ -280,7 +281,7 @@
|
|||
this.wardenSpawnTracker = wardenspawntracker;
|
||||
});
|
||||
}
|
||||
@@ -457,17 +587,26 @@
|
||||
@@ -457,17 +588,26 @@
|
||||
return this.server.getRecipeManager().byKey(resourcekey).isPresent();
|
||||
});
|
||||
}
|
||||
|
@ -308,7 +309,7 @@
|
|||
Logger logger1 = ServerPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger1);
|
||||
@@ -482,7 +621,7 @@
|
||||
@@ -482,7 +622,7 @@
|
||||
dataresult = BlockPos.CODEC.parse(NbtOps.INSTANCE, nbtbase);
|
||||
logger = ServerPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
|
@ -317,7 +318,7 @@
|
|||
this.raidOmenPosition = blockposition;
|
||||
});
|
||||
}
|
||||
@@ -492,7 +631,7 @@
|
||||
@@ -492,7 +632,7 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag nbt) {
|
||||
super.addAdditionalSaveData(nbt);
|
||||
|
@ -326,7 +327,7 @@
|
|||
Logger logger = ServerPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -526,6 +665,7 @@
|
||||
@@ -526,6 +666,7 @@
|
||||
nbt.put("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
|
@ -334,7 +335,7 @@
|
|||
|
||||
nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
if (this.raidOmenPosition != null) {
|
||||
@@ -544,7 +684,20 @@
|
||||
@@ -544,7 +685,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
|
@ -356,7 +357,7 @@
|
|||
CompoundTag nbttagcompound1 = new CompoundTag();
|
||||
CompoundTag nbttagcompound2 = new CompoundTag();
|
||||
|
||||
@@ -564,7 +717,7 @@
|
||||
@@ -564,7 +718,7 @@
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
CompoundTag nbttagcompound = ((CompoundTag) nbt.get()).getCompound("RootVehicle");
|
||||
Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver, EntitySpawnReason.LOAD, (entity1) -> {
|
||||
|
@ -365,7 +366,7 @@
|
|||
});
|
||||
|
||||
if (entity == null) {
|
||||
@@ -598,12 +751,12 @@
|
||||
@@ -598,12 +752,12 @@
|
||||
|
||||
if (!this.isPassenger()) {
|
||||
ServerPlayer.LOGGER.warn("Couldn't reattach entity to player");
|
||||
|
@ -380,7 +381,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -625,7 +778,7 @@
|
||||
@@ -625,7 +779,7 @@
|
||||
CompoundTag nbttagcompound1 = new CompoundTag();
|
||||
|
||||
entityenderpearl.save(nbttagcompound1);
|
||||
|
@ -389,7 +390,7 @@
|
|||
Logger logger = ServerPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -651,7 +804,7 @@
|
||||
@@ -651,7 +805,7 @@
|
||||
nbttaglist.forEach((nbtbase1) -> {
|
||||
if (nbtbase1 instanceof CompoundTag nbttagcompound) {
|
||||
if (nbttagcompound.contains("ender_pearl_dimension")) {
|
||||
|
@ -398,7 +399,7 @@
|
|||
Logger logger = ServerPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -686,6 +839,29 @@
|
||||
@@ -686,6 +840,29 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -428,7 +429,7 @@
|
|||
public void setExperiencePoints(int points) {
|
||||
float f = (float) this.getXpNeededForNextLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -744,6 +920,11 @@
|
||||
@@ -744,6 +921,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
@ -440,7 +441,7 @@
|
|||
this.tickClientLoadTimeout();
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
@@ -751,9 +932,13 @@
|
||||
@@ -751,9 +933,13 @@
|
||||
--this.invulnerableTime;
|
||||
}
|
||||
|
||||
|
@ -457,7 +458,7 @@
|
|||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
|
||||
@@ -807,7 +992,7 @@
|
||||
@@ -807,7 +993,7 @@
|
||||
|
||||
public void doTick() {
|
||||
try {
|
||||
|
@ -466,7 +467,7 @@
|
|||
super.tick();
|
||||
}
|
||||
|
||||
@@ -820,7 +1005,7 @@
|
||||
@@ -820,7 +1006,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
|
@ -475,7 +476,7 @@
|
|||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -851,6 +1036,12 @@
|
||||
@@ -851,6 +1037,12 @@
|
||||
this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float) this.lastRecordedExperience));
|
||||
}
|
||||
|
||||
|
@ -488,10 +489,12 @@
|
|||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float) this.lastRecordedLevel));
|
||||
@@ -865,6 +1056,20 @@
|
||||
CriteriaTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
@@ -863,8 +1055,22 @@
|
||||
|
||||
if (this.tickCount % 20 == 0) {
|
||||
CriteriaTriggers.LOCATION.trigger(this);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
|
||||
+ if (this.oldLevel == -1) {
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
|
@ -500,8 +503,8 @@
|
|||
+ if (this.oldLevel != this.experienceLevel) {
|
||||
+ CraftEventFactory.callPlayerLevelChangeEvent(this.getBukkitEntity(), this.oldLevel, this.experienceLevel);
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ if (this.getBukkitEntity().hasClientWorldBorder()) {
|
||||
+ ((CraftWorldBorder) this.getBukkitEntity().getWorldBorder()).getHandle().tick();
|
||||
+ }
|
||||
|
@ -509,7 +512,7 @@
|
|||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
|
||||
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Player being ticked");
|
||||
@@ -893,7 +1098,7 @@
|
||||
@@ -893,7 +1099,7 @@
|
||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (this.tickCount % 20 == 0) {
|
||||
if (this.getHealth() < this.getMaxHealth()) {
|
||||
|
@ -518,7 +521,7 @@
|
|||
}
|
||||
|
||||
float f = this.foodData.getSaturationLevel();
|
||||
@@ -946,19 +1151,103 @@
|
||||
@@ -946,19 +1152,103 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(ObjectiveCriteria criterion, int score) {
|
||||
|
@ -626,7 +629,7 @@
|
|||
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
|
||||
boolean flag1 = true;
|
||||
String s = ichatbasecomponent.getString(256);
|
||||
@@ -988,12 +1277,23 @@
|
||||
@@ -988,12 +1278,23 @@
|
||||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
|
@ -654,7 +657,7 @@
|
|||
LivingEntity entityliving = this.getKillCredit();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -1028,10 +1328,12 @@
|
||||
@@ -1028,10 +1329,12 @@
|
||||
public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
|
||||
if (entityKilled != this) {
|
||||
super.awardKillScore(entityKilled, damageSource);
|
||||
|
@ -670,7 +673,7 @@
|
|||
} else {
|
||||
this.awardStat(Stats.MOB_KILLS);
|
||||
}
|
||||
@@ -1049,7 +1351,8 @@
|
||||
@@ -1049,7 +1352,8 @@
|
||||
int i = scoreboardteam.getColor().getId();
|
||||
|
||||
if (i >= 0 && i < criterions.length) {
|
||||
|
@ -680,7 +683,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1062,8 +1365,8 @@
|
||||
@@ -1062,8 +1366,8 @@
|
||||
} else {
|
||||
Entity entity = source.getEntity();
|
||||
|
||||
|
@ -691,7 +694,7 @@
|
|||
|
||||
if (!this.canHarmPlayer(entityhuman)) {
|
||||
return false;
|
||||
@@ -1074,8 +1377,8 @@
|
||||
@@ -1074,8 +1378,8 @@
|
||||
AbstractArrow entityarrow = (AbstractArrow) entity;
|
||||
Entity entity1 = entityarrow.getOwner();
|
||||
|
||||
|
@ -702,7 +705,7 @@
|
|||
|
||||
if (!this.canHarmPlayer(entityhuman1)) {
|
||||
return false;
|
||||
@@ -1083,38 +1386,78 @@
|
||||
@@ -1083,38 +1387,78 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -789,7 +792,7 @@
|
|||
}
|
||||
|
||||
public static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(ServerLevel world, BlockPos pos, float spawnAngle, boolean spawnForced, boolean alive) {
|
||||
@@ -1129,11 +1472,11 @@
|
||||
@@ -1129,11 +1473,11 @@
|
||||
}
|
||||
|
||||
return optional.map((vec3d) -> {
|
||||
|
@ -803,7 +806,7 @@
|
|||
});
|
||||
} else if (!spawnForced) {
|
||||
return Optional.empty();
|
||||
@@ -1142,7 +1485,7 @@
|
||||
@@ -1142,7 +1486,7 @@
|
||||
BlockState iblockdata1 = world.getBlockState(pos.above());
|
||||
boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1);
|
||||
|
||||
|
@ -812,7 +815,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1160,6 +1503,7 @@
|
||||
@@ -1160,6 +1504,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public ServerPlayer teleport(TeleportTransition teleportTarget) {
|
||||
|
@ -820,7 +823,7 @@
|
|||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -1169,39 +1513,78 @@
|
||||
@@ -1169,39 +1514,78 @@
|
||||
|
||||
ServerLevel worldserver = teleportTarget.newLevel();
|
||||
ServerLevel worldserver1 = this.serverLevel();
|
||||
|
@ -907,7 +910,7 @@
|
|||
this.connection.resetPosition();
|
||||
worldserver.addDuringTeleport(this);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -1215,12 +1598,30 @@
|
||||
@@ -1215,12 +1599,30 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
|
@ -938,7 +941,7 @@
|
|||
public void forceSetRotation(float yaw, float pitch) {
|
||||
this.connection.send(new ClientboundPlayerRotationPacket(yaw, pitch));
|
||||
}
|
||||
@@ -1228,13 +1629,21 @@
|
||||
@@ -1228,13 +1630,21 @@
|
||||
public void triggerDimensionChangeTriggers(ServerLevel origin) {
|
||||
ResourceKey<Level> resourcekey = origin.dimension();
|
||||
ResourceKey<Level> resourcekey1 = this.level().dimension();
|
||||
|
@ -963,7 +966,7 @@
|
|||
this.enteredNetherPosition = null;
|
||||
}
|
||||
|
||||
@@ -1251,36 +1660,63 @@
|
||||
@@ -1251,36 +1661,63 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1045,7 @@
|
|||
this.awardStat(Stats.SLEEP_IN_BED);
|
||||
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -1293,9 +1729,8 @@
|
||||
@@ -1293,9 +1730,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
|
@ -1053,7 +1056,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1322,13 +1757,31 @@
|
||||
@@ -1322,13 +1758,31 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean skipSleepTimer, boolean updateSleepingPlayers) {
|
||||
|
@ -1086,7 +1089,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1387,8 +1840,9 @@
|
||||
@@ -1387,8 +1841,9 @@
|
||||
this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front));
|
||||
}
|
||||
|
||||
|
@ -1097,7 +1100,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1396,13 +1850,35 @@
|
||||
@@ -1396,13 +1851,35 @@
|
||||
if (factory == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
|
@ -1133,7 +1136,7 @@
|
|||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true);
|
||||
@@ -1410,9 +1886,11 @@
|
||||
@@ -1410,9 +1887,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
|
@ -1147,7 +1150,7 @@
|
|||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1425,15 +1903,26 @@
|
||||
@@ -1425,15 +1904,26 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(AbstractHorse horse, Container inventory) {
|
||||
|
@ -1177,7 +1180,7 @@
|
|||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1456,6 +1945,13 @@
|
||||
@@ -1456,6 +1946,13 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
|
@ -1191,7 +1194,7 @@
|
|||
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
@@ -1485,19 +1981,19 @@
|
||||
@@ -1485,19 +1982,19 @@
|
||||
i = Math.round((float) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.awardStat(Stats.SWIM_ONE_CM, i);
|
||||
|
@ -1214,7 +1217,7 @@
|
|||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (deltaY > 0.0D) {
|
||||
@@ -1508,13 +2004,13 @@
|
||||
@@ -1508,13 +2005,13 @@
|
||||
if (i > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(Stats.SPRINT_ONE_CM, i);
|
||||
|
@ -1231,7 +1234,7 @@
|
|||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1557,7 +2053,7 @@
|
||||
@@ -1557,7 +2054,7 @@
|
||||
@Override
|
||||
public void awardStat(Stat<?> stat, int amount) {
|
||||
this.stats.increment(this, stat, amount);
|
||||
|
@ -1240,7 +1243,7 @@
|
|||
scoreaccess.add(amount);
|
||||
});
|
||||
}
|
||||
@@ -1565,7 +2061,7 @@
|
||||
@@ -1565,7 +2062,7 @@
|
||||
@Override
|
||||
public void resetStat(Stat<?> stat) {
|
||||
this.stats.setValue(this, stat, 0);
|
||||
|
@ -1249,7 +1252,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1597,9 +2093,9 @@
|
||||
@@ -1597,9 +2094,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(Stats.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
|
@ -1261,7 +1264,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1613,6 +2109,13 @@
|
||||
@@ -1613,6 +2110,13 @@
|
||||
public void disconnect() {
|
||||
this.disconnected = true;
|
||||
this.ejectPassengers();
|
||||
|
@ -1275,7 +1278,7 @@
|
|||
if (this.isSleeping()) {
|
||||
this.stopSleepInBed(true, false);
|
||||
}
|
||||
@@ -1625,6 +2128,7 @@
|
||||
@@ -1625,6 +2129,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
|
@ -1283,7 +1286,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1661,7 +2165,7 @@
|
||||
@@ -1661,7 +2166,7 @@
|
||||
this.onUpdateAbilities();
|
||||
if (alive) {
|
||||
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
|
||||
|
@ -1292,7 +1295,7 @@
|
|||
this.setHealth(oldPlayer.getHealth());
|
||||
this.foodData = oldPlayer.foodData;
|
||||
Iterator iterator = oldPlayer.getActiveEffects().iterator();
|
||||
@@ -1669,7 +2173,7 @@
|
||||
@@ -1669,7 +2174,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
|
||||
|
||||
|
@ -1301,7 +1304,7 @@
|
|||
}
|
||||
|
||||
this.getInventory().replaceWith(oldPlayer.getInventory());
|
||||
@@ -1680,7 +2184,7 @@
|
||||
@@ -1680,7 +2185,7 @@
|
||||
this.portalProcess = oldPlayer.portalProcess;
|
||||
} else {
|
||||
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
|
||||
|
@ -1310,7 +1313,7 @@
|
|||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) {
|
||||
this.getInventory().replaceWith(oldPlayer.getInventory());
|
||||
this.experienceLevel = oldPlayer.experienceLevel;
|
||||
@@ -1696,7 +2200,7 @@
|
||||
@@ -1696,7 +2201,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
|
@ -1319,7 +1322,7 @@
|
|||
this.seenCredits = oldPlayer.seenCredits;
|
||||
this.enteredNetherPosition = oldPlayer.enteredNetherPosition;
|
||||
this.chunkTrackingView = oldPlayer.chunkTrackingView;
|
||||
@@ -1752,19 +2256,19 @@
|
||||
@@ -1752,19 +2257,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1343,7 +1346,7 @@
|
|||
}
|
||||
|
||||
return flag1;
|
||||
@@ -1861,8 +2365,13 @@
|
||||
@@ -1861,8 +2366,13 @@
|
||||
}
|
||||
|
||||
public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) {
|
||||
|
@ -1358,7 +1361,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1878,7 +2387,36 @@
|
||||
@@ -1878,7 +2388,36 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientOptions) {
|
||||
|
@ -1395,7 +1398,7 @@
|
|||
this.requestedViewDistance = clientOptions.viewDistance();
|
||||
this.chatVisibility = clientOptions.chatVisibility();
|
||||
this.canChatColor = clientOptions.chatColors();
|
||||
@@ -1957,12 +2495,27 @@
|
||||
@@ -1957,12 +2496,27 @@
|
||||
|
||||
this.camera = (Entity) (entity == null ? this : entity);
|
||||
if (entity1 != this.camera) {
|
||||
|
@ -1424,7 +1427,7 @@
|
|||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1999,11 +2552,11 @@
|
||||
@@ -1999,11 +2553,11 @@
|
||||
|
||||
@Nullable
|
||||
public Component getTabListDisplayName() {
|
||||
|
@ -1438,7 +1441,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -2046,17 +2599,43 @@
|
||||
@@ -2046,17 +2600,43 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
|
||||
|
@ -1489,7 +1492,7 @@
|
|||
} else {
|
||||
this.respawnPosition = null;
|
||||
this.respawnDimension = Level.OVERWORLD;
|
||||
@@ -2088,18 +2667,44 @@
|
||||
@@ -2088,18 +2668,44 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1538,7 +1541,7 @@
|
|||
}
|
||||
|
||||
this.awardStat(Stats.DROP);
|
||||
@@ -2275,9 +2880,15 @@
|
||||
@@ -2275,9 +2881,15 @@
|
||||
|
||||
@Override
|
||||
public void stopRiding() {
|
||||
|
@ -1555,7 +1558,7 @@
|
|||
if (entity instanceof LivingEntity entityliving) {
|
||||
Iterator iterator = entityliving.getActiveEffects().iterator();
|
||||
|
||||
@@ -2375,10 +2986,12 @@
|
||||
@@ -2375,10 +2987,12 @@
|
||||
return TicketType.ENDER_PEARL.timeout();
|
||||
}
|
||||
|
||||
|
@ -1571,7 +1574,7 @@
|
|||
}
|
||||
|
||||
private static float calculateLookAtYaw(Vec3 respawnPos, BlockPos currentPos) {
|
||||
@@ -2387,4 +3000,147 @@
|
||||
@@ -2387,4 +3001,147 @@
|
||||
return (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
+ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
+ ResourceLocation identifier = packet.payload().type().id();
|
||||
+ ByteBuf payload = ((DiscardedPayload)packet.payload()).data();
|
||||
|
||||
+
|
||||
+ if (identifier.equals(ServerCommonPacketListenerImpl.CUSTOM_REGISTER)) {
|
||||
+ try {
|
||||
+ String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
|
||||
|
@ -193,7 +193,7 @@
|
|||
+ this.disconnect(Component.literal("Invalid custom payload!"));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public final boolean isDisconnected() {
|
||||
|
@ -281,7 +281,7 @@
|
|||
if (packet.isTerminal()) {
|
||||
this.close();
|
||||
}
|
||||
@@ -175,20 +328,72 @@
|
||||
@@ -175,20 +328,73 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,6 +342,7 @@
|
|||
+
|
||||
+ private void disconnect0(DisconnectionDetails disconnectiondetails) {
|
||||
+ // CraftBukkit end
|
||||
+ this.player.quitReason = org.bukkit.event.player.PlayerQuitEvent.QuitReason.KICKED; // Paper - Add API for quit reason
|
||||
+ this.connection.send(new ClientboundDisconnectPacket(disconnectiondetails.reason()), PacketSendListener.thenRun(() -> {
|
||||
+ this.connection.disconnect(disconnectiondetails);
|
||||
}));
|
||||
|
|
|
@ -401,7 +401,7 @@
|
|||
+ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
|
||||
+ }
|
||||
+
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); // Paper - Adventure
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName())), entityplayer.quitReason); // Paper - Adventure & Add API for quit reason
|
||||
+ this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||
+ entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
+
|
||||
|
|
Loading…
Reference in a new issue