Skip to content

Commit 26874a2

Browse files
Merge pull request #16 from SLNE-Development/fix/hotfix-world-management
feat: restrict NPC interaction to players in the same world
2 parents 87dbf89 + ae95c2c commit 26874a2

File tree

1 file changed

+9
-0
lines changed
  • surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/listener

1 file changed

+9
-0
lines changed

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/listener/NpcListener.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class NpcListener : PacketListener {
2828
?: continue
2929
val playerLoc = player.location
3030

31+
if (playerLoc.world.name != npcLoc.world) {
32+
continue
33+
}
34+
3135
if (playerLoc.distanceSquared(npcLoc.toLocation()) > 20 * 20) {
3236
continue
3337
}
@@ -43,6 +47,10 @@ class NpcListener : PacketListener {
4347
?: continue
4448
val playerLoc = player.location
4549

50+
if (playerLoc.world.name != npcLoc.world) {
51+
continue
52+
}
53+
4654
if (playerLoc.distanceSquared(npcLoc.toLocation()) > 1 * 1) {
4755
continue
4856
}
@@ -82,6 +90,7 @@ class NpcListener : PacketListener {
8290
).callEvent()
8391
}
8492
}
93+
8594
WrapperPlayClientInteractEntity.InteractAction.INTERACT_AT -> {
8695
// This is already handled by INTERACT action, so we can ignore it.
8796
}

0 commit comments

Comments
 (0)