Fix kick event leave message not being sent

This commit is contained in:
Jake Potrebic 2021-07-07 16:19:41 -07:00
parent 485db97ad6
commit 818a84cfbe
4 changed files with 209 additions and 179 deletions

View file

@ -114,7 +114,7 @@
@Nullable
private Vec3 startingToFallPosition;
@Nullable
@@ -258,6 +293,35 @@
@@ -258,6 +293,34 @@
private final CommandSource commandSource;
private int containerCounter;
public boolean wonGame;
@ -141,7 +141,6 @@
+ public boolean joining = true;
+ public boolean sentListPacket = false;
+ public boolean supressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready
+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // CraftBukkit end
+ public boolean isRealPlayer; // Paper
+ public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
@ -150,7 +149,7 @@
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
@@ -266,7 +330,7 @@
@@ -266,7 +329,7 @@
this.canChatColor = true;
this.lastActionTime = Util.getMillis();
this.requestedViewDistance = 2;
@ -159,7 +158,7 @@
this.lastSectionPos = SectionPos.of(0, 0, 0);
this.chunkTrackingView = ChunkTrackingView.EMPTY;
this.respawnDimension = Level.OVERWORLD;
@@ -340,6 +404,13 @@
@@ -340,6 +403,13 @@
public void sendSystemMessage(Component message) {
ServerPlayer.this.sendSystemMessage(message);
}
@ -173,7 +172,7 @@
};
this.textFilter = server.createTextFilterForPlayer(this);
this.gameMode = server.createGameModeForPlayer(this);
@@ -349,17 +420,71 @@
@@ -349,17 +419,71 @@
this.server = server;
this.stats = server.getPlayerList().getPlayerStats(this);
this.advancements = server.getPlayerList().getPlayerAdvancements(this);
@ -188,8 +187,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 +234,9 @@
+ }
+
+ return blockposition;
+ }
}
+ // CraftBukkit end
+
@Override
public BlockPos adjustSpawnLocation(ServerLevel world, BlockPos basePos) {
AABB axisalignedbb = this.getDimensions(Pose.STANDING).makeBoundingBox(Vec3.ZERO);
@ -248,7 +247,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 +520,20 @@
@@ -395,14 +519,20 @@
Objects.requireNonNull(basePos);
crashreportsystemdetails.setDetail("Origin", basePos::toString);
@ -271,7 +270,7 @@
});
throw new ReportedException(crashreport);
}
@@ -440,7 +571,7 @@
@@ -440,7 +570,7 @@
dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(NbtOps.INSTANCE, nbt.get("warden_spawn_tracker")));
logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@ -280,7 +279,7 @@
this.wardenSpawnTracker = wardenspawntracker;
});
}
@@ -457,17 +588,26 @@
@@ -457,17 +587,26 @@
return this.server.getRecipeManager().byKey(resourcekey).isPresent();
});
}
@ -308,7 +307,7 @@
Logger logger1 = ServerPlayer.LOGGER;
Objects.requireNonNull(logger1);
@@ -482,7 +622,7 @@
@@ -482,7 +621,7 @@
dataresult = BlockPos.CODEC.parse(NbtOps.INSTANCE, nbtbase);
logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@ -317,7 +316,7 @@
this.raidOmenPosition = blockposition;
});
}
@@ -492,7 +632,7 @@
@@ -492,7 +631,7 @@
@Override
public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
@ -326,7 +325,7 @@
Logger logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -526,6 +666,7 @@
@@ -526,6 +665,7 @@
nbt.put("SpawnDimension", nbtbase);
});
}
@ -334,7 +333,7 @@
nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
if (this.raidOmenPosition != null) {
@@ -544,7 +685,20 @@
@@ -544,7 +684,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@ -356,7 +355,7 @@
CompoundTag nbttagcompound1 = new CompoundTag();
CompoundTag nbttagcompound2 = new CompoundTag();
@@ -564,7 +718,7 @@
@@ -564,7 +717,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 +364,7 @@
});
if (entity == null) {
@@ -598,12 +752,12 @@
@@ -598,12 +751,12 @@
if (!this.isPassenger()) {
ServerPlayer.LOGGER.warn("Couldn't reattach entity to player");
@ -380,7 +379,7 @@
}
}
}
@@ -625,7 +779,7 @@
@@ -625,7 +778,7 @@
CompoundTag nbttagcompound1 = new CompoundTag();
entityenderpearl.save(nbttagcompound1);
@ -389,7 +388,7 @@
Logger logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -651,7 +805,7 @@
@@ -651,7 +804,7 @@
nbttaglist.forEach((nbtbase1) -> {
if (nbtbase1 instanceof CompoundTag nbttagcompound) {
if (nbttagcompound.contains("ender_pearl_dimension")) {
@ -398,7 +397,7 @@
Logger logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -686,6 +840,29 @@
@@ -686,6 +839,29 @@
}
@ -428,7 +427,7 @@
public void setExperiencePoints(int points) {
float f = (float) this.getXpNeededForNextLevel();
float f1 = (f - 1.0F) / f;
@@ -744,6 +921,11 @@
@@ -744,6 +920,11 @@
@Override
public void tick() {
@ -440,7 +439,7 @@
this.tickClientLoadTimeout();
this.gameMode.tick();
this.wardenSpawnTracker.tick();
@@ -751,9 +933,13 @@
@@ -751,9 +932,13 @@
--this.invulnerableTime;
}
@ -457,7 +456,7 @@
this.containerMenu = this.inventoryMenu;
}
@@ -807,7 +993,7 @@
@@ -807,7 +992,7 @@
public void doTick() {
try {
@ -466,7 +465,7 @@
super.tick();
}
@@ -820,7 +1006,7 @@
@@ -820,7 +1005,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@ -475,7 +474,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -851,6 +1037,12 @@
@@ -851,6 +1036,12 @@
this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float) this.lastRecordedExperience));
}
@ -488,7 +487,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float) this.lastRecordedLevel));
@@ -865,6 +1057,20 @@
@@ -865,6 +1056,20 @@
CriteriaTriggers.LOCATION.trigger(this);
}
@ -509,7 +508,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -893,7 +1099,7 @@
@@ -893,7 +1098,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 +517,7 @@
}
float f = this.foodData.getSaturationLevel();
@@ -946,19 +1152,103 @@
@@ -946,19 +1151,103 @@
}
private void updateScoreForCriteria(ObjectiveCriteria criterion, int score) {
@ -626,7 +625,7 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true;
String s = ichatbasecomponent.getString(256);
@@ -988,12 +1278,23 @@
@@ -988,12 +1277,23 @@
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@ -654,7 +653,7 @@
LivingEntity entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -1028,10 +1329,12 @@
@@ -1028,10 +1328,12 @@
public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
if (entityKilled != this) {
super.awardKillScore(entityKilled, damageSource);
@ -670,7 +669,7 @@
} else {
this.awardStat(Stats.MOB_KILLS);
}
@@ -1049,7 +1352,8 @@
@@ -1049,7 +1351,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < criterions.length) {
@ -680,7 +679,7 @@
}
}
@@ -1062,8 +1366,8 @@
@@ -1062,8 +1365,8 @@
} else {
Entity entity = source.getEntity();
@ -691,7 +690,7 @@
if (!this.canHarmPlayer(entityhuman)) {
return false;
@@ -1074,8 +1378,8 @@
@@ -1074,8 +1377,8 @@
AbstractArrow entityarrow = (AbstractArrow) entity;
Entity entity1 = entityarrow.getOwner();
@ -702,7 +701,7 @@
if (!this.canHarmPlayer(entityhuman1)) {
return false;
@@ -1083,38 +1387,84 @@
@@ -1083,38 +1386,84 @@
}
}
@ -795,7 +794,7 @@
}
public static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(ServerLevel world, BlockPos pos, float spawnAngle, boolean spawnForced, boolean alive) {
@@ -1129,11 +1479,11 @@
@@ -1129,11 +1478,11 @@
}
return optional.map((vec3d) -> {
@ -809,7 +808,7 @@
});
} else if (!spawnForced) {
return Optional.empty();
@@ -1142,7 +1492,7 @@
@@ -1142,7 +1491,7 @@
BlockState iblockdata1 = world.getBlockState(pos.above());
boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1);
@ -818,7 +817,7 @@
}
}
@@ -1160,6 +1510,7 @@
@@ -1160,6 +1509,7 @@
@Nullable
@Override
public ServerPlayer teleport(TeleportTransition teleportTarget) {
@ -826,7 +825,7 @@
if (this.isRemoved()) {
return null;
} else {
@@ -1169,39 +1520,78 @@
@@ -1169,39 +1519,78 @@
ServerLevel worldserver = teleportTarget.newLevel();
ServerLevel worldserver1 = this.serverLevel();
@ -913,7 +912,7 @@
this.connection.resetPosition();
worldserver.addDuringTeleport(this);
gameprofilerfiller.pop();
@@ -1215,12 +1605,35 @@
@@ -1215,10 +1604,33 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -929,27 +928,25 @@
+ // Paper end - Reset shield blocking on dimension change
return this;
}
}
}
+ }
+ }
+
+ // CraftBukkit start
@Override
+ @Override
+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, TeleportCause cause, int searchRadius, int creationRadius) {
+ Location enter = this.getBukkitEntity().getLocation();
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) {
+ return null;
+ }
}
+ return new CraftPortalEvent(event);
+ }
+ // CraftBukkit end
+
+ @Override
public void forceSetRotation(float yaw, float pitch) {
this.connection.send(new ClientboundPlayerRotationPacket(yaw, pitch));
}
@@ -1228,13 +1641,21 @@
+ // CraftBukkit end
@Override
public void forceSetRotation(float yaw, float pitch) {
@@ -1228,13 +1640,21 @@
public void triggerDimensionChangeTriggers(ServerLevel origin) {
ResourceKey<Level> resourcekey = origin.dimension();
ResourceKey<Level> resourcekey1 = this.level().dimension();
@ -974,7 +971,7 @@
this.enteredNetherPosition = null;
}
@@ -1251,36 +1672,63 @@
@@ -1251,36 +1671,63 @@
this.containerMenu.broadcastChanges();
}
@ -1053,7 +1050,7 @@
this.awardStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -1293,9 +1741,8 @@
@@ -1293,9 +1740,8 @@
return either;
}
}
@ -1064,7 +1061,7 @@
}
@Override
@@ -1322,13 +1769,31 @@
@@ -1322,13 +1768,31 @@
@Override
public void stopSleepInBed(boolean skipSleepTimer, boolean updateSleepingPlayers) {
@ -1097,7 +1094,7 @@
}
}
@@ -1387,8 +1852,9 @@
@@ -1387,8 +1851,9 @@
this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front));
}
@ -1108,7 +1105,7 @@
}
@Override
@@ -1396,13 +1862,35 @@
@@ -1396,13 +1861,35 @@
if (factory == null) {
return OptionalInt.empty();
} else {
@ -1144,7 +1141,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true);
@@ -1410,9 +1898,11 @@
@@ -1410,9 +1897,11 @@
return OptionalInt.empty();
} else {
@ -1158,7 +1155,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1425,15 +1915,26 @@
@@ -1425,15 +1914,26 @@
@Override
public void openHorseInventory(AbstractHorse horse, Container inventory) {
@ -1188,7 +1185,7 @@
this.initMenu(this.containerMenu);
}
@@ -1456,6 +1957,13 @@
@@ -1456,6 +1956,13 @@
@Override
public void closeContainer() {
@ -1202,7 +1199,7 @@
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1485,19 +1993,19 @@
@@ -1485,19 +1992,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);
@ -1225,7 +1222,7 @@
}
} else if (this.onClimbable()) {
if (deltaY > 0.0D) {
@@ -1508,13 +2016,13 @@
@@ -1508,13 +2015,13 @@
if (i > 0) {
if (this.isSprinting()) {
this.awardStat(Stats.SPRINT_ONE_CM, i);
@ -1242,7 +1239,7 @@
}
}
} else if (this.isFallFlying()) {
@@ -1557,7 +2065,7 @@
@@ -1557,7 +2064,7 @@
@Override
public void awardStat(Stat<?> stat, int amount) {
this.stats.increment(this, stat, amount);
@ -1251,7 +1248,7 @@
scoreaccess.add(amount);
});
}
@@ -1565,7 +2073,7 @@
@@ -1565,7 +2072,7 @@
@Override
public void resetStat(Stat<?> stat) {
this.stats.setValue(this, stat, 0);
@ -1260,7 +1257,7 @@
}
@Override
@@ -1597,9 +2105,9 @@
@@ -1597,9 +2104,9 @@
super.jumpFromGround();
this.awardStat(Stats.JUMP);
if (this.isSprinting()) {
@ -1272,7 +1269,7 @@
}
}
@@ -1613,6 +2121,13 @@
@@ -1613,6 +2120,13 @@
public void disconnect() {
this.disconnected = true;
this.ejectPassengers();
@ -1286,7 +1283,7 @@
if (this.isSleeping()) {
this.stopSleepInBed(true, false);
}
@@ -1625,6 +2140,7 @@
@@ -1625,6 +2139,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@ -1294,7 +1291,7 @@
}
@Override
@@ -1661,7 +2177,7 @@
@@ -1661,7 +2176,7 @@
this.onUpdateAbilities();
if (alive) {
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
@ -1303,7 +1300,7 @@
this.setHealth(oldPlayer.getHealth());
this.foodData = oldPlayer.foodData;
Iterator iterator = oldPlayer.getActiveEffects().iterator();
@@ -1669,7 +2185,7 @@
@@ -1669,7 +2184,7 @@
while (iterator.hasNext()) {
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
@ -1312,7 +1309,7 @@
}
this.getInventory().replaceWith(oldPlayer.getInventory());
@@ -1680,7 +2196,7 @@
@@ -1680,7 +2195,7 @@
this.portalProcess = oldPlayer.portalProcess;
} else {
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
@ -1321,7 +1318,7 @@
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) {
this.getInventory().replaceWith(oldPlayer.getInventory());
this.experienceLevel = oldPlayer.experienceLevel;
@@ -1696,7 +2212,7 @@
@@ -1696,7 +2211,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -1330,7 +1327,7 @@
this.seenCredits = oldPlayer.seenCredits;
this.enteredNetherPosition = oldPlayer.enteredNetherPosition;
this.chunkTrackingView = oldPlayer.chunkTrackingView;
@@ -1752,19 +2268,19 @@
@@ -1752,19 +2267,19 @@
}
@Override
@ -1354,7 +1351,7 @@
}
return flag1;
@@ -1799,10 +2315,18 @@
@@ -1799,10 +2314,18 @@
}
public boolean setGameMode(GameType gameMode) {
@ -1375,7 +1372,7 @@
} else {
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId()));
if (gameMode == GameType.SPECTATOR) {
@@ -1818,7 +2342,7 @@
@@ -1818,7 +2341,7 @@
this.onUpdateAbilities();
this.updateEffectVisibility();
@ -1384,7 +1381,7 @@
}
}
@@ -1861,8 +2385,13 @@
@@ -1861,8 +2384,13 @@
}
public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) {
@ -1399,7 +1396,7 @@
}
}
@@ -1878,7 +2407,36 @@
@@ -1878,7 +2406,36 @@
}
public void updateOptions(ClientInformation clientOptions) {
@ -1436,7 +1433,7 @@
this.requestedViewDistance = clientOptions.viewDistance();
this.chatVisibility = clientOptions.chatVisibility();
this.canChatColor = clientOptions.chatColors();
@@ -1957,12 +2515,27 @@
@@ -1957,12 +2514,27 @@
this.camera = (Entity) (entity == null ? this : entity);
if (entity1 != this.camera) {
@ -1465,7 +1462,7 @@
}
if (entity != null) {
@@ -1999,11 +2572,11 @@
@@ -1999,11 +2571,11 @@
@Nullable
public Component getTabListDisplayName() {
@ -1479,7 +1476,7 @@
}
@Override
@@ -2046,17 +2619,43 @@
@@ -2046,17 +2618,43 @@
}
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
@ -1530,7 +1527,7 @@
} else {
this.respawnPosition = null;
this.respawnDimension = Level.OVERWORLD;
@@ -2088,18 +2687,44 @@
@@ -2088,18 +2686,44 @@
}
@Override
@ -1579,7 +1576,7 @@
}
this.awardStat(Stats.DROP);
@@ -2115,6 +2740,11 @@
@@ -2115,6 +2739,11 @@
return null;
} else {
double d0 = this.getEyeY() - 0.30000001192092896D;
@ -1591,7 +1588,7 @@
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), d0, this.getZ(), stack);
entityitem.setPickUpDelay(40);
@@ -2166,6 +2796,16 @@
@@ -2166,6 +2795,16 @@
}
public void loadGameTypes(@Nullable CompoundTag nbt) {
@ -1608,7 +1605,7 @@
this.gameMode.setGameModeForPlayer(this.calculateGameModeForNewPlayer(ServerPlayer.readPlayerMode(nbt, "playerGameType")), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType"));
}
@@ -2275,9 +2915,15 @@
@@ -2275,9 +2914,15 @@
@Override
public void stopRiding() {
@ -1625,7 +1622,7 @@
if (entity instanceof LivingEntity entityliving) {
Iterator iterator = entityliving.getActiveEffects().iterator();
@@ -2375,10 +3021,12 @@
@@ -2375,16 +3020,161 @@
return TicketType.ENDER_PEARL.timeout();
}
@ -1641,10 +1638,11 @@
}
private static float calculateLookAtYaw(Vec3 respawnPos, BlockPos currentPos) {
@@ -2387,4 +3035,147 @@
Vec3 vec3d1 = Vec3.atBottomCenterOf(currentPos).subtract(respawnPos).normalize();
return (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
}
}
+ }
+ }
+
+ // CraftBukkit start - Add per-player time and weather.
+ public long timeOffset = 0;
@ -1669,7 +1667,7 @@
+ public void setPlayerWeather(WeatherType type, boolean plugin) {
+ if (!plugin && this.weather != null) {
+ return;
+ }
}
+
+ if (plugin) {
+ this.weather = type;
@ -1680,7 +1678,7 @@
+ } else {
+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0));
+ }
+ }
}
+
+ private float pluginRainPosition;
+ private float pluginRainPositionPrevious;

View file

@ -111,7 +111,19 @@
private void close() {
if (!this.closed) {
this.closedListenerTime = Util.getMillis();
@@ -80,13 +131,18 @@
@@ -65,6 +116,11 @@
@Override
public void onDisconnect(DisconnectionDetails info) {
+ // Paper start - Fix kick event leave message not being sent
+ this.onDisconnect(info, null);
+ }
+ public void onDisconnect(DisconnectionDetails info, @Nullable net.kyori.adventure.text.Component quitMessage) {
+ // Paper end - Fix kick event leave message not being sent
if (this.isSingleplayerOwner()) {
ServerCommonPacketListenerImpl.LOGGER.info("Stopping singleplayer server as player logged out");
this.server.halt(false);
@@ -80,13 +136,18 @@
@Override
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
@ -131,7 +143,7 @@
}
}
@@ -94,38 +150,127 @@
@@ -94,38 +155,127 @@
@Override
public void handlePong(ServerboundPongPacket packet) {}
@ -269,7 +281,7 @@
Profiler.get().pop();
}
@@ -133,7 +278,7 @@
@@ -133,7 +283,7 @@
private boolean checkIfClosed(long time) {
if (this.closed) {
if (time - this.closedListenerTime >= 15000L) {
@ -278,7 +290,7 @@
}
return false;
@@ -156,6 +301,14 @@
@@ -156,6 +306,14 @@
}
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
@ -293,7 +305,7 @@
if (packet.isTerminal()) {
this.close();
}
@@ -175,20 +328,83 @@
@@ -175,20 +333,82 @@
}
}
@ -359,18 +371,17 @@
+ // Do not kick the player
+ return;
+ }
+ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // Send the possibly modified leave message
+ this.disconnect0(new DisconnectionDetails(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.reason()), disconnectionInfo.report(), disconnectionInfo.bugReportLink())); // Paper - Adventure
+ this.disconnect0(new DisconnectionDetails(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.reason()), disconnectionInfo.report(), disconnectionInfo.bugReportLink()), event.leaveMessage()); // Paper - Adventure & use kick event leave message
+ }
+
+ private void disconnect0(DisconnectionDetails disconnectiondetails) {
+ private void disconnect0(DisconnectionDetails disconnectiondetails, @Nullable net.kyori.adventure.text.Component leaveMessage) { // Paper - use kick event leave message
+ // 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);
}));
+ this.onDisconnect(disconnectiondetails); // CraftBukkit - fire quit instantly
+ this.onDisconnect(disconnectiondetails, leaveMessage); // CraftBukkit - fire quit instantly // Paper - use kick event leave message
this.connection.setReadOnly();
MinecraftServer minecraftserver = this.server;
Connection networkmanager = this.connection;

View file

@ -48,7 +48,7 @@
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
@@ -192,12 +196,73 @@
@@ -192,11 +196,72 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
@ -59,7 +59,7 @@
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.NamespacedKey;
import org.slf4j.Logger;
+
+// CraftBukkit start
+import io.papermc.paper.adventure.ChatProcessor; // Paper
+import io.papermc.paper.adventure.PaperAdventure; // Paper
@ -118,10 +118,9 @@
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.SmithingInventory;
+// CraftBukkit end
+
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
static final Logger LOGGER = LogUtils.getLogger();
@@ -212,7 +277,9 @@
private int tickCount;
private int ackBlockChangesUpTo = -1;
@ -318,7 +317,7 @@
boolean flag1 = entity.verticalCollisionBelow;
if (entity instanceof LivingEntity) {
@@ -449,20 +594,73 @@
@@ -449,19 +594,72 @@
d10 = d6 * d6 + d7 * d7 + d8 * d8;
boolean flag2 = false;
@ -337,8 +336,8 @@
+ this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
return;
}
+ }
+
+ // CraftBukkit start - fire PlayerMoveEvent
+ Player player = this.getCraftPlayer();
+ if (!this.hasMoved) {
@ -387,12 +386,11 @@
+ this.justTeleported = false;
+ return;
+ }
+ }
}
+ // CraftBukkit end
+
this.player.serverLevel().getChunkSource().move(this.player);
entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position());
Vec3 vec3d = new Vec3(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
@@ -489,16 +687,17 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (packet.getId() == this.awaitingTeleport) {
@ -1168,10 +1166,16 @@
return;
}
}
@@ -1342,6 +1975,13 @@
@@ -1342,17 +1975,46 @@
@Override
public void onDisconnect(DisconnectionDetails info) {
+ // Paper start - Fix kick event leave message not being sent
+ this.onDisconnect(info, null);
+ }
+ @Override
+ public void onDisconnect(DisconnectionDetails info, @Nullable net.kyori.adventure.text.Component quitMessage) {
+ // Paper end - Fix kick event leave message not being sent
+ // CraftBukkit start - Rarely it would send a disconnect line twice
+ if (this.processedDisconnect) {
+ return;
@ -1180,11 +1184,19 @@
+ }
+ // CraftBukkit end
ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), info.reason().getString());
this.removePlayerFromWorld();
super.onDisconnect(info);
@@ -1349,10 +1989,20 @@
- this.removePlayerFromWorld();
- super.onDisconnect(info);
+ this.removePlayerFromWorld(quitMessage); // Paper - Fix kick event leave message not being sent
+ super.onDisconnect(info, quitMessage); // Paper - Fix kick event leave message not being sent
}
+ // Paper start - Fix kick event leave message not being sent
private void removePlayerFromWorld() {
+ this.removePlayerFromWorld(null);
+ }
+
+ private void removePlayerFromWorld(@Nullable net.kyori.adventure.text.Component quitMessage) {
+ // Paper end - Fix kick event leave message not being sent
this.chatMessageChain.close();
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
@ -1196,7 +1208,7 @@
this.player.disconnect();
- this.server.getPlayerList().remove(this.player);
+ // Paper start - Adventure
+ net.kyori.adventure.text.Component quitMessage = this.server.getPlayerList().remove(this.player);
+ quitMessage = quitMessage == null ? this.server.getPlayerList().remove(this.player) : this.server.getPlayerList().remove(this.player, quitMessage); // Paper - pass in quitMessage to fix kick message not being used
+ if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) {
+ this.server.getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(quitMessage), false);
+ // Paper end
@ -1205,7 +1217,7 @@
this.player.getTextFilter().leave();
}
@@ -1367,7 +2017,17 @@
@@ -1367,7 +2029,17 @@
@Override
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1223,7 +1235,7 @@
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
this.player.stopUsingItem();
}
@@ -1376,11 +2036,18 @@
@@ -1376,11 +2048,18 @@
this.player.resetLastActionTime();
} else {
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -1242,7 +1254,7 @@
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
if (!optional.isEmpty()) {
@@ -1394,27 +2061,44 @@
@@ -1394,27 +2073,44 @@
return;
}
@ -1294,7 +1306,7 @@
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
@@ -1431,19 +2115,37 @@
@@ -1431,19 +2127,37 @@
if (!optional.isEmpty()) {
this.tryHandleChat(packet.command(), () -> {
@ -1336,7 +1348,7 @@
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
this.handleMessageDecodeFailure(signedmessagechain_a);
return;
@@ -1451,10 +2153,10 @@
@@ -1451,10 +2165,10 @@
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
@ -1349,7 +1361,7 @@
}
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
@@ -1530,14 +2232,20 @@
@@ -1530,14 +2244,20 @@
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
}
@ -1375,7 +1387,7 @@
}
}
@@ -1549,7 +2257,7 @@
@@ -1549,7 +2269,7 @@
if (optional.isEmpty()) {
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
@ -1384,7 +1396,7 @@
}
return optional;
@@ -1566,6 +2274,127 @@
@@ -1566,6 +2286,127 @@
return false;
}
@ -1512,7 +1524,7 @@
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
@@ -1573,15 +2402,44 @@
@@ -1573,15 +2414,44 @@
}
private void broadcastChatMessage(PlayerChatMessage message) {
@ -1563,7 +1575,7 @@
}
@@ -1592,7 +2450,7 @@
@@ -1592,7 +2462,7 @@
synchronized (this.lastSeenMessages) {
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
@ -1572,7 +1584,7 @@
}
}
@@ -1601,7 +2459,40 @@
@@ -1601,7 +2471,40 @@
@Override
public void handleAnimate(ServerboundSwingPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1613,7 +1625,7 @@
this.player.swing(packet.getHand());
}
@@ -1609,6 +2500,29 @@
@@ -1609,6 +2512,29 @@
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (this.player.hasClientLoaded()) {
@ -1643,7 +1655,7 @@
this.player.resetLastActionTime();
Entity entity;
PlayerRideableJumping ijumpable;
@@ -1616,6 +2530,11 @@
@@ -1616,6 +2542,11 @@
switch (packet.getAction()) {
case PRESS_SHIFT_KEY:
this.player.setShiftKeyDown(true);
@ -1655,7 +1667,7 @@
break;
case RELEASE_SHIFT_KEY:
this.player.setShiftKeyDown(false);
@@ -1684,13 +2603,19 @@
@@ -1684,13 +2615,19 @@
}
if (i > 4096) {
@ -1676,7 +1688,7 @@
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
this.addPendingMessage(message);
}
@@ -1703,6 +2628,18 @@
@@ -1703,6 +2640,18 @@
return this.connection.getRemoteAddress();
}
@ -1695,7 +1707,7 @@
public void switchToConfig() {
this.waitingForSwitchToConfig = true;
this.removePlayerFromWorld();
@@ -1718,9 +2655,17 @@
@@ -1718,9 +2667,17 @@
@Override
public void handleInteract(ServerboundInteractPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1713,7 +1725,7 @@
this.player.resetLastActionTime();
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
@@ -1733,20 +2678,58 @@
@@ -1733,20 +2690,58 @@
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
packet.dispatch(new ServerboundInteractPacket.Handler() {
@ -1776,7 +1788,7 @@
}
}
@@ -1755,19 +2738,20 @@
@@ -1755,19 +2750,20 @@
@Override
public void onInteraction(InteractionHand hand) {
@ -1800,7 +1812,7 @@
label23:
{
if (entity instanceof AbstractArrow) {
@@ -1785,17 +2769,41 @@
@@ -1785,17 +2781,41 @@
}
ServerGamePacketListenerImpl.this.player.attack(entity);
@ -1843,7 +1855,7 @@
}
}
@@ -1809,7 +2817,7 @@
@@ -1809,7 +2829,7 @@
case PERFORM_RESPAWN:
if (this.player.wonGame) {
this.player.wonGame = false;
@ -1852,7 +1864,7 @@
this.resetPosition();
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
} else {
@@ -1817,11 +2825,11 @@
@@ -1817,11 +2837,11 @@
return;
}
@ -1867,7 +1879,7 @@
}
}
break;
@@ -1833,16 +2841,27 @@
@@ -1833,16 +2853,27 @@
@Override
public void handleContainerClose(ServerboundContainerClosePacket packet) {
@ -1897,7 +1909,7 @@
this.player.containerMenu.sendAllDataToRemote();
} else if (!this.player.containerMenu.stillValid(this.player)) {
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
@@ -1855,7 +2874,284 @@
@@ -1855,7 +2886,284 @@
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@ -2183,7 +2195,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1879,6 +3175,14 @@
@@ -1879,6 +3187,14 @@
@Override
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
@ -2198,7 +2210,7 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
this.player.resetLastActionTime();
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) {
@@ -1900,9 +3204,43 @@
@@ -1900,9 +3216,43 @@
ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location());
return;
}
@ -2243,7 +2255,7 @@
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
}
@@ -1917,6 +3255,7 @@
@@ -1917,6 +3267,7 @@
@Override
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -2251,7 +2263,7 @@
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1945,6 +3284,43 @@
@@ -1945,7 +3296,44 @@
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
@ -2259,7 +2271,7 @@
+ // CraftBukkit start - Call click event
+ InventoryView inventory = this.player.inventoryMenu.getBukkitView();
+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packet.itemStack());
+
+ SlotType type = SlotType.QUICKBAR;
+ if (flag) {
+ type = SlotType.OUTSIDE;
@ -2292,10 +2304,11 @@
+ }
+ }
+ // CraftBukkit end
+
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
@@ -1964,7 +3340,19 @@
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
@@ -1964,7 +3352,19 @@
@Override
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
@ -2316,7 +2329,7 @@
this.filterTextPacket(list).thenAcceptAsync((list1) -> {
this.updateSignText(packet, list1);
@@ -1972,6 +3360,7 @@
@@ -1972,6 +3372,7 @@
}
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
@ -2324,7 +2337,7 @@
this.player.resetLastActionTime();
ServerLevel worldserver = this.player.serverLevel();
BlockPos blockposition = packet.getPos();
@@ -1993,15 +3382,33 @@
@@ -1993,15 +3394,33 @@
@Override
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -2359,7 +2372,7 @@
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
}
@@ -2012,7 +3419,7 @@
@@ -2012,7 +3431,7 @@
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
@ -2368,7 +2381,7 @@
}
}
@@ -2033,7 +3440,7 @@
@@ -2033,7 +3452,7 @@
if (!Objects.equals(profilepublickey_a, profilepublickey_a1)) {
if (profilepublickey_a != null && profilepublickey_a1.expiresAt().isBefore(profilepublickey_a.expiresAt())) {
@ -2377,7 +2390,7 @@
} else {
try {
SignatureValidator signaturevalidator = this.server.getProfileKeySignatureValidator();
@@ -2046,7 +3453,7 @@
@@ -2046,7 +3465,7 @@
this.resetPlayerChatState(remotechatsession_a.validate(this.player.getGameProfile(), signaturevalidator));
} catch (ProfilePublicKey.ValidationException profilepublickey_b) {
ServerGamePacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage());
@ -2386,7 +2399,7 @@
}
}
@@ -2058,7 +3465,7 @@
@@ -2058,7 +3477,7 @@
if (!this.waitingForSwitchToConfig) {
throw new IllegalStateException("Client acknowledged config, but none was requested");
} else {
@ -2395,7 +2408,7 @@
}
}
@@ -2083,8 +3490,10 @@
@@ -2083,8 +3502,10 @@
});
}

View file

@ -381,13 +381,18 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -334,95 +509,202 @@
@@ -334,95 +509,207 @@
}
- public void remove(ServerPlayer player) {
- ServerLevel worldserver = player.serverLevel();
+ public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component
+ // Paper start - Fix kick event leave message not being sent
+ return this.remove(entityplayer, 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())));
+ }
+ public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
+ // Paper end - Fix kick event leave message not being sent
+ ServerLevel worldserver = entityplayer.serverLevel();
- player.awardStat(Stats.LEAVE_GAME);
@ -402,7 +407,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())), entityplayer.quitReason); // Paper - Adventure & Add API for quit reason
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), leaveMessage, entityplayer.quitReason); // Paper - Adventure & Add API for quit reason
+ this.cserver.getPluginManager().callEvent(playerQuitEvent);
+ entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
+
@ -580,13 +585,13 @@
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
+ }
+ }
}
+
+ this.cserver.getPluginManager().callEvent(event);
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
+ loginlistener.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure
+ return null;
}
+ }
+ return entity;
}
@ -622,7 +627,7 @@
if (entityplayer1 != null) {
set.add(entityplayer1);
@@ -431,72 +713,160 @@
@@ -431,72 +718,160 @@
Iterator iterator1 = set.iterator();
while (iterator1.hasNext()) {
@ -804,7 +809,7 @@
return entityplayer1;
}
@@ -516,15 +886,32 @@
@@ -516,15 +891,32 @@
}
public void sendPlayerPermissionLevel(ServerPlayer player) {
@ -839,10 +844,14 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -541,6 +928,25 @@
}
@@ -537,9 +929,28 @@
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
entityplayer.connection.send(packet);
+ }
+
+ }
+
+ // CraftBukkit start - add a world/entity limited version
+ public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) {
+ for (int i = 0; i < this.players.size(); ++i) {
@ -857,15 +866,14 @@
+ public void broadcastAll(Packet packet, Level world) {
+ for (int i = 0; i < world.players().size(); ++i) {
+ ((ServerPlayer) world.players().get(i)).connection.send(packet);
+ }
+
+ }
}
}
+ // CraftBukkit end
+
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
Iterator iterator = this.players.iterator();
@@ -554,7 +960,7 @@
@@ -554,7 +965,7 @@
}
@ -874,7 +882,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam != null) {
@@ -573,7 +979,7 @@
@@ -573,7 +984,7 @@
}
}
@ -883,7 +891,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam == null) {
@@ -619,7 +1025,7 @@
@@ -619,7 +1030,7 @@
}
public void deop(GameProfile profile) {
@ -892,7 +900,7 @@
ServerPlayer entityplayer = this.getPlayer(profile.getId());
if (entityplayer != null) {
@@ -629,6 +1035,11 @@
@@ -629,6 +1040,11 @@
}
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
@ -904,7 +912,7 @@
if (player.connection != null) {
byte b0;
@@ -643,36 +1054,53 @@
@@ -643,36 +1059,53 @@
player.connection.send(new ClientboundEntityEventPacket(player, b0));
}
@ -971,7 +979,7 @@
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
double d4 = x - entityplayer.getX();
double d5 = y - entityplayer.getY();
@@ -687,10 +1115,12 @@
@@ -687,10 +1120,12 @@
}
public void saveAll() {
@ -984,7 +992,7 @@
}
public UserWhiteList getWhiteList() {
@@ -712,15 +1142,19 @@
@@ -712,15 +1147,19 @@
public void reloadWhiteList() {}
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
@ -1008,7 +1016,7 @@
}
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
@@ -729,8 +1163,16 @@
@@ -729,8 +1168,16 @@
public void sendAllPlayerInfo(ServerPlayer player) {
player.inventoryMenu.sendAllDataToRemote();
@ -1026,7 +1034,7 @@
}
public int getPlayerCount() {
@@ -746,6 +1188,7 @@
@@ -746,6 +1193,7 @@
}
public void setUsingWhiteList(boolean whitelistEnabled) {
@ -1034,7 +1042,7 @@
this.doWhiteList = whitelistEnabled;
}
@@ -786,12 +1229,36 @@
@@ -786,12 +1234,36 @@
}
public void removeAll() {
@ -1073,7 +1081,7 @@
public void broadcastSystemMessage(Component message, boolean overlay) {
this.broadcastSystemMessage(message, (entityplayer) -> {
return message;
@@ -819,24 +1286,43 @@
@@ -819,24 +1291,43 @@
}
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
@ -1120,7 +1128,7 @@
}
if (flag1 && sender != null) {
@@ -845,20 +1331,27 @@
@@ -845,20 +1336,27 @@
}
@ -1153,7 +1161,7 @@
Path path = file2.toPath();
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -867,7 +1360,7 @@
@@ -867,7 +1365,7 @@
}
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
@ -1162,7 +1170,7 @@
}
return serverstatisticmanager;
@@ -875,13 +1368,13 @@
@@ -875,13 +1373,13 @@
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
UUID uuid = player.getUUID();
@ -1178,7 +1186,7 @@
}
advancementdataplayer.setPlayer(player);
@@ -932,15 +1425,28 @@
@@ -932,15 +1430,28 @@
}
public void reloadResources() {