Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sending multiple messages of notify-enter and notify-leave flag when joining from foreign worlds #4433

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,9 @@ public void onTeleport(PlayerTeleportEvent event) {
// to is identical to the plot's home location, and untrusted-visit is true
// i.e. untrusted-visit can override deny-teleport
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot
.getHomeSynchronous()
.equals(BukkitUtil.adaptComplete(to)))) {
if (result || (plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous().equals(BukkitUtil.adaptComplete(to)))) {
plotListener.plotEntry(pp, plot);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this only being added here? Do we not want to call plotEntry if deny teleport doesn't allow entry, but the untrusted visit flag does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I have addressed this issue in the latest commit.

} else {
pp.sendMessage(
TranslatableCaption.of("deny.no_enter"),
TagResolver.resolver("plot", Tag.inserting(Component.text(plot.toString())))
Expand All @@ -548,6 +548,19 @@ public void onTeleport(PlayerTeleportEvent event) {
playerMove(event);
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldChanged(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.adapt(player);
if (this.worldEdit != null) {
if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) {
if (pp.getAttribute("worldedit")) {
pp.removeAttribute("worldedit");
}
}
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void vehicleMove(VehicleMoveEvent event)
throws IllegalAccessException {
Expand Down Expand Up @@ -887,40 +900,6 @@ public void onChat(AsyncPlayerChatEvent event) {
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldChanged(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.adapt(player);
// Delete last location
Plot plot;
try (final MetaDataAccess<Plot> lastPlotAccess =
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
plot = lastPlotAccess.remove();
}
try (final MetaDataAccess<Location> lastLocationAccess =
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LOCATION)) {
lastLocationAccess.remove();
}
if (plot != null) {
plotListener.plotExit(pp, plot);
}
if (this.worldEdit != null) {
if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) {
if (pp.getAttribute("worldedit")) {
pp.removeAttribute("worldedit");
}
}
}
Location location = pp.getLocation();
PlotArea area = location.getPlotArea();
if (location.isPlotArea()) {
plot = location.getPlot();
if (plot != null) {
plotListener.plotEntry(pp, plot);
}
}
}

@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
Expand Down
Loading