Skip to content

Commit 67e69e3

Browse files
authored
Fix sending multiple messages of notify-enter and notify-leave flag when joining from foreign worlds (#4433)
* Fixed #3424 by combining Teleport and WorldChange * re-added WorldEdit permission check * Changed conditions for calling plotEntry
1 parent 670f5a8 commit 67e69e3

File tree

1 file changed

+16
-37
lines changed

1 file changed

+16
-37
lines changed

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ public void onTeleport(PlayerTeleportEvent event) {
533533
// to is identical to the plot's home location, and untrusted-visit is true
534534
// i.e. untrusted-visit can override deny-teleport
535535
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
536-
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot
537-
.getHomeSynchronous()
538-
.equals(BukkitUtil.adaptComplete(to)))) {
536+
if (result || (plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous().equals(BukkitUtil.adaptComplete(to)))) {
537+
plotListener.plotEntry(pp, plot);
538+
} else {
539539
pp.sendMessage(
540540
TranslatableCaption.of("deny.no_enter"),
541541
TagResolver.resolver("plot", Tag.inserting(Component.text(plot.toString())))
@@ -548,6 +548,19 @@ public void onTeleport(PlayerTeleportEvent event) {
548548
playerMove(event);
549549
}
550550

551+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
552+
public void onWorldChanged(PlayerChangedWorldEvent event) {
553+
Player player = event.getPlayer();
554+
BukkitPlayer pp = BukkitUtil.adapt(player);
555+
if (this.worldEdit != null) {
556+
if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) {
557+
if (pp.getAttribute("worldedit")) {
558+
pp.removeAttribute("worldedit");
559+
}
560+
}
561+
}
562+
}
563+
551564
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
552565
public void vehicleMove(VehicleMoveEvent event)
553566
throws IllegalAccessException {
@@ -887,40 +900,6 @@ public void onChat(AsyncPlayerChatEvent event) {
887900
}
888901
}
889902

890-
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
891-
public void onWorldChanged(PlayerChangedWorldEvent event) {
892-
Player player = event.getPlayer();
893-
BukkitPlayer pp = BukkitUtil.adapt(player);
894-
// Delete last location
895-
Plot plot;
896-
try (final MetaDataAccess<Plot> lastPlotAccess =
897-
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
898-
plot = lastPlotAccess.remove();
899-
}
900-
try (final MetaDataAccess<Location> lastLocationAccess =
901-
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LOCATION)) {
902-
lastLocationAccess.remove();
903-
}
904-
if (plot != null) {
905-
plotListener.plotExit(pp, plot);
906-
}
907-
if (this.worldEdit != null) {
908-
if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) {
909-
if (pp.getAttribute("worldedit")) {
910-
pp.removeAttribute("worldedit");
911-
}
912-
}
913-
}
914-
Location location = pp.getLocation();
915-
PlotArea area = location.getPlotArea();
916-
if (location.isPlotArea()) {
917-
plot = location.getPlot();
918-
if (plot != null) {
919-
plotListener.plotEntry(pp, plot);
920-
}
921-
}
922-
}
923-
924903
@SuppressWarnings("deprecation")
925904
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
926905
public void onInventoryClick(InventoryClickEvent event) {

0 commit comments

Comments
 (0)