mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 22:26:45 +01:00
Fix sending multiple messages of notify-enter and notify-leave flag when joining from foreign worlds (#4433)
* Fixed IntellectualSites/PlotSquared#3424 by combining Teleport and WorldChange * re-added WorldEdit permission check * Changed conditions for calling plotEntry
This commit is contained in:
parent
670f5a802e
commit
67e69e3fc1
@ -533,9 +533,9 @@ public class PlayerEventListener implements Listener {
|
|||||||
// to is identical to the plot's home location, and untrusted-visit is true
|
// to is identical to the plot's home location, and untrusted-visit is true
|
||||||
// i.e. untrusted-visit can override deny-teleport
|
// i.e. untrusted-visit can override deny-teleport
|
||||||
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
||||||
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot
|
if (result || (plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous().equals(BukkitUtil.adaptComplete(to)))) {
|
||||||
.getHomeSynchronous()
|
plotListener.plotEntry(pp, plot);
|
||||||
.equals(BukkitUtil.adaptComplete(to)))) {
|
} else {
|
||||||
pp.sendMessage(
|
pp.sendMessage(
|
||||||
TranslatableCaption.of("deny.no_enter"),
|
TranslatableCaption.of("deny.no_enter"),
|
||||||
TagResolver.resolver("plot", Tag.inserting(Component.text(plot.toString())))
|
TagResolver.resolver("plot", Tag.inserting(Component.text(plot.toString())))
|
||||||
@ -548,6 +548,19 @@ public class PlayerEventListener implements Listener {
|
|||||||
playerMove(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)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void vehicleMove(VehicleMoveEvent event)
|
public void vehicleMove(VehicleMoveEvent event)
|
||||||
throws IllegalAccessException {
|
throws IllegalAccessException {
|
||||||
@ -887,40 +900,6 @@ public class PlayerEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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")
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user