mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 17:43:44 +01:00 
			
		
		
		
	| @@ -362,12 +362,19 @@ public class BukkitPlayer extends PlotPlayer<Player> { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Convert from PlotSquared's {@link TeleportCause} to Bukkit's {@link PlayerTeleportEvent.TeleportCause} | ||||||
|  |      * | ||||||
|  |      * @param cause PlotSquared teleport cause to convert | ||||||
|  |      * @return Bukkit's equivalent teleport cause | ||||||
|  |      */ | ||||||
|     public PlayerTeleportEvent.TeleportCause getTeleportCause(final @NonNull TeleportCause cause) { |     public PlayerTeleportEvent.TeleportCause getTeleportCause(final @NonNull TeleportCause cause) { | ||||||
|         return switch (cause) { |         if (TeleportCause.CauseSets.COMMAND.contains(cause)) { | ||||||
|             case COMMAND -> PlayerTeleportEvent.TeleportCause.COMMAND; |             return PlayerTeleportEvent.TeleportCause.COMMAND; | ||||||
|             case PLUGIN -> PlayerTeleportEvent.TeleportCause.PLUGIN; |         } else if (cause == TeleportCause.UNKNOWN) { | ||||||
|             default -> PlayerTeleportEvent.TeleportCause.UNKNOWN; |             return PlayerTeleportEvent.TeleportCause.UNKNOWN; | ||||||
|         }; |         } | ||||||
|  |         return PlayerTeleportEvent.TeleportCause.PLUGIN; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -395,7 +395,7 @@ public class Area extends SubCommand { | |||||||
|                                     final String world = this.setupUtils.setupWorld(builder); |                                     final String world = this.setupUtils.setupWorld(builder); | ||||||
|                                     if (this.worldUtil.isWorld(world)) { |                                     if (this.worldUtil.isWorld(world)) { | ||||||
|                                         PlotSquared.get().loadWorld(world, null); |                                         PlotSquared.get().loadWorld(world, null); | ||||||
|                                         player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND); |                                         player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE); | ||||||
|                                         player.sendMessage(TranslatableCaption.of("setup.setup_finished")); |                                         player.sendMessage(TranslatableCaption.of("setup.setup_finished")); | ||||||
|                                         if (area.getTerrain() != PlotAreaTerrainType.ALL) { |                                         if (area.getTerrain() != PlotAreaTerrainType.ALL) { | ||||||
|                                             QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world)); |                                             QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world)); | ||||||
| @@ -525,7 +525,7 @@ public class Area extends SubCommand { | |||||||
|                                 builder.generatorName(PlotSquared.platform().pluginName()); |                                 builder.generatorName(PlotSquared.platform().pluginName()); | ||||||
|                                 String world = this.setupUtils.setupWorld(builder); |                                 String world = this.setupUtils.setupWorld(builder); | ||||||
|                                 if (this.worldUtil.isWorld(world)) { |                                 if (this.worldUtil.isWorld(world)) { | ||||||
|                                     player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND); |                                     player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE); | ||||||
|                                     player.sendMessage(TranslatableCaption.of("setup.setup_finished")); |                                     player.sendMessage(TranslatableCaption.of("setup.setup_finished")); | ||||||
|                                 } else { |                                 } else { | ||||||
|                                     player.sendMessage( |                                     player.sendMessage( | ||||||
| @@ -560,13 +560,13 @@ public class Area extends SubCommand { | |||||||
|                         } |                         } | ||||||
|                         if (this.worldUtil.isWorld(pa.getWorldName())) { |                         if (this.worldUtil.isWorld(pa.getWorldName())) { | ||||||
|                             if (!player.getLocation().getWorldName().equals(pa.getWorldName())) { |                             if (!player.getLocation().getWorldName().equals(pa.getWorldName())) { | ||||||
|                                 player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), TeleportCause.COMMAND); |                                 player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), TeleportCause.COMMAND_AREA_CREATE); | ||||||
|                             } |                             } | ||||||
|                         } else { |                         } else { | ||||||
|                             builder.terrainType(PlotAreaTerrainType.NONE); |                             builder.terrainType(PlotAreaTerrainType.NONE); | ||||||
|                             builder.plotAreaType(PlotAreaType.NORMAL); |                             builder.plotAreaType(PlotAreaType.NORMAL); | ||||||
|                             this.setupUtils.setupWorld(builder); |                             this.setupUtils.setupWorld(builder); | ||||||
|                             player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), TeleportCause.COMMAND); |                             player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), TeleportCause.COMMAND_AREA_CREATE); | ||||||
|                         } |                         } | ||||||
|                         metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa); |                         metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa); | ||||||
|                         player.sendMessage( |                         player.sendMessage( | ||||||
| @@ -795,10 +795,10 @@ public class Area extends SubCommand { | |||||||
|                 if (area instanceof SinglePlotArea) { |                 if (area instanceof SinglePlotArea) { | ||||||
|                     ((SinglePlotArea) area).loadWorld(PlotId.of(0, 0)); |                     ((SinglePlotArea) area).loadWorld(PlotId.of(0, 0)); | ||||||
|                     center = this.worldUtil.getSpawn(PlotId.of(0, 0).toUnderscoreSeparatedString()); |                     center = this.worldUtil.getSpawn(PlotId.of(0, 0).toUnderscoreSeparatedString()); | ||||||
|                     player.teleport(center, TeleportCause.COMMAND); |                     player.teleport(center, TeleportCause.COMMAND_AREA_TELEPORT); | ||||||
|                 } else if (area.getType() != PlotAreaType.PARTIAL) { |                 } else if (area.getType() != PlotAreaType.PARTIAL) { | ||||||
|                     center = this.worldUtil.getSpawn(area.getWorldName()); |                     center = this.worldUtil.getSpawn(area.getWorldName()); | ||||||
|                     player.teleport(center, TeleportCause.COMMAND); |                     player.teleport(center, TeleportCause.COMMAND_AREA_TELEPORT); | ||||||
|                 } else { |                 } else { | ||||||
|                     CuboidRegion region = area.getRegion(); |                     CuboidRegion region = area.getRegion(); | ||||||
|                     center = Location.at(area.getWorldName(), |                     center = Location.at(area.getWorldName(), | ||||||
| @@ -810,7 +810,7 @@ public class Area extends SubCommand { | |||||||
|                                     .getZ()) / 2 |                                     .getZ()) / 2 | ||||||
|                     ); |                     ); | ||||||
|                     this.worldUtil.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), |                     this.worldUtil.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), | ||||||
|                             y -> player.teleport(center.withY(1 + y), TeleportCause.COMMAND) |                             y -> player.teleport(center.withY(1 + y), TeleportCause.COMMAND_AREA_TELEPORT) | ||||||
|                     ); |                     ); | ||||||
|                 } |                 } | ||||||
|                 return true; |                 return true; | ||||||
|   | |||||||
| @@ -209,31 +209,24 @@ public class Auto extends SubCommand { | |||||||
|                 return false; |                 return false; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         int size_x = 1; |         int sizeX = 1; | ||||||
|         int size_z = 1; |         int sizeZ = 1; | ||||||
|         String schematic = null; |         String schematic = null; | ||||||
|         boolean mega = false; |         boolean mega = false; | ||||||
|         if (args.length > 0) { |         if (args.length > 0) { | ||||||
|             try { |             try { | ||||||
|                 String[] split = args[0].split(",|;"); |                 String[] split = args[0].split("[,;]"); | ||||||
|                 switch (split.length) { |                 if (split.length == 2) { | ||||||
|                     case 1 -> { |                     sizeX = Integer.parseInt(split[0]); | ||||||
|                         size_x = 1; |                     sizeZ = Integer.parseInt(split[1]); | ||||||
|                         size_z = 1; |                 } else { | ||||||
|                     } |                     player.sendMessage( | ||||||
|                     case 2 -> { |                             TranslatableCaption.of("commandconfig.command_syntax"), | ||||||
|                         size_x = Integer.parseInt(split[0]); |                             Template.of("value", getUsage()) | ||||||
|                         size_z = Integer.parseInt(split[1]); |                     ); | ||||||
|                     } |                     return true; | ||||||
|                     default -> { |  | ||||||
|                         player.sendMessage( |  | ||||||
|                                 TranslatableCaption.of("commandconfig.command_syntax"), |  | ||||||
|                                 Template.of("value", getUsage()) |  | ||||||
|                         ); |  | ||||||
|                         return true; |  | ||||||
|                     } |  | ||||||
|                 } |                 } | ||||||
|                 if (size_x < 1 || size_z < 1) { |                 if (sizeX < 1 || sizeZ < 1) { | ||||||
|                     player.sendMessage(TranslatableCaption.of("error.plot_size_negative")); |                     player.sendMessage(TranslatableCaption.of("error.plot_size_negative")); | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
| @@ -242,13 +235,13 @@ public class Auto extends SubCommand { | |||||||
|                 } |                 } | ||||||
|                 mega = true; |                 mega = true; | ||||||
|             } catch (NumberFormatException ignored) { |             } catch (NumberFormatException ignored) { | ||||||
|                 size_x = 1; |                 sizeX = 1; | ||||||
|                 size_z = 1; |                 sizeZ = 1; | ||||||
|                 schematic = args[0]; |                 schematic = args[0]; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         PlayerAutoPlotEvent event = this.eventDispatcher |         PlayerAutoPlotEvent event = this.eventDispatcher | ||||||
|                 .callAuto(player, plotarea, schematic, size_x, size_z); |                 .callAuto(player, plotarea, schematic, sizeX, sizeZ); | ||||||
|         if (event.getEventResult() == Result.DENY) { |         if (event.getEventResult() == Result.DENY) { | ||||||
|             player.sendMessage( |             player.sendMessage( | ||||||
|                     TranslatableCaption.of("events.event_denied"), |                     TranslatableCaption.of("events.event_denied"), | ||||||
| @@ -257,8 +250,8 @@ public class Auto extends SubCommand { | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|         boolean force = event.getEventResult() == Result.FORCE; |         boolean force = event.getEventResult() == Result.FORCE; | ||||||
|         size_x = event.getSize_x(); |         sizeX = event.getSizeX(); | ||||||
|         size_z = event.getSize_z(); |         sizeZ = event.getSizeZ(); | ||||||
|         schematic = event.getSchematic(); |         schematic = event.getSchematic(); | ||||||
|         if (!force && mega && !Permissions.hasPermission(player, Permission.PERMISSION_AUTO_MEGA)) { |         if (!force && mega && !Permissions.hasPermission(player, Permission.PERMISSION_AUTO_MEGA)) { | ||||||
|             player.sendMessage( |             player.sendMessage( | ||||||
| @@ -266,7 +259,7 @@ public class Auto extends SubCommand { | |||||||
|                     Template.of("node", String.valueOf(Permission.PERMISSION_AUTO_MEGA)) |                     Template.of("node", String.valueOf(Permission.PERMISSION_AUTO_MEGA)) | ||||||
|             ); |             ); | ||||||
|         } |         } | ||||||
|         if (!force && size_x * size_z > Settings.Claim.MAX_AUTO_AREA) { |         if (!force && sizeX * sizeZ > Settings.Claim.MAX_AUTO_AREA) { | ||||||
|             player.sendMessage( |             player.sendMessage( | ||||||
|                     TranslatableCaption.of("permission.cant_claim_more_plots_num"), |                     TranslatableCaption.of("permission.cant_claim_more_plots_num"), | ||||||
|                     Template.of("amount", String.valueOf(Settings.Claim.MAX_AUTO_AREA)) |                     Template.of("amount", String.valueOf(Settings.Claim.MAX_AUTO_AREA)) | ||||||
| @@ -277,7 +270,7 @@ public class Auto extends SubCommand { | |||||||
|         try (final MetaDataAccess<Boolean> metaDataAccess = |         try (final MetaDataAccess<Boolean> metaDataAccess = | ||||||
|                      player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_AUTO)) { |                      player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_AUTO)) { | ||||||
|             if (!force && (metaDataAccess.get().orElse(false) || !checkAllowedPlots(player, |             if (!force && (metaDataAccess.get().orElse(false) || !checkAllowedPlots(player, | ||||||
|                     plotarea, allowed_plots, size_x, size_z |                     plotarea, allowed_plots, sizeX, sizeZ | ||||||
|             ))) { |             ))) { | ||||||
|                 return false; |                 return false; | ||||||
|             } |             } | ||||||
| @@ -309,7 +302,7 @@ public class Auto extends SubCommand { | |||||||
|             double cost = costExp.evaluate(Settings.Limit.GLOBAL ? |             double cost = costExp.evaluate(Settings.Limit.GLOBAL ? | ||||||
|                     player.getPlotCount() : |                     player.getPlotCount() : | ||||||
|                     player.getPlotCount(plotarea.getWorldName())); |                     player.getPlotCount(plotarea.getWorldName())); | ||||||
|             cost = (size_x * size_z) * cost; |             cost = (sizeX * sizeZ) * cost; | ||||||
|             if (cost > 0d) { |             if (cost > 0d) { | ||||||
|                 if (!this.econHandler.isSupported()) { |                 if (!this.econHandler.isSupported()) { | ||||||
|                     player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null")); |                     player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null")); | ||||||
| @@ -331,11 +324,13 @@ public class Auto extends SubCommand { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         final List<Plot> plots = this.servicePipeline |         List<Plot> plots = this.servicePipeline | ||||||
|                 .pump(new AutoService.AutoQuery(player, null, size_x, size_z, plotarea)) |                 .pump(new AutoService.AutoQuery(player, null, sizeX, sizeZ, plotarea)) | ||||||
|                 .through(AutoService.class) |                 .through(AutoService.class) | ||||||
|                 .getResult(); |                 .getResult(); | ||||||
|  |  | ||||||
|  |         plots = this.eventDispatcher.callAutoPlotsChosen(player, plots).getPlots(); | ||||||
|  |  | ||||||
|         if (plots.isEmpty()) { |         if (plots.isEmpty()) { | ||||||
|             player.sendMessage(TranslatableCaption.of("errors.no_free_plots")); |             player.sendMessage(TranslatableCaption.of("errors.no_free_plots")); | ||||||
|             return false; |             return false; | ||||||
| @@ -344,7 +339,11 @@ public class Auto extends SubCommand { | |||||||
|         } else { |         } else { | ||||||
|             final Iterator<Plot> plotIterator = plots.iterator(); |             final Iterator<Plot> plotIterator = plots.iterator(); | ||||||
|             while (plotIterator.hasNext()) { |             while (plotIterator.hasNext()) { | ||||||
|                 plotIterator.next().claim(player, !plotIterator.hasNext(), null); |                 Plot plot = plotIterator.next(); | ||||||
|  |                 if (!plot.canClaim(player)) { | ||||||
|  |                     continue; | ||||||
|  |                 } | ||||||
|  |                 plot.claim(player, !plotIterator.hasNext(), null, true, true); | ||||||
|             } |             } | ||||||
|             final PlotAutoMergeEvent mergeEvent = this.eventDispatcher.callAutoMerge( |             final PlotAutoMergeEvent mergeEvent = this.eventDispatcher.callAutoMerge( | ||||||
|                     plots.get(0), |                     plots.get(0), | ||||||
|   | |||||||
| @@ -193,7 +193,7 @@ public class Claim extends SubCommand { | |||||||
|         DBFunc.createPlotSafe(plot, () -> { |         DBFunc.createPlotSafe(plot, () -> { | ||||||
|             try { |             try { | ||||||
|                 TaskManager.getPlatformImplementation().sync(() -> { |                 TaskManager.getPlatformImplementation().sync(() -> { | ||||||
|                     if (!plot.claim(player, true, finalSchematic, false)) { |                     if (!plot.claim(player, true, finalSchematic, false, false)) { | ||||||
|                         LOGGER.info("Failed to claim plot {}", plot.getId().toCommaSeparatedString()); |                         LOGGER.info("Failed to claim plot {}", plot.getId().toCommaSeparatedString()); | ||||||
|                         player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); |                         player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); | ||||||
|                         plot.setOwnerAbs(null); |                         plot.setOwnerAbs(null); | ||||||
|   | |||||||
| @@ -104,7 +104,7 @@ public class Clear extends Command { | |||||||
|                 .hasPermission(player, "plots.continue"), TranslatableCaption.of("done.done_already_done")); |                 .hasPermission(player, "plots.continue"), TranslatableCaption.of("done.done_already_done")); | ||||||
|         confirm.run(this, () -> { |         confirm.run(this, () -> { | ||||||
|             if (Settings.Teleport.ON_CLEAR) { |             if (Settings.Teleport.ON_CLEAR) { | ||||||
|                 plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND, |                 plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND_CLEAR, | ||||||
|                         result -> { |                         result -> { | ||||||
|                         } |                         } | ||||||
|                 )); |                 )); | ||||||
|   | |||||||
| @@ -730,7 +730,7 @@ public class Cluster extends SubCommand { | |||||||
|                         return false; |                         return false; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 cluster.getHome(home -> player.teleport(home, TeleportCause.COMMAND)); |                 cluster.getHome(home -> player.teleport(home, TeleportCause.COMMAND_CLUSTER_TELEPORT)); | ||||||
|                 player.sendMessage(TranslatableCaption.of("cluster.cluster_teleporting")); |                 player.sendMessage(TranslatableCaption.of("cluster.cluster_teleporting")); | ||||||
|                 return true; |                 return true; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -107,7 +107,7 @@ public class Delete extends SubCommand { | |||||||
|             } |             } | ||||||
|             final long start = System.currentTimeMillis(); |             final long start = System.currentTimeMillis(); | ||||||
|             if (Settings.Teleport.ON_DELETE) { |             if (Settings.Teleport.ON_DELETE) { | ||||||
|                 plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND, |                 plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND_DELETE, | ||||||
|                         result -> { |                         result -> { | ||||||
|                         } |                         } | ||||||
|                 )); |                 )); | ||||||
|   | |||||||
| @@ -30,6 +30,7 @@ import com.plotsquared.core.PlotSquared; | |||||||
| import com.plotsquared.core.configuration.Settings; | import com.plotsquared.core.configuration.Settings; | ||||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||||
| import com.plotsquared.core.database.DBFunc; | import com.plotsquared.core.database.DBFunc; | ||||||
|  | import com.plotsquared.core.events.TeleportCause; | ||||||
| import com.plotsquared.core.location.Location; | import com.plotsquared.core.location.Location; | ||||||
| import com.plotsquared.core.permissions.Permission; | import com.plotsquared.core.permissions.Permission; | ||||||
| import com.plotsquared.core.player.PlotPlayer; | import com.plotsquared.core.player.PlotPlayer; | ||||||
| @@ -183,10 +184,10 @@ public class Deny extends SubCommand { | |||||||
|                 player.kick("You got kicked from the plot! This server did not set up a loaded spawn, so you got " + |                 player.kick("You got kicked from the plot! This server did not set up a loaded spawn, so you got " + | ||||||
|                         "kicked from the server."); |                         "kicked from the server."); | ||||||
|             } else { |             } else { | ||||||
|                 player.teleport(newSpawn); |                 player.teleport(newSpawn, TeleportCause.DENIED); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             player.teleport(spawn); |             player.teleport(spawn, TeleportCause.DENIED); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -85,7 +85,7 @@ public class HomeCommand extends Command { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         Plot plot = plots.get(page - 1); |         Plot plot = plots.get(page - 1); | ||||||
|         confirm.run(this, () -> plot.teleportPlayer(player, TeleportCause.COMMAND, result -> { |         confirm.run(this, () -> plot.teleportPlayer(player, TeleportCause.COMMAND_HOME, result -> { | ||||||
|             if (result) { |             if (result) { | ||||||
|                 whenDone.run(this, CommandResult.SUCCESS); |                 whenDone.run(this, CommandResult.SUCCESS); | ||||||
|             } else { |             } else { | ||||||
|   | |||||||
| @@ -113,7 +113,7 @@ public class Like extends SubCommand { | |||||||
|                     for (final Plot plot : plots) { |                     for (final Plot plot : plots) { | ||||||
|                         if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot |                         if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot | ||||||
|                                 .isBasePlot() && (!plot.getLikes().containsKey(uuid))) { |                                 .isBasePlot() && (!plot.getLikes().containsKey(uuid))) { | ||||||
|                             plot.teleportPlayer(player, TeleportCause.COMMAND, result -> { |                             plot.teleportPlayer(player, TeleportCause.COMMAND_LIKE, result -> { | ||||||
|                             }); |                             }); | ||||||
|                             player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); |                             player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); | ||||||
|                             return true; |                             return true; | ||||||
|   | |||||||
| @@ -49,7 +49,7 @@ public class Middle extends SubCommand { | |||||||
|             player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); |             player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND)); |         plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND_MIDDLE)); | ||||||
|         player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot")); |         player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot")); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -106,7 +106,7 @@ public class Rate extends SubCommand { | |||||||
|                         if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p |                         if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p | ||||||
|                                 .isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p |                                 .isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p | ||||||
|                                 .isAdded(uuid)) { |                                 .isAdded(uuid)) { | ||||||
|                             p.teleportPlayer(player, TeleportCause.COMMAND, result -> { |                             p.teleportPlayer(player, TeleportCause.COMMAND_RATE, result -> { | ||||||
|                             }); |                             }); | ||||||
|                             player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); |                             player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); | ||||||
|                             return true; |                             return true; | ||||||
|   | |||||||
| @@ -240,7 +240,7 @@ public class Template extends SubCommand { | |||||||
|  |  | ||||||
|                 this.setupUtils.setupWorld(builder); |                 this.setupUtils.setupWorld(builder); | ||||||
|                 TaskManager.runTask(() -> { |                 TaskManager.runTask(() -> { | ||||||
|                     player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND); |                     player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_TEMPLATE); | ||||||
|                     player.sendMessage(TranslatableCaption.of("setup.setup_finished")); |                     player.sendMessage(TranslatableCaption.of("setup.setup_finished")); | ||||||
|                 }); |                 }); | ||||||
|                 return true; |                 return true; | ||||||
|   | |||||||
| @@ -166,7 +166,7 @@ public class Visit extends Command { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         confirm.run(this, () -> plot.teleportPlayer(player, TeleportCause.COMMAND, result -> { |         confirm.run(this, () -> plot.teleportPlayer(player, TeleportCause.COMMAND_VISIT, result -> { | ||||||
|             if (result) { |             if (result) { | ||||||
|                 whenDone.run(Visit.this, CommandResult.SUCCESS); |                 whenDone.run(Visit.this, CommandResult.SUCCESS); | ||||||
|             } else { |             } else { | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ package com.plotsquared.core.events; | |||||||
|  |  | ||||||
| import com.plotsquared.core.command.Claim; | import com.plotsquared.core.command.Claim; | ||||||
| import com.plotsquared.core.player.PlotPlayer; | import com.plotsquared.core.player.PlotPlayer; | ||||||
|  | import com.plotsquared.core.plot.Plot; | ||||||
| import com.plotsquared.core.plot.PlotArea; | import com.plotsquared.core.plot.PlotArea; | ||||||
| import org.checkerframework.checker.nullness.qual.Nullable; | import org.checkerframework.checker.nullness.qual.Nullable; | ||||||
|  |  | ||||||
| @@ -39,8 +40,8 @@ public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEve | |||||||
|     private final PlotArea plotArea; |     private final PlotArea plotArea; | ||||||
|     private Result eventResult; |     private Result eventResult; | ||||||
|     private String schematic; |     private String schematic; | ||||||
|     private int size_x; |     private int sizeX; | ||||||
|     private int size_z; |     private int sizeZ; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * PlayerAutoPlotEvent: called when a player attempts to auto claim a plot. |      * PlayerAutoPlotEvent: called when a player attempts to auto claim a plot. | ||||||
| @@ -48,19 +49,31 @@ public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEve | |||||||
|      * @param player    The player attempting to auto claim |      * @param player    The player attempting to auto claim | ||||||
|      * @param plotArea  The applicable plot area |      * @param plotArea  The applicable plot area | ||||||
|      * @param schematic The schematic defined or null |      * @param schematic The schematic defined or null | ||||||
|      * @param size_x    The size of the auto area |      * @param sizeX     The size of the auto area | ||||||
|      * @param size_z    The size of the auto area |      * @param sizeZ     The size of the auto area | ||||||
|      */ |      */ | ||||||
|     public PlayerAutoPlotEvent( |     public PlayerAutoPlotEvent( | ||||||
|             PlotPlayer<?> player, PlotArea plotArea, @Nullable String schematic, |             PlotPlayer<?> player, PlotArea plotArea, @Nullable String schematic, | ||||||
|             int size_x, int size_z |             int sizeX, int sizeZ | ||||||
|     ) { |     ) { | ||||||
|         super(null); |         super(null); | ||||||
|         this.player = player; |         this.player = player; | ||||||
|         this.plotArea = plotArea; |         this.plotArea = plotArea; | ||||||
|         this.schematic = schematic; |         this.schematic = schematic; | ||||||
|         this.size_x = size_x; |         this.sizeX = sizeX; | ||||||
|         this.size_z = size_z; |         this.sizeZ = sizeZ; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Returns null as the plots to be claimed haven't been chosen yet. This will depend on the size of the auto | ||||||
|  |      * ({@link PlayerAutoPlotEvent#setSizeX(int)} and {@link PlayerAutoPlotEvent#setSizeZ(int)}). To see which plots have been | ||||||
|  |      * chosen, see {@link PlayerAutoPlotsChosenEvent}. | ||||||
|  |      * | ||||||
|  |      * @return null | ||||||
|  |      */ | ||||||
|  |     @Override | ||||||
|  |     public @Nullable Plot getPlot() { | ||||||
|  |         return null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -99,20 +112,72 @@ public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEve | |||||||
|         return this.plotArea; |         return this.plotArea; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeX()} | ||||||
|  |      */ | ||||||
|  |     @Deprecated(forRemoval = true) | ||||||
|     public int getSize_x() { |     public int getSize_x() { | ||||||
|         return this.size_x; |         return getSizeX(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setSize_x(int size_x) { |     /** | ||||||
|         this.size_x = size_x; |      * @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeX(int)} )} | ||||||
|  |      */ | ||||||
|  |     @Deprecated(forRemoval = true) | ||||||
|  |     public void setSize_x(int sizeX) { | ||||||
|  |         setSizeX(sizeX); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeZ()} | ||||||
|  |      */ | ||||||
|  |     @Deprecated(forRemoval = true) | ||||||
|     public int getSize_z() { |     public int getSize_z() { | ||||||
|         return this.size_z; |         return getSizeZ(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setSize_z(int size_z) { |     /** | ||||||
|         this.size_z = size_z; |      * @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeZ(int)} )} | ||||||
|  |      */ | ||||||
|  |     @Deprecated(forRemoval = true) | ||||||
|  |     public void setSize_z(int sizeZ) { | ||||||
|  |         setSizeZ(sizeZ); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get the x size of the auto-area | ||||||
|  |      * | ||||||
|  |      * @return x size | ||||||
|  |      */ | ||||||
|  |     public int getSizeX() { | ||||||
|  |         return this.sizeX; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Set the x size of the auto-area | ||||||
|  |      * | ||||||
|  |      * @param sizeX x size | ||||||
|  |      */ | ||||||
|  |     public void setSizeX(int sizeX) { | ||||||
|  |         this.sizeX = sizeX; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get the z size of the auto-area | ||||||
|  |      * | ||||||
|  |      * @return z size | ||||||
|  |      */ | ||||||
|  |     public int getSizeZ() { | ||||||
|  |         return this.sizeZ; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Set the z size of the auto-area | ||||||
|  |      * | ||||||
|  |      * @param sizeZ z size | ||||||
|  |      */ | ||||||
|  |     public void setSizeZ(int sizeZ) { | ||||||
|  |         this.sizeZ = sizeZ; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,86 @@ | |||||||
|  | /* | ||||||
|  |  *       _____  _       _    _____                                _ | ||||||
|  |  *      |  __ \| |     | |  / ____|                              | | | ||||||
|  |  *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| | | ||||||
|  |  *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | | ||||||
|  |  *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| | | ||||||
|  |  *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_| | ||||||
|  |  *                                    | | | ||||||
|  |  *                                    |_| | ||||||
|  |  *            PlotSquared plot management system for Minecraft | ||||||
|  |  *                  Copyright (C) 2021 IntellectualSites | ||||||
|  |  * | ||||||
|  |  *     This program is free software: you can redistribute it and/or modify | ||||||
|  |  *     it under the terms of the GNU General Public License as published by | ||||||
|  |  *     the Free Software Foundation, either version 3 of the License, or | ||||||
|  |  *     (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  *     This program is distributed in the hope that it will be useful, | ||||||
|  |  *     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  *     GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  *     You should have received a copy of the GNU General Public License | ||||||
|  |  *     along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  | package com.plotsquared.core.events; | ||||||
|  |  | ||||||
|  | import com.plotsquared.core.player.PlotPlayer; | ||||||
|  | import com.plotsquared.core.plot.Plot; | ||||||
|  | import org.checkerframework.checker.nullness.qual.NonNull; | ||||||
|  | import org.checkerframework.checker.nullness.qual.Nullable; | ||||||
|  |  | ||||||
|  | import java.util.Collections; | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Event fired when the plots that are to be claimed by a player executing a /plot auto have been chosen. It contains an | ||||||
|  |  * unmodifiable list of the plots selected. This may be of length 0. This event is effectively cancellable by setting the list | ||||||
|  |  * of plots to an empty list. | ||||||
|  |  */ | ||||||
|  | public class PlayerAutoPlotsChosenEvent extends PlotPlayerEvent { | ||||||
|  |  | ||||||
|  |     private Result eventResult; | ||||||
|  |  | ||||||
|  |     private List<Plot> plots; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * PlayerAutoPlotsChosenEvent: Called when one or more plots are chosen for a /plot auto | ||||||
|  |      * | ||||||
|  |      * @param player Player that executed the auto | ||||||
|  |      * @param plots  Plots that have been chosen to be set to the player | ||||||
|  |      */ | ||||||
|  |     public PlayerAutoPlotsChosenEvent(PlotPlayer<?> player, List<Plot> plots) { | ||||||
|  |         super(player, plots.size() > 0 ? plots.get(0) : null); | ||||||
|  |         this.plots = Collections.unmodifiableList(plots); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Returns the plot at index 0 in the list of plots selected. May be null if the list was of length 0. | ||||||
|  |      * | ||||||
|  |      * @return plot at index 0 or null. | ||||||
|  |      */ | ||||||
|  |     @Override | ||||||
|  |     public @Nullable Plot getPlot() { | ||||||
|  |         return super.getPlot(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get the immutable list of plots selected to be claimed by the player. May be of length 0. | ||||||
|  |      * | ||||||
|  |      * @return immutable list. | ||||||
|  |      */ | ||||||
|  |     public @NonNull List<Plot> getPlots() { | ||||||
|  |         return plots; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Set the plots to be claimed by the player. | ||||||
|  |      * | ||||||
|  |      * @param plots list of plots. | ||||||
|  |      */ | ||||||
|  |     public void setPlots(final @NonNull List<Plot> plots) { | ||||||
|  |         this.plots = List.copyOf(plots); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -35,18 +35,39 @@ import com.plotsquared.core.plot.Plot; | |||||||
| public class PlayerTeleportToPlotEvent extends PlotPlayerEvent implements CancellablePlotEvent { | public class PlayerTeleportToPlotEvent extends PlotPlayerEvent implements CancellablePlotEvent { | ||||||
|  |  | ||||||
|     private final Location from; |     private final Location from; | ||||||
|  |     private final TeleportCause cause; | ||||||
|     private Result eventResult; |     private Result eventResult; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @deprecated use {@link PlayerTeleportToPlotEvent#PlayerTeleportToPlotEvent(PlotPlayer, Location, Plot, TeleportCause)}. | ||||||
|  |      * You should not be creating events in the first place. | ||||||
|  |      */ | ||||||
|  |     @Deprecated(forRemoval = true) | ||||||
|  |     public PlayerTeleportToPlotEvent(PlotPlayer<?> player, Location from, Plot plot) { | ||||||
|  |         this(player, from, plot, TeleportCause.UNKNOWN); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * PlayerTeleportToPlotEvent: Called when a player teleports to a plot |      * PlayerTeleportToPlotEvent: Called when a player teleports to a plot | ||||||
|      * |      * | ||||||
|      * @param player That was teleported |      * @param player That was teleported | ||||||
|      * @param from   Start location |      * @param from   Start location | ||||||
|      * @param plot   Plot to which the player was teleported |      * @param plot   Plot to which the player was teleported | ||||||
|  |      * @param cause  Why the teleport is being completed | ||||||
|      */ |      */ | ||||||
|     public PlayerTeleportToPlotEvent(PlotPlayer<?> player, Location from, Plot plot) { |     public PlayerTeleportToPlotEvent(PlotPlayer<?> player, Location from, Plot plot, TeleportCause cause) { | ||||||
|         super(player, plot); |         super(player, plot); | ||||||
|         this.from = from; |         this.from = from; | ||||||
|  |         this.cause = cause; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get the teleport cause | ||||||
|  |      * | ||||||
|  |      * @return TeleportCause | ||||||
|  |      */ | ||||||
|  |     public TeleportCause getCause() { | ||||||
|  |         return cause; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  *       _____  _       _    _____                                _ | ||||||
|  |  *      |  __ \| |     | |  / ____|                              | | | ||||||
|  |  *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| | | ||||||
|  |  *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | | ||||||
|  |  *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| | | ||||||
|  |  *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_| | ||||||
|  |  *                                    | | | ||||||
|  |  *                                    |_| | ||||||
|  |  *            PlotSquared plot management system for Minecraft | ||||||
|  |  *                  Copyright (C) 2021 IntellectualSites | ||||||
|  |  * | ||||||
|  |  *     This program is free software: you can redistribute it and/or modify | ||||||
|  |  *     it under the terms of the GNU General Public License as published by | ||||||
|  |  *     the Free Software Foundation, either version 3 of the License, or | ||||||
|  |  *     (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  *     This program is distributed in the hope that it will be useful, | ||||||
|  |  *     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  *     GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  *     You should have received a copy of the GNU General Public License | ||||||
|  |  *     along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  | package com.plotsquared.core.events; | ||||||
|  |  | ||||||
|  | import com.plotsquared.core.plot.Plot; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * To be used as a notification that a plot has been claimed. For cancelling events, see {@link PlayerClaimPlotEvent} | ||||||
|  |  */ | ||||||
|  | public class PlotClaimedNotifyEvent extends PlotEvent { | ||||||
|  |  | ||||||
|  |     private final boolean auto; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * New event instance. | ||||||
|  |      * | ||||||
|  |      * @param plot Plot that was claimed | ||||||
|  |      * @param auto If the plot was claimed using /plot auto | ||||||
|  |      */ | ||||||
|  |     public PlotClaimedNotifyEvent(Plot plot, boolean auto) { | ||||||
|  |         super(plot); | ||||||
|  |         this.auto = auto; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * If the plot was claimed using /plot auto | ||||||
|  |      * | ||||||
|  |      * @return if claimed with auto | ||||||
|  |      */ | ||||||
|  |     public boolean wasAuto() { | ||||||
|  |         return auto; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -42,7 +42,7 @@ public abstract class PlotEvent { | |||||||
|      * |      * | ||||||
|      * @return Plot |      * @return Plot | ||||||
|      */ |      */ | ||||||
|     public final Plot getPlot() { |     public Plot getPlot() { | ||||||
|         return this.plot; |         return this.plot; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,8 +25,48 @@ | |||||||
|  */ |  */ | ||||||
| package com.plotsquared.core.events; | package com.plotsquared.core.events; | ||||||
|  |  | ||||||
|  | import com.google.common.collect.Sets; | ||||||
|  |  | ||||||
|  | import java.util.EnumSet; | ||||||
|  | import java.util.Set; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * The reason for an internal player teleport. | ||||||
|  |  */ | ||||||
| public enum TeleportCause { | public enum TeleportCause { | ||||||
|  |  | ||||||
|     COMMAND, |     COMMAND, | ||||||
|  |     COMMAND_AREA_CREATE, | ||||||
|  |     COMMAND_AREA_TELEPORT, | ||||||
|  |     COMMAND_AUTO, | ||||||
|  |     COMMAND_CLAIM, | ||||||
|  |     COMMAND_CLEAR, | ||||||
|  |     COMMAND_CLUSTER_TELEPORT, | ||||||
|  |     COMMAND_DELETE, | ||||||
|  |     COMMAND_HOME, | ||||||
|  |     COMMAND_LIKE, | ||||||
|  |     COMMAND_MIDDLE, | ||||||
|  |     COMMAND_RATE, | ||||||
|  |     COMMAND_SETUP, | ||||||
|  |     COMMAND_TEMPLATE, | ||||||
|  |     COMMAND_VISIT, | ||||||
|  |     DEATH, | ||||||
|  |     DENIED, | ||||||
|  |     KICK, | ||||||
|  |     LOGIN, | ||||||
|     PLUGIN, |     PLUGIN, | ||||||
|     UNKNOWN |     UNKNOWN; | ||||||
|  |  | ||||||
|  |     public static final class CauseSets { | ||||||
|  |  | ||||||
|  |         public static final Set<TeleportCause> COMMAND = Sets.immutableEnumSet(EnumSet.range( | ||||||
|  |                 TeleportCause.COMMAND, | ||||||
|  |                 TeleportCause.COMMAND_VISIT | ||||||
|  |         )); | ||||||
|  |         public static final Set<TeleportCause> PLUGIN = Sets.immutableEnumSet(EnumSet.range( | ||||||
|  |                 TeleportCause.DEATH, | ||||||
|  |                 TeleportCause.PLUGIN | ||||||
|  |         )); | ||||||
|  |  | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -473,7 +473,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer, | |||||||
|      */ |      */ | ||||||
|     public void plotkick(Location location) { |     public void plotkick(Location location) { | ||||||
|         setMeta("kick", true); |         setMeta("kick", true); | ||||||
|         teleport(location); |         teleport(location, TeleportCause.KICK); | ||||||
|         deleteMeta("kick"); |         deleteMeta("kick"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -712,7 +712,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer, | |||||||
|                         if (plot.isLoaded()) { |                         if (plot.isLoaded()) { | ||||||
|                             TaskManager.runTask(() -> { |                             TaskManager.runTask(() -> { | ||||||
|                                 if (getMeta("teleportOnLogin", true)) { |                                 if (getMeta("teleportOnLogin", true)) { | ||||||
|                                     teleport(location); |                                     teleport(location, TeleportCause.LOGIN); | ||||||
|                                     sendMessage( |                                     sendMessage( | ||||||
|                                             TranslatableCaption.of("teleport.teleported_to_plot")); |                                             TranslatableCaption.of("teleport.teleported_to_plot")); | ||||||
|                                 } |                                 } | ||||||
| @@ -724,7 +724,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer, | |||||||
|                                         result -> TaskManager.runTask(() -> { |                                         result -> TaskManager.runTask(() -> { | ||||||
|                                             if (getMeta("teleportOnLogin", true)) { |                                             if (getMeta("teleportOnLogin", true)) { | ||||||
|                                                 if (plot.isLoaded()) { |                                                 if (plot.isLoaded()) { | ||||||
|                                                     teleport(location); |                                                     teleport(location, TeleportCause.LOGIN); | ||||||
|                                                     sendMessage(TranslatableCaption |                                                     sendMessage(TranslatableCaption | ||||||
|                                                             .of("teleport.teleported_to_plot")); |                                                             .of("teleport.teleported_to_plot")); | ||||||
|                                                 } |                                                 } | ||||||
|   | |||||||
| @@ -1666,6 +1666,7 @@ public class Plot { | |||||||
|         return base.settings != null && base.settings.getRatings() != null; |         return base.settings != null && base.settings.getRatings() != null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Deprecated(forRemoval = true) | ||||||
|     public boolean claim(final @NonNull PlotPlayer<?> player, boolean teleport, String schematic) { |     public boolean claim(final @NonNull PlotPlayer<?> player, boolean teleport, String schematic) { | ||||||
|         if (!canClaim(player)) { |         if (!canClaim(player)) { | ||||||
|             return false; |             return false; | ||||||
| @@ -1673,8 +1674,26 @@ public class Plot { | |||||||
|         return claim(player, teleport, schematic, true); |         return claim(player, teleport, schematic, true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Deprecated(forRemoval = true) | ||||||
|     public boolean claim(final @NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB) { |     public boolean claim(final @NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB) { | ||||||
|  |         return claim(player, teleport, schematic, updateDB, false); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Claim the plot | ||||||
|  |      * | ||||||
|  |      * @param player    The player to set the owner to | ||||||
|  |      * @param teleport  If the player should be teleported | ||||||
|  |      * @param schematic The schematic name to paste on the plot | ||||||
|  |      * @param updateDB  If the database should be updated | ||||||
|  |      * @param auto      If the plot is being claimed by a /plot auto | ||||||
|  |      * @return success | ||||||
|  |      */ | ||||||
|  |     public boolean claim( | ||||||
|  |             final @NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB, | ||||||
|  |             boolean auto | ||||||
|  |     ) { | ||||||
|  |         this.eventDispatcher.callPlotClaimedNotify(this, auto); | ||||||
|         if (updateDB) { |         if (updateDB) { | ||||||
|             if (!this.getPlotModificationManager().create(player.getUUID(), true)) { |             if (!this.getPlotModificationManager().create(player.getUUID(), true)) { | ||||||
|                 LOGGER.error("Player {} attempted to claim plot {}, but the database failed to update", player.getName(), |                 LOGGER.error("Player {} attempted to claim plot {}, but the database failed to update", player.getName(), | ||||||
| @@ -1689,7 +1708,7 @@ public class Plot { | |||||||
|         this.getPlotModificationManager().setSign(player.getName()); |         this.getPlotModificationManager().setSign(player.getName()); | ||||||
|         player.sendMessage(TranslatableCaption.of("working.claimed"), Template.of("plot", this.getId().toString())); |         player.sendMessage(TranslatableCaption.of("working.claimed"), Template.of("plot", this.getId().toString())); | ||||||
|         if (teleport && Settings.Teleport.ON_CLAIM) { |         if (teleport && Settings.Teleport.ON_CLAIM) { | ||||||
|             teleportPlayer(player, TeleportCause.COMMAND, result -> { |             teleportPlayer(player, auto ? TeleportCause.COMMAND_AUTO : TeleportCause.COMMAND_CLAIM, result -> { | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|         PlotArea plotworld = getArea(); |         PlotArea plotworld = getArea(); | ||||||
| @@ -2570,7 +2589,7 @@ public class Plot { | |||||||
|      */ |      */ | ||||||
|     public void teleportPlayer(final PlotPlayer<?> player, TeleportCause cause, Consumer<Boolean> resultConsumer) { |     public void teleportPlayer(final PlotPlayer<?> player, TeleportCause cause, Consumer<Boolean> resultConsumer) { | ||||||
|         Plot plot = this.getBasePlot(false); |         Plot plot = this.getBasePlot(false); | ||||||
|         Result result = this.eventDispatcher.callTeleport(player, player.getLocation(), plot).getEventResult(); |         Result result = this.eventDispatcher.callTeleport(player, player.getLocation(), plot, cause).getEventResult(); | ||||||
|         if (result == Result.DENY) { |         if (result == Result.DENY) { | ||||||
|             player.sendMessage( |             player.sendMessage( | ||||||
|                     TranslatableCaption.of("events.event_denied"), |                     TranslatableCaption.of("events.event_denied"), | ||||||
|   | |||||||
| @@ -230,7 +230,7 @@ public enum CommonSetupSteps implements SetupStep { | |||||||
|                 world = builder.setupManager().setupWorld(builder); |                 world = builder.setupManager().setupWorld(builder); | ||||||
|             } |             } | ||||||
|             try { |             try { | ||||||
|                 plotPlayer.teleport(PlotSquared.platform().worldUtil().getSpawn(world), TeleportCause.COMMAND); |                 plotPlayer.teleport(PlotSquared.platform().worldUtil().getSpawn(world), TeleportCause.COMMAND_SETUP); | ||||||
|             } catch (Exception e) { |             } catch (Exception e) { | ||||||
|                 plotPlayer.sendMessage(TranslatableCaption.of("errors.error_console")); |                 plotPlayer.sendMessage(TranslatableCaption.of("errors.error_console")); | ||||||
|                 e.printStackTrace(); |                 e.printStackTrace(); | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ import com.google.common.eventbus.EventBus; | |||||||
| import com.plotsquared.core.configuration.Settings; | import com.plotsquared.core.configuration.Settings; | ||||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||||
| import com.plotsquared.core.events.PlayerAutoPlotEvent; | import com.plotsquared.core.events.PlayerAutoPlotEvent; | ||||||
|  | import com.plotsquared.core.events.PlayerAutoPlotsChosenEvent; | ||||||
| import com.plotsquared.core.events.PlayerClaimPlotEvent; | import com.plotsquared.core.events.PlayerClaimPlotEvent; | ||||||
| import com.plotsquared.core.events.PlayerEnterPlotEvent; | import com.plotsquared.core.events.PlayerEnterPlotEvent; | ||||||
| import com.plotsquared.core.events.PlayerLeavePlotEvent; | import com.plotsquared.core.events.PlayerLeavePlotEvent; | ||||||
| @@ -38,6 +39,7 @@ import com.plotsquared.core.events.PlayerPlotTrustedEvent; | |||||||
| import com.plotsquared.core.events.PlayerTeleportToPlotEvent; | import com.plotsquared.core.events.PlayerTeleportToPlotEvent; | ||||||
| import com.plotsquared.core.events.PlotAutoMergeEvent; | import com.plotsquared.core.events.PlotAutoMergeEvent; | ||||||
| import com.plotsquared.core.events.PlotChangeOwnerEvent; | import com.plotsquared.core.events.PlotChangeOwnerEvent; | ||||||
|  | import com.plotsquared.core.events.PlotClaimedNotifyEvent; | ||||||
| import com.plotsquared.core.events.PlotClearEvent; | import com.plotsquared.core.events.PlotClearEvent; | ||||||
| import com.plotsquared.core.events.PlotComponentSetEvent; | import com.plotsquared.core.events.PlotComponentSetEvent; | ||||||
| import com.plotsquared.core.events.PlotDeleteEvent; | import com.plotsquared.core.events.PlotDeleteEvent; | ||||||
| @@ -48,6 +50,7 @@ import com.plotsquared.core.events.PlotFlagRemoveEvent; | |||||||
| import com.plotsquared.core.events.PlotMergeEvent; | import com.plotsquared.core.events.PlotMergeEvent; | ||||||
| import com.plotsquared.core.events.PlotRateEvent; | import com.plotsquared.core.events.PlotRateEvent; | ||||||
| import com.plotsquared.core.events.PlotUnlinkEvent; | import com.plotsquared.core.events.PlotUnlinkEvent; | ||||||
|  | import com.plotsquared.core.events.TeleportCause; | ||||||
| import com.plotsquared.core.listener.PlayerBlockEventType; | import com.plotsquared.core.listener.PlayerBlockEventType; | ||||||
| import com.plotsquared.core.location.Direction; | import com.plotsquared.core.location.Direction; | ||||||
| import com.plotsquared.core.location.Location; | import com.plotsquared.core.location.Location; | ||||||
| @@ -75,11 +78,13 @@ import com.sk89q.worldedit.world.block.BlockTypes; | |||||||
| import net.kyori.adventure.text.minimessage.Template; | import net.kyori.adventure.text.minimessage.Template; | ||||||
| import org.checkerframework.checker.nullness.qual.NonNull; | import org.checkerframework.checker.nullness.qual.NonNull; | ||||||
| import org.checkerframework.checker.nullness.qual.Nullable; | import org.checkerframework.checker.nullness.qual.Nullable; | ||||||
|  | import org.jetbrains.annotations.ApiStatus; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  |  | ||||||
|  | @ApiStatus.Internal | ||||||
| public class EventDispatcher { | public class EventDispatcher { | ||||||
|  |  | ||||||
|     private final EventBus eventBus = new EventBus("PlotSquaredEvents"); |     private final EventBus eventBus = new EventBus("PlotSquaredEvents"); | ||||||
| @@ -130,8 +135,23 @@ public class EventDispatcher { | |||||||
|         return event; |         return event; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public PlayerTeleportToPlotEvent callTeleport(PlotPlayer<?> player, Location from, Plot plot) { |     public PlayerAutoPlotsChosenEvent callAutoPlotsChosen( | ||||||
|         PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot); |             PlotPlayer<?> player, List<Plot> plots | ||||||
|  |     ) { | ||||||
|  |         PlayerAutoPlotsChosenEvent event = | ||||||
|  |                 new PlayerAutoPlotsChosenEvent(player, plots); | ||||||
|  |         callEvent(event); | ||||||
|  |         return event; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public PlotClaimedNotifyEvent callPlotClaimedNotify(Plot plot, boolean auto) { | ||||||
|  |         PlotClaimedNotifyEvent event = new PlotClaimedNotifyEvent(plot, auto); | ||||||
|  |         callEvent(event); | ||||||
|  |         return event; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public PlayerTeleportToPlotEvent callTeleport(PlotPlayer<?> player, Location from, Plot plot, TeleportCause cause) { | ||||||
|  |         PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot, cause); | ||||||
|         callEvent(event); |         callEvent(event); | ||||||
|         return event; |         return event; | ||||||
|     } |     } | ||||||
| @@ -263,7 +283,7 @@ public class EventDispatcher { | |||||||
|         final Plot plot = player.getCurrentPlot(); |         final Plot plot = player.getCurrentPlot(); | ||||||
|         if (Settings.Teleport.ON_LOGIN && plot != null && !(plot |         if (Settings.Teleport.ON_LOGIN && plot != null && !(plot | ||||||
|                 .getArea() instanceof SinglePlotArea)) { |                 .getArea() instanceof SinglePlotArea)) { | ||||||
|             TaskManager.runTask(() -> plot.teleportPlayer(player, result -> { |             TaskManager.runTask(() -> plot.teleportPlayer(player, TeleportCause.LOGIN, result -> { | ||||||
|             })); |             })); | ||||||
|             player.sendMessage(TranslatableCaption.of("teleport.teleported_to_road")); |             player.sendMessage(TranslatableCaption.of("teleport.teleported_to_road")); | ||||||
|         } |         } | ||||||
| @@ -272,7 +292,7 @@ public class EventDispatcher { | |||||||
|     public void doRespawnTask(final PlotPlayer<?> player) { |     public void doRespawnTask(final PlotPlayer<?> player) { | ||||||
|         final Plot plot = player.getCurrentPlot(); |         final Plot plot = player.getCurrentPlot(); | ||||||
|         if (Settings.Teleport.ON_DEATH && plot != null) { |         if (Settings.Teleport.ON_DEATH && plot != null) { | ||||||
|             TaskManager.runTask(() -> plot.teleportPlayer(player, result -> { |             TaskManager.runTask(() -> plot.teleportPlayer(player, TeleportCause.DEATH, result -> { | ||||||
|             })); |             })); | ||||||
|             player.sendMessage(TranslatableCaption.of("teleport.teleported_to_road")); |             player.sendMessage(TranslatableCaption.of("teleport.teleported_to_road")); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -68,7 +68,7 @@ public final class AutoClaimFinishTask implements Callable<Boolean> { | |||||||
|             player.sendMessage(TranslatableCaption.of("errors.no_free_plots")); |             player.sendMessage(TranslatableCaption.of("errors.no_free_plots")); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         plot.claim(player, true, schematic, false); |         plot.claim(player, true, schematic, false, true); | ||||||
|         if (area.isAutoMerge()) { |         if (area.isAutoMerge()) { | ||||||
|             PlotMergeEvent event = this.eventDispatcher.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); |             PlotMergeEvent event = this.eventDispatcher.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); | ||||||
|             if (event.getEventResult() == Result.DENY) { |             if (event.getEventResult() == Result.DENY) { | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ plugins { | |||||||
|     idea |     idea | ||||||
| } | } | ||||||
|  |  | ||||||
| var ver by extra("6.0.10") | var ver by extra("6.1.0") | ||||||
| var versuffix by extra("-SNAPSHOT") | var versuffix by extra("-SNAPSHOT") | ||||||
| val versionsuffix: String? by project | val versionsuffix: String? by project | ||||||
| if (versionsuffix != null) { | if (versionsuffix != null) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 dordsor21
					dordsor21