|
29 | 29 | import com.plotsquared.core.configuration.Settings; |
30 | 30 | import com.plotsquared.core.configuration.caption.Caption; |
31 | 31 | import com.plotsquared.core.configuration.caption.TranslatableCaption; |
| 32 | +import com.plotsquared.core.events.TeleportCause; |
32 | 33 | import com.plotsquared.core.listener.PlayerBlockEventType; |
33 | 34 | import com.plotsquared.core.listener.PlotListener; |
34 | 35 | import com.plotsquared.core.location.Location; |
@@ -543,7 +544,7 @@ public void onConnect(PlayerJoinEvent event) { |
543 | 544 | if (area != null) { |
544 | 545 | Plot plot = area.getPlot(location); |
545 | 546 | if (plot != null) { |
546 | | - plotListener.plotEntry(pp, plot); |
| 547 | + this.enforceJoinEntry(pp, player, plot); |
547 | 548 | } |
548 | 549 | } |
549 | 550 | // Delayed |
@@ -575,6 +576,24 @@ public void onConnect(PlayerJoinEvent event) { |
575 | 576 | } |
576 | 577 | } |
577 | 578 |
|
| 579 | + private void enforceJoinEntry(final PlotPlayer<Player> player, final Player bukkitPlayer, final Plot plot) { |
| 580 | + if (!this.plotListener.plotEntry(player, plot)) { |
| 581 | + Location spawn = PlotSquared.platform().worldUtil().getSpawn(plot.getWorldName()); |
| 582 | + if (!plot.equals(spawn.getPlot())) { |
| 583 | + player.teleport(spawn, TeleportCause.DENIED); |
| 584 | + return; |
| 585 | + } |
| 586 | + |
| 587 | + Location fallbackSpawn = PlotSquared.platform().worldUtil().getSpawn(this.plotAreaManager.getAllWorlds()[0]); |
| 588 | + if (plot.equals(fallbackSpawn.getPlot())) { |
| 589 | + player.kick( |
| 590 | + "You got kicked from the plot! This server did not set up a loaded spawn, so you got kicked from the server."); |
| 591 | + } else { |
| 592 | + player.teleport(fallbackSpawn, TeleportCause.DENIED); |
| 593 | + } |
| 594 | + } |
| 595 | + } |
| 596 | + |
578 | 597 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
579 | 598 | public void playerRespawn(PlayerRespawnEvent event) { |
580 | 599 | Player player = event.getPlayer(); |
@@ -754,8 +773,10 @@ public void playerMove(PlayerMoveEvent event) { |
754 | 773 | if (now == null) { |
755 | 774 | try (final MetaDataAccess<Boolean> kickAccess = |
756 | 775 | pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) { |
757 | | - if (lastPlot != null && !plotListener.plotExit(pp, lastPlot, now, area) && this.tmpTeleport && !kickAccess.get().orElse( |
758 | | - false)) { |
| 776 | + if (lastPlot != null && !plotListener.plotExit(pp, lastPlot, now, area) && this.tmpTeleport && !kickAccess |
| 777 | + .get() |
| 778 | + .orElse( |
| 779 | + false)) { |
759 | 780 | pp.sendMessage( |
760 | 781 | TranslatableCaption.of("permission.no_permission_event"), |
761 | 782 | TagResolver.resolver( |
@@ -848,8 +869,10 @@ public void playerMove(PlayerMoveEvent event) { |
848 | 869 | if (plot == null) { |
849 | 870 | try (final MetaDataAccess<Boolean> kickAccess = |
850 | 871 | pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) { |
851 | | - if (lastPlot != null && !plotListener.plotExit(pp, lastPlot, null, area) && this.tmpTeleport && !kickAccess.get().orElse( |
852 | | - false)) { |
| 872 | + if (lastPlot != null && !plotListener.plotExit(pp, lastPlot, null, area) && this.tmpTeleport && !kickAccess |
| 873 | + .get() |
| 874 | + .orElse( |
| 875 | + false)) { |
853 | 876 | pp.sendMessage( |
854 | 877 | TranslatableCaption.of("permission.no_permission_event"), |
855 | 878 | TagResolver.resolver( |
|
0 commit comments