Skip to content

Commit

Permalink
Don't call options events on login (#9834)
Browse files Browse the repository at this point in the history
* Don't call options events on login

* Merge changes into client options API patch
  • Loading branch information
froobynooby authored Oct 14, 2023
1 parent f613437 commit 3e9d2ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
23 changes: 22 additions & 1 deletion patches/server/0376-Implement-Player-Client-Options-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,18 @@ index 0000000000000000000000000000000000000000..b6f4400df3d8ec7e06a996de54f8cabb
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0bab5208a38e8e7c848e9162396df535eb7e5711..baec871645598c36cefda7478e91b560bdfdf6fe 100644
index 0bab5208a38e8e7c848e9162396df535eb7e5711..88fcf595c6a28811545715f5e5a225809a977d76 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -379,7 +379,7 @@ public class ServerPlayer extends Player {
this.advancements = server.getPlayerList().getPlayerAdvancements(this);
this.setMaxUpStep(1.0F);
// this.fudgeSpawnLocation(world); // Paper - don't move to spawn on login, only first join
- this.updateOptions(clientOptions);
+ this.updateOptionsNoEvents(clientOptions); // Paper - don't call options events on login

this.cachedSingleHashSet = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper

@@ -1950,7 +1950,23 @@ public class ServerPlayer extends Player {
}
}
Expand All @@ -114,6 +123,18 @@ index 0bab5208a38e8e7c848e9162396df535eb7e5711..baec871645598c36cefda7478e91b560
// CraftBukkit start
if (getMainArm() != clientOptions.mainHand()) {
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
@@ -1962,6 +1978,11 @@ public class ServerPlayer extends Player {
this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.language, clientOptions.language())); // Paper
}
// CraftBukkit end
+ // Paper start - don't call options events on login
+ updateOptionsNoEvents(clientOptions);
+ }
+ public void updateOptionsNoEvents(ClientInformation clientOptions) {
+ // Paper end
this.language = clientOptions.language();
this.adventure$locale = net.kyori.adventure.translation.Translator.parseLocale(this.language); // Paper
this.requestedViewDistance = clientOptions.viewDistance();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 94cb3513aeef549da3626ff18c1ea0662252ecb9..f4a15de92c3af88624f337c36fadbea67d339064 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ index aee8618e27b893b72931e925724dd683d2e6d2aa..5cb15e2209d7b315904a1fc6d650ce1e
}

diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index d942b68c01b202dcad1377e98199bab2f79feebf..6856080fc6195e5f340d64434955c4ea3f0b0ef8 100644
index 1d7fe0e7d382d2f2aa5a38732cc6212d6c7a11e3..e12e512b607882f68b6f32b6201aeb2b3e39a699 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1887,8 +1887,16 @@ public class ServerPlayer extends Player {
Expand Down Expand Up @@ -76,7 +76,7 @@ index d942b68c01b202dcad1377e98199bab2f79feebf..6856080fc6195e5f340d64434955c4ea
}
}

@@ -2304,6 +2312,16 @@ public class ServerPlayer extends Player {
@@ -2309,6 +2317,16 @@ public class ServerPlayer extends Player {
}

public void loadGameTypes(@Nullable CompoundTag nbt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Fix PlayerDropItemEvent using wrong item


diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 6856080fc6195e5f340d64434955c4ea3f0b0ef8..ec135dca185c0c9cdb5a28c75d44f54681448cf8 100644
index e12e512b607882f68b6f32b6201aeb2b3e39a699..963af930dc40b30d84c1e5d46be752ef74908a8a 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -2281,7 +2281,7 @@ public class ServerPlayer extends Player {
@@ -2286,7 +2286,7 @@ public class ServerPlayer extends Player {

if (retainOwnership) {
if (!itemstack1.isEmpty()) {
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0646-Add-PlayerSetSpawnEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ index a2d0699e8427b2262a2396495111125eccafbb66..d797637f61bdf8a424f56fbb48e28b7c
}
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 25f6b4e7ac794431f1b6170e9e680e43c44d10cf..f612363c1530dd66fd57eaa324e285d481fa30e6 100644
index 47e7bc46d349e0f0000676948a5c251f555abeb1..6b92189b6dddee7e632c142430eaa784d22adbca 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1351,7 +1351,7 @@ public class ServerPlayer extends Player {
Expand All @@ -61,7 +61,7 @@ index 25f6b4e7ac794431f1b6170e9e680e43c44d10cf..f612363c1530dd66fd57eaa324e285d4
if (this.level().isDay()) {
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
} else {
@@ -2201,44 +2201,50 @@ public class ServerPlayer extends Player {
@@ -2206,44 +2206,50 @@ public class ServerPlayer extends Player {
return this.respawnForced;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ index 25f6b4e7ac794431f1b6170e9e680e43c44d10cf..f612363c1530dd66fd57eaa324e285d4
} else {
this.respawnPosition = null;
this.respawnDimension = Level.OVERWORLD;
@@ -2246,6 +2252,7 @@ public class ServerPlayer extends Player {
@@ -2251,6 +2257,7 @@ public class ServerPlayer extends Player {
this.respawnForced = false;
}

Expand Down

0 comments on commit 3e9d2ac

Please sign in to comment.