@@ -779,7 +779,7 @@ public void onPlayerMove(PlayerMoveEvent event) {
779779 // Let's ignore Citizens NPCs
780780 if (PluginIntegrations .getInstance ().isNPC (event .getPlayer ()))
781781 return ;
782-
782+
783783 if (plugin .isError ()) {
784784 event .setCancelled (true );
785785 return ;
@@ -816,22 +816,22 @@ public void handleCellChange(Player player, Location from, Location to, Cancella
816816
817817 if (this .teleportWarmupTime > 0 && this .isMovementCancellingWarmup ) {
818818 final Resident resident = TownyAPI .getInstance ().getResident (player );
819-
819+
820820 if (resident != null && resident .hasRequestedTeleport () && !resident .isAdmin () && TeleportWarmupTimerTask .abortTeleportRequest (resident , CancelledTeleportReason .MOVEMENT ))
821821 TownyMessaging .sendErrorMsg (player , Translatable .of ("msg_err_teleport_cancelled" ));
822822 }
823823
824824 if (WorldCoord .cellChanged (from , to )) {
825825
826- TownyWorld fromWorld = TownyAPI .getInstance ().getTownyWorld (from .getWorld ());
826+ TownyWorld fromWorld = TownyAPI .getInstance ().getTownyWorld (from .getWorld ());
827827 TownyWorld toWorld = TownyAPI .getInstance ().getTownyWorld (to .getWorld ());
828828 if (fromWorld == null || toWorld == null ) {
829829 TownyMessaging .sendErrorMsg (player , Translatable .of ("not_registered" ));
830830 return ;
831831 }
832832 WorldCoord fromCoord = WorldCoord .parseWorldCoord (from );
833833 WorldCoord toCoord = WorldCoord .parseWorldCoord (to );
834-
834+
835835 onPlayerMoveChunk (player , fromCoord , toCoord , event );
836836 }
837837 }
@@ -1007,14 +1007,9 @@ private void onPlayerMoveChunk(Player player, WorldCoord from, WorldCoord to, Ca
10071007 // Paper doesn't currently throw PlayerMoveEvents for passengers in vehicles who aren't the driver.
10081008 // This workaround ensures that any passengers that are players will cause PlayerChangePlotEvents.
10091009 if (player .isInsideVehicle ())
1010- handleAnimalVehiclesWorkaround (player , player .getVehicle () , from , to , moveEvent );
1010+ handleAnimalVehiclesWorkaround (player .getVehicle (), from , to );
10111011
1012- PlayerChangePlotEvent event = new PlayerChangePlotEvent (player , from , to , moveEvent );
1013- BukkitTools .fireEvent (event );
1014-
1015- if (event .isCancelled ()) {
1016- moveEvent .setCancelled (true );
1017- }
1012+ BukkitTools .fireEvent (new PlayerChangePlotEvent (player , from , to ));
10181013 }
10191014
10201015 /**
@@ -1023,14 +1018,12 @@ private void onPlayerMoveChunk(Player player, WorldCoord from, WorldCoord to, Ca
10231018 * ridden they stop throwing EntityMoveEvents. The driver is the only one who
10241019 * will have a PlayerMoveEvent thrown which is why we're doing this here.
10251020 *
1026- * @param player Player driving the Vehicle.
10271021 * @param vehicle Vehicle being driven.
10281022 * @param from WorldCoord the players are leaving.
10291023 * @param to WorldCoord the players are entering.
1030- * @param moveEvent PlayerMoveEvent of the driving player.
10311024 */
1032- private void handleAnimalVehiclesWorkaround (Player player , @ Nullable Entity vehicle , WorldCoord from , WorldCoord to , PlayerMoveEvent moveEvent ) {
1033- if (!EntityLists .MULTISEAT_ANIMAL_MOUNTS .contains (vehicle ))
1025+ private void handleAnimalVehiclesWorkaround (@ Nullable Entity vehicle , WorldCoord from , WorldCoord to ) {
1026+ if (vehicle == null || !EntityLists .MULTISEAT_ANIMAL_MOUNTS .contains (vehicle ))
10341027 return ;
10351028
10361029 if (vehicle .getPassengers ().size () < 2 )
@@ -1042,7 +1035,7 @@ private void handleAnimalVehiclesWorkaround(Player player, @Nullable Entity vehi
10421035
10431036 for (Entity entity : passengers ) {
10441037 if (entity instanceof Player rider )
1045- BukkitTools .fireEvent (new PlayerChangePlotEvent (rider , from , to , moveEvent ));
1038+ BukkitTools .fireEvent (new PlayerChangePlotEvent (rider , from , to ));
10461039 }
10471040 }
10481041
@@ -1060,18 +1053,18 @@ public void onPlayerChangePlotEvent(PlayerChangePlotEvent event) {
10601053 return ;
10611054 if (to .isWilderness ()) {
10621055 // Gone from a Town into the wilderness.
1063- BukkitTools .fireEvent (new PlayerExitsFromTownBorderEvent (event .getPlayer (), to , from , from .getTownOrNull (), event . getMoveEvent () ));
1056+ BukkitTools .fireEvent (new PlayerExitsFromTownBorderEvent (event .getPlayer (), to , from , from .getTownOrNull ()));
10641057 } else if (from .isWilderness ()) {
10651058 // Gone from wilderness into Town.
1066- BukkitTools .fireEvent (new PlayerEntersIntoTownBorderEvent (event .getPlayer (), to , from , to .getTownOrNull (), event . getMoveEvent () ));
1059+ BukkitTools .fireEvent (new PlayerEntersIntoTownBorderEvent (event .getPlayer (), to , from , to .getTownOrNull ()));
10671060 // Both to and from have towns.
10681061 } else if (to .getTownOrNull ().equals (from .getTownOrNull ())) {
10691062 // The towns are the same, no event will fire.
10701063 return ;
10711064 } else {
10721065 // Player has left one Town and immediately entered a different one.
1073- BukkitTools .fireEvent (new PlayerEntersIntoTownBorderEvent (event .getPlayer (), to , from , to .getTownOrNull (), event . getMoveEvent () ));
1074- BukkitTools .fireEvent (new PlayerExitsFromTownBorderEvent (event .getPlayer (), to , from , from .getTownOrNull (), event . getMoveEvent () ));
1066+ BukkitTools .fireEvent (new PlayerEntersIntoTownBorderEvent (event .getPlayer (), to , from , to .getTownOrNull ()));
1067+ BukkitTools .fireEvent (new PlayerExitsFromTownBorderEvent (event .getPlayer (), to , from , from .getTownOrNull ()));
10751068 }
10761069 }
10771070
@@ -1096,24 +1089,24 @@ public void onPlayerChangeDistricts(PlayerChangePlotEvent event) {
10961089
10971090 if (to .isWilderness () && fromHasDistrict ) {
10981091 // Gone from a Town into the wilderness.
1099- BukkitTools .fireEvent (new PlayerExitsFromDistrictEvent (event .getPlayer (), to , from , fromDistrict , event . getMoveEvent () ));
1092+ BukkitTools .fireEvent (new PlayerExitsFromDistrictEvent (event .getPlayer (), to , from , fromDistrict ));
11001093
11011094 } else if (from .isWilderness () && toHasDistrict ) {
11021095 // Gone from wilderness into Town.
1103- BukkitTools .fireEvent (new PlayerEntersIntoDistrictEvent (event .getPlayer (), to , from , toDistrict , event . getMoveEvent () ));
1096+ BukkitTools .fireEvent (new PlayerEntersIntoDistrictEvent (event .getPlayer (), to , from , toDistrict ));
11041097
11051098 } else if (!to .isWilderness () && !from .isWilderness () && to .getTownOrNull ().equals (from .getTownOrNull ())
11061099 && fromHasDistrict && toHasDistrict && !fromDistrict .equals (toDistrict )) {
11071100 // Moving in same town, between two different Districts.
1108- BukkitTools .fireEvent (new PlayerExitsFromDistrictEvent (event .getPlayer (), to , from , fromDistrict , event . getMoveEvent () ));
1109- BukkitTools .fireEvent (new PlayerEntersIntoDistrictEvent (event .getPlayer (), to , from , toDistrict , event . getMoveEvent () ));
1101+ BukkitTools .fireEvent (new PlayerExitsFromDistrictEvent (event .getPlayer (), to , from , fromDistrict ));
1102+ BukkitTools .fireEvent (new PlayerEntersIntoDistrictEvent (event .getPlayer (), to , from , toDistrict ));
11101103
11111104 } else {
11121105 // Player has left one Town and immediately entered a different one, check if there were districts.
11131106 if (fromHasDistrict )
1114- BukkitTools .fireEvent (new PlayerExitsFromDistrictEvent (event .getPlayer (), to , from , fromDistrict , event . getMoveEvent () ));
1107+ BukkitTools .fireEvent (new PlayerExitsFromDistrictEvent (event .getPlayer (), to , from , fromDistrict ));
11151108 if (toHasDistrict )
1116- BukkitTools .fireEvent (new PlayerEntersIntoDistrictEvent (event .getPlayer (), to , from , toDistrict , event . getMoveEvent () ));
1109+ BukkitTools .fireEvent (new PlayerEntersIntoDistrictEvent (event .getPlayer (), to , from , toDistrict ));
11171110 }
11181111 }
11191112
0 commit comments