mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-26 15:13:45 +01:00 
			
		
		
		
	Compare commits
	
		
			11 Commits
		
	
	
		
			feature/v6
			...
			fix/expire
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | ebbbb6c670 | ||
|   | b8b3098022 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 0ae8fc46b8 | ||
|   | e0762f63a8 | ||
|   | 9f3850000c | ||
|   | 76c6be9ba7 | ||
|   | 308a5aa781 | ||
|   | e244527538 | ||
|   | 11dd013333 | ||
|   | b740d5854c | ||
|   | d5445cfbef | 
| @@ -24,7 +24,7 @@ dependencies { | ||||
|     implementation("org.bstats:bstats-bukkit") | ||||
|  | ||||
|     // Paper | ||||
|     compileOnly(libs.paper) | ||||
|     compileOnly("io.papermc.paper:paper-api") | ||||
|     implementation("io.papermc:paperlib") | ||||
|  | ||||
|     // Plugins | ||||
|   | ||||
| @@ -849,11 +849,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | ||||
|                             // managed elsewhere | ||||
|                             continue; | ||||
|                         case "SHULKER": | ||||
|                             if (Settings.Enabled_Components.KILL_ROAD_MOBS) { | ||||
|                             if (Settings.Enabled_Components.KILL_ROAD_MOBS && (Settings.Enabled_Components.KILL_NAMED_ROAD_MOBS || entity.getCustomName() == null)) { | ||||
|                                 LivingEntity livingEntity = (LivingEntity) entity; | ||||
|                                 List<MetadataValue> meta = entity.getMetadata("shulkerPlot"); | ||||
|                                 if (!meta.isEmpty()) { | ||||
|                                     if (livingEntity.isLeashed()) { | ||||
|                                     if (livingEntity.isLeashed() && !Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS) { | ||||
|                                         continue; | ||||
|                                     } | ||||
|                                     List<MetadataValue> keep = entity.getMetadata("keep"); | ||||
| @@ -866,10 +866,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | ||||
|                                         com.plotsquared.core.location.Location pLoc = BukkitUtil.adapt(entity.getLocation()); | ||||
|                                         PlotArea area = pLoc.getPlotArea(); | ||||
|                                         if (area != null) { | ||||
|                                             PlotId currentPlotId = area.getPlotAbs(pLoc).getId(); | ||||
|                                             if (!originalPlotId.equals(currentPlotId) && (currentPlotId == null || !area.getPlot( | ||||
|                                                             originalPlotId) | ||||
|                                                     .equals(area.getPlot(currentPlotId)))) { | ||||
|                                             Plot currentPlot = area.getPlotAbs(pLoc); | ||||
|                                             if (currentPlot == null || !originalPlotId.equals(currentPlot.getId())) { | ||||
|                                                 if (entity.hasMetadata("ps-tmp-teleport")) { | ||||
|                                                     continue; | ||||
|                                                 } | ||||
| @@ -883,11 +881,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | ||||
|                                     com.plotsquared.core.location.Location pLoc = BukkitUtil.adapt(entity.getLocation()); | ||||
|                                     PlotArea area = pLoc.getPlotArea(); | ||||
|                                     if (area != null) { | ||||
|                                         PlotId currentPlotId = area.getPlotAbs(pLoc).getId(); | ||||
|                                         if (currentPlotId != null) { | ||||
|                                         Plot currentPlot = area.getPlotAbs(pLoc); | ||||
|                                         if (currentPlot != null) { | ||||
|                                             entity.setMetadata( | ||||
|                                                     "shulkerPlot", | ||||
|                                                     new FixedMetadataValue((Plugin) PlotSquared.platform(), currentPlotId) | ||||
|                                                     new FixedMetadataValue((Plugin) PlotSquared.platform(), currentPlot.getId()) | ||||
|                                             ); | ||||
|                                         } | ||||
|                                     } | ||||
| @@ -973,7 +971,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | ||||
|                                                 || !entity.hasMetadata("keep")) { | ||||
|                                             Entity passenger = entity.getPassenger(); | ||||
|                                             if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS | ||||
|                                                     || !(passenger instanceof Player)) && entity.getMetadata("keep").isEmpty()) { | ||||
|                                                     || !((passenger instanceof Player) || livingEntity.isLeashed())) | ||||
|                                                     && (Settings.Enabled_Components.KILL_NAMED_ROAD_MOBS || entity.getCustomName() == null) | ||||
|                                                     && entity.getMetadata("keep").isEmpty()) { | ||||
|                                                 if (entity.hasMetadata("ps-tmp-teleport")) { | ||||
|                                                     continue; | ||||
|                                                 } | ||||
| @@ -983,8 +983,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | ||||
|                                         } | ||||
|                                     } else { | ||||
|                                         Entity passenger = entity.getPassenger(); | ||||
|                                         if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS | ||||
|                                                 || !(passenger instanceof Player)) && entity.getMetadata("keep").isEmpty()) { | ||||
|                                         if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS || !(passenger instanceof Player)) | ||||
|                                                 && (Settings.Enabled_Components.KILL_NAMED_ROAD_MOBS && entity.getCustomName() != null) | ||||
|                                                 && entity.getMetadata("keep").isEmpty()) { | ||||
|                                             if (entity.hasMetadata("ps-tmp-teleport")) { | ||||
|                                                 continue; | ||||
|                                             } | ||||
|   | ||||
| @@ -183,7 +183,11 @@ public class GenChunk extends ScopedQueueCoordinator { | ||||
|  | ||||
|     @Override | ||||
|     public boolean setBlock(int x, int y, int z, @NonNull Pattern pattern) { | ||||
|         return setBlock(x, y, z, PatternUtil.apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z)); | ||||
|         final BaseBlock block = PatternUtil.apply(Preconditions.checkNotNull( | ||||
|                 pattern, | ||||
|                 "Pattern may not be null" | ||||
|         ), x + (chunkX << 4), y, z + (chunkZ << 4)); | ||||
|         return setBlock(x, y, z, block); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -32,6 +32,7 @@ import com.plotsquared.core.inject.annotations.DefaultGenerator; | ||||
| import com.plotsquared.core.location.World; | ||||
| import com.plotsquared.core.permissions.PermissionHandler; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.world.PlotAreaManager; | ||||
| import com.plotsquared.core.queue.GlobalBlockQueue; | ||||
| import com.plotsquared.core.util.ChunkManager; | ||||
| @@ -284,6 +285,16 @@ public interface PlotPlatform<P> extends LocaleHolder { | ||||
|         return injector().getInstance(ChunkManager.class); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the {@link ExpireManager} implementation for the platform | ||||
|      * | ||||
|      * @return Expire manager | ||||
|      * @since TODO | ||||
|      */ | ||||
|     default @NonNull ExpireManager expireManager() { | ||||
|         return injector().getInstance(ExpireManager.class); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the {@link PlotAreaManager} implementation. | ||||
|      * | ||||
|   | ||||
| @@ -290,11 +290,11 @@ public class PlotSquared { | ||||
|  | ||||
|     public void startExpiryTasks() { | ||||
|         if (Settings.Enabled_Components.PLOT_EXPIRY) { | ||||
|             ExpireManager.IMP = new ExpireManager(this.eventDispatcher); | ||||
|             ExpireManager.IMP.runAutomatedTask(); | ||||
|             ExpireManager expireManager = PlotSquared.platform().expireManager(); | ||||
|             expireManager.runAutomatedTask(); | ||||
|             for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) { | ||||
|                 ExpiryTask task = new ExpiryTask(settings, this.getPlotAreaManager()); | ||||
|                 ExpireManager.IMP.addTask(task); | ||||
|                 expireManager.addTask(task); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @@ -645,7 +645,8 @@ public class PlotSquared { | ||||
|         } else { | ||||
|             list = new ArrayList<>(input); | ||||
|         } | ||||
|         list.sort(Comparator.comparingLong(a -> ExpireManager.IMP.getTimestamp(a.getOwnerAbs()))); | ||||
|         ExpireManager expireManager = PlotSquared.platform().expireManager(); | ||||
|         list.sort(Comparator.comparingLong(a -> expireManager.getTimestamp(a.getOwnerAbs()))); | ||||
|         return list; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -19,6 +19,7 @@ | ||||
| package com.plotsquared.core.command; | ||||
|  | ||||
| import com.google.inject.Inject; | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.caption.StaticCaption; | ||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||
| import com.plotsquared.core.events.PlotFlagRemoveEvent; | ||||
| @@ -139,10 +140,7 @@ public class DebugExec extends SubCommand { | ||||
|                     return true; | ||||
|                 } | ||||
|                 case "start-expire" -> { | ||||
|                     if (ExpireManager.IMP == null) { | ||||
|                         ExpireManager.IMP = new ExpireManager(this.eventDispatcher); | ||||
|                     } | ||||
|                     if (ExpireManager.IMP.runAutomatedTask()) { | ||||
|                     if (PlotSquared.platform().expireManager().runAutomatedTask()) { | ||||
|                         player.sendMessage(TranslatableCaption.of("debugexec.expiry_started")); | ||||
|                     } else { | ||||
|                         player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started")); | ||||
| @@ -150,7 +148,7 @@ public class DebugExec extends SubCommand { | ||||
|                     return true; | ||||
|                 } | ||||
|                 case "stop-expire" -> { | ||||
|                     if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) { | ||||
|                     if (!PlotSquared.platform().expireManager().cancelTask()) { | ||||
|                         player.sendMessage(TranslatableCaption.of("debugexec.task_halted")); | ||||
|                     } else { | ||||
|                         player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled")); | ||||
|   | ||||
| @@ -19,6 +19,7 @@ | ||||
| package com.plotsquared.core.command; | ||||
|  | ||||
| import com.google.inject.Inject; | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.Settings; | ||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||
| import com.plotsquared.core.events.PlotDoneEvent; | ||||
| @@ -29,7 +30,6 @@ import com.plotsquared.core.location.Location; | ||||
| import com.plotsquared.core.permissions.Permission; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.expiration.PlotAnalysis; | ||||
| import com.plotsquared.core.plot.flag.PlotFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.DoneFlag; | ||||
| @@ -94,7 +94,7 @@ public class Done extends SubCommand { | ||||
|                 Template.of("plot", plot.getId().toString()) | ||||
|         ); | ||||
|         final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done"); | ||||
|         if (ExpireManager.IMP == null || doneRequirements == null) { | ||||
|         if (PlotSquared.platform().expireManager() == null || doneRequirements == null) { | ||||
|             finish(plot, player, true); | ||||
|             plot.removeRunning(); | ||||
|         } else { | ||||
|   | ||||
| @@ -30,7 +30,6 @@ import com.plotsquared.core.permissions.Permission; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.flag.implementations.DoneFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.PriceFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag; | ||||
| @@ -240,7 +239,7 @@ public class ListCmd extends SubCommand { | ||||
|                     ); | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (ExpireManager.IMP == null) { | ||||
|                 if (PlotSquared.platform().expireManager() == null) { | ||||
|                     plotConsumer.accept(PlotQuery.newQuery().noPlots()); | ||||
|                 } else { | ||||
|                     plotConsumer.accept(PlotQuery.newQuery().expiredPlots()); | ||||
|   | ||||
| @@ -282,28 +282,7 @@ public class Merge extends SubCommand { | ||||
|                 run.run(); | ||||
|             } | ||||
|         } | ||||
|         if (force || !isOnline) { | ||||
|             if (force || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE)) { | ||||
|                 if (plot.getPlotModificationManager().autoMerge(direction, maxSize - size, uuids.iterator().next(), player, terrain)) { | ||||
|                     if (this.econHandler.isEnabled(plotArea) && price > 0d) { | ||||
|                         if (!force && this.econHandler.getMoney(player) < price) { | ||||
|                             player.sendMessage( | ||||
|                                     TranslatableCaption.of("economy.cannot_afford_merge"), | ||||
|                                     Template.of("money", this.econHandler.format(price)) | ||||
|                             ); | ||||
|                             return false; | ||||
|                         } | ||||
|                         this.econHandler.withdrawMoney(player, price); | ||||
|                         player.sendMessage( | ||||
|                                 TranslatableCaption.of("economy.removed_balance"), | ||||
|                                 Template.of("money", this.econHandler.format(price)) | ||||
|                         ); | ||||
|                     } | ||||
|                     player.sendMessage(TranslatableCaption.of("merge.success_merge")); | ||||
|                     eventDispatcher.callPostMerge(player, plot); | ||||
|                     return true; | ||||
|                 } | ||||
|             } | ||||
|         if (!force && !isOnline) { | ||||
|             player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); | ||||
|             return false; | ||||
|         } | ||||
|   | ||||
| @@ -25,7 +25,6 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||
| import com.plotsquared.core.location.Location; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.world.PlotAreaManager; | ||||
| import com.plotsquared.core.queue.GlobalBlockQueue; | ||||
| import com.plotsquared.core.queue.QueueCoordinator; | ||||
| @@ -92,8 +91,8 @@ public class Trim extends SubCommand { | ||||
|         } | ||||
|         TranslatableCaption.of("trim.trim_starting"); | ||||
|         final List<Plot> plots = PlotQuery.newQuery().inWorld(world).asList(); | ||||
|         if (ExpireManager.IMP != null) { | ||||
|             plots.removeAll(ExpireManager.IMP.getPendingExpired()); | ||||
|         if (PlotSquared.platform().expireManager() != null) { | ||||
|             plots.removeAll(PlotSquared.platform().expireManager().getPendingExpired()); | ||||
|         } | ||||
|         result.value1 = new HashSet<>(PlotSquared.platform().worldUtil().getChunkChunks(world)); | ||||
|         result.value2 = new HashSet<>(); | ||||
|   | ||||
| @@ -759,6 +759,8 @@ public class Settings extends Config { | ||||
|         @Comment("Also kill any road mobs that are being ridden, or are leashed") | ||||
|         public static boolean | ||||
|                 KILL_OWNED_ROAD_MOBS = false; | ||||
|         @Comment("Also kill any road mobs that are named") | ||||
|         public static boolean KILL_NAMED_ROAD_MOBS = false; | ||||
|         @Comment("Kill items on roads (Stick, Paper, etc.)") | ||||
|         public static boolean KILL_ROAD_ITEMS = false; | ||||
|         @Comment("Kill vehicles on roads (Boat, Minecart, etc.)") | ||||
|   | ||||
| @@ -53,7 +53,10 @@ final class ClassLoaderCaptionProvider implements DefaultCaptionProvider { | ||||
|         try { | ||||
|             final InputStream stream = this.classLoader.getResourceAsStream(url); | ||||
|             if (stream == null) { | ||||
|                 LOGGER.warn("No resource for locale '{}' found", locale); | ||||
|                 LOGGER.info("No resource for locale '{}' found in the plugin file." + | ||||
|                                 "Please ensure you have placed the latest version of the file messages_{}.json in the 'lang' folder." + | ||||
|                                 "You may be able to find completed translations at https://intellectualsites.crowdin.com/plotsquared", | ||||
|                         locale, locale); | ||||
|                 return null; | ||||
|             } | ||||
|             try (final BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { | ||||
|   | ||||
| @@ -174,8 +174,9 @@ public class HybridPlotManager extends ClassicPlotManager { | ||||
|                     for (int y = 0; y < blocks.length; y++) { | ||||
|                         if (blocks[y] != null) { | ||||
|                             queue.setBlock(x, minY + y, z, blocks[y]); | ||||
|                         } else { | ||||
|                         } else if (!isRoad) { | ||||
|                             // This is necessary, otherwise any blocks not specified in the schematic will remain after a clear | ||||
|                             //  Do not set air for road as this may cause cavernous roads when debugroadregen is used | ||||
|                             queue.setBlock(x, minY + y, z, airBlock); | ||||
|                         } | ||||
|                     } | ||||
|   | ||||
| @@ -21,7 +21,6 @@ package com.plotsquared.core.generator; | ||||
| import com.google.inject.Inject; | ||||
| import com.google.inject.assistedinject.Assisted; | ||||
| import com.intellectualsites.annotations.DoNotUse; | ||||
| import com.intellectualsites.annotations.NotPublic; | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.ConfigurationSection; | ||||
| import com.plotsquared.core.configuration.Settings; | ||||
| @@ -75,6 +74,9 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|     public short PATH_WIDTH_UPPER; | ||||
|     public HashMap<Integer, BaseBlock[]> G_SCH; | ||||
|     public HashMap<Integer, BiomeType> G_SCH_B; | ||||
|     /** | ||||
|      * The Y level at which schematic generation will start, lowest of either road or plot schematic generation. | ||||
|      */ | ||||
|     public int SCHEM_Y; | ||||
|     private Location SIGN_LOCATION; | ||||
|     private File root = null; | ||||
| @@ -267,34 +269,64 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|         int oddshift = (this.ROAD_WIDTH & 1); | ||||
|  | ||||
|         SCHEM_Y = schematicStartHeight(); | ||||
|  | ||||
|         // plotY and roadY are important to allow plot and/or road schematic "overflow" into each other without causing AIOOB | ||||
|         //  exceptions when attempting either to set blocks to, or get block from G_SCH | ||||
|         // Default plot schematic start height, normalized to the minimum height schematics are pasted from. | ||||
|         int plotY = PLOT_HEIGHT - SCHEM_Y; | ||||
|         int minRoadWall = Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT ? Math.min(ROAD_HEIGHT, WALL_HEIGHT) : ROAD_HEIGHT; | ||||
|         // Default road schematic start height, normalized to the minimum height schematics are pasted from. | ||||
|         int roadY = minRoadWall - SCHEM_Y; | ||||
|  | ||||
|         int worldHeight = getMaxGenHeight() - getMinGenHeight() + 1; | ||||
|         int worldGenHeight = getMaxGenHeight() - getMinGenHeight() + 1; | ||||
|  | ||||
|         int maxSchematicHeight = 0; | ||||
|         int plotSchemHeight = 0; | ||||
|  | ||||
|         // SCHEM_Y should be normalised to the plot "start" height | ||||
|         if (schematic3 != null) { | ||||
|             if (schematic3.getClipboard().getDimensions().getY() == worldHeight) { | ||||
|                 SCHEM_Y = plotY = 0; | ||||
|             plotSchemHeight = maxSchematicHeight = schematic3.getClipboard().getDimensions().getY(); | ||||
|             if (maxSchematicHeight == worldGenHeight) { | ||||
|                 SCHEM_Y = getMinGenHeight(); | ||||
|                 plotY = 0; | ||||
|             } else if (!Settings.Schematics.PASTE_ON_TOP) { | ||||
|                 SCHEM_Y = plotY = getMinBuildHeight() - getMinGenHeight(); | ||||
|                 SCHEM_Y = getMinBuildHeight(); | ||||
|                 plotY = 0; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         int roadSchemHeight; | ||||
|  | ||||
|         if (schematic1 != null) { | ||||
|             if (schematic1.getClipboard().getDimensions().getY() == worldHeight) { | ||||
|                 SCHEM_Y = roadY = getMinGenHeight(); | ||||
|                 if (schematic3 != null && schematic3.getClipboard().getDimensions().getY() != worldHeight | ||||
|                         && !Settings.Schematics.PASTE_ON_TOP) { | ||||
|                     plotY = PLOT_HEIGHT; | ||||
|             roadSchemHeight = schematic1.getClipboard().getDimensions().getY(); | ||||
|             maxSchematicHeight = Math.max(roadSchemHeight, maxSchematicHeight); | ||||
|             if (maxSchematicHeight == worldGenHeight) { | ||||
|                 SCHEM_Y = getMinGenHeight(); | ||||
|                 roadY = 0; // Road is the lowest schematic | ||||
|                 if (schematic3 != null && schematic3.getClipboard().getDimensions().getY() != worldGenHeight) { | ||||
|                     // Road is the lowest schematic. Normalize plotY to it. | ||||
|                     if (Settings.Schematics.PASTE_ON_TOP) { | ||||
|                         plotY = PLOT_HEIGHT - getMinGenHeight(); | ||||
|                     } else { | ||||
|                         plotY = getMinBuildHeight() - getMinGenHeight(); | ||||
|                     } | ||||
|                 } | ||||
|             } else if (!Settings.Schematics.PASTE_ROAD_ON_TOP) { | ||||
|                 SCHEM_Y = roadY = getMinBuildHeight(); | ||||
|                 if (schematic3 != null && schematic3.getClipboard().getDimensions().getY() != worldHeight | ||||
|                         && !Settings.Schematics.PASTE_ON_TOP) { | ||||
|                     plotY = PLOT_HEIGHT; | ||||
|                 if (SCHEM_Y == getMinGenHeight()) { // Only possible if plot schematic is enabled | ||||
|                     // Plot is still the lowest schematic, normalize roadY to it | ||||
|                     roadY = getMinBuildHeight() - getMinGenHeight(); | ||||
|                 } else if (schematic3 != null) { | ||||
|                     SCHEM_Y = getMinBuildHeight(); | ||||
|                     roadY = 0;// Road is the lowest schematic | ||||
|                     if (Settings.Schematics.PASTE_ON_TOP) { | ||||
|                         // Road is the lowest schematic. Normalize plotY to it. | ||||
|                         plotY = PLOT_HEIGHT - getMinBuildHeight(); | ||||
|                     } | ||||
|                     maxSchematicHeight = Math.max(maxSchematicHeight, plotY + plotSchemHeight); | ||||
|                 } | ||||
|             } else { | ||||
|                 roadY = minRoadWall - SCHEM_Y; | ||||
|                 maxSchematicHeight = Math.max(maxSchematicHeight, roadY + roadSchemHeight); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -331,17 +363,15 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|                                 y + min.getBlockY(), | ||||
|                                 z + min.getBlockZ() | ||||
|                         )); | ||||
|                         if (!id.getBlockType().getMaterial().isAir()) { | ||||
|                             schem3PopulationNeeded |= id.hasNbtData(); | ||||
|                             addOverlayBlock( | ||||
|                                     (short) (x + shift + oddshift + centerShiftX), | ||||
|                                     (short) (y + plotY), | ||||
|                                     (short) (z + shift + oddshift + centerShiftZ), | ||||
|                                     id, | ||||
|                                     false, | ||||
|                                     h3 | ||||
|                             ); | ||||
|                         } | ||||
|                         schem3PopulationNeeded |= id.hasNbtData(); | ||||
|                         addOverlayBlock( | ||||
|                                 (short) (x + shift + oddshift + centerShiftX), | ||||
|                                 (short) (y + plotY), | ||||
|                                 (short) (z + shift + oddshift + centerShiftZ), | ||||
|                                 id, | ||||
|                                 false, | ||||
|                                 maxSchematicHeight | ||||
|                         ); | ||||
|                     } | ||||
|                     if (blockArrayClipboard3.hasBiomes()) { | ||||
|                         BiomeType biome = blockArrayClipboard3.getBiome(BlockVector2.at( | ||||
| @@ -391,18 +421,23 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|                             y + min.getBlockY(), | ||||
|                             z + min.getBlockZ() | ||||
|                     )); | ||||
|                     if (!id.getBlockType().getMaterial().isAir()) { | ||||
|                         schem1PopulationNeeded |= id.hasNbtData(); | ||||
|                         addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z + shift + oddshift), id, false, h1); | ||||
|                         addOverlayBlock( | ||||
|                                 (short) (z + shift + oddshift), | ||||
|                                 (short) (y + roadY), | ||||
|                                 (short) (shift - x + (oddshift - 1)), | ||||
|                                 id, | ||||
|                                 true, | ||||
|                                 h1 | ||||
|                         ); | ||||
|                     } | ||||
|                     schem1PopulationNeeded |= id.hasNbtData(); | ||||
|                     addOverlayBlock( | ||||
|                             (short) (x - shift), | ||||
|                             (short) (y + roadY), | ||||
|                             (short) (z + shift + oddshift), | ||||
|                             id, | ||||
|                             false, | ||||
|                             maxSchematicHeight | ||||
|                     ); | ||||
|                     addOverlayBlock( | ||||
|                             (short) (z + shift + oddshift), | ||||
|                             (short) (y + roadY), | ||||
|                             (short) (shift - x + (oddshift - 1)), | ||||
|                             id, | ||||
|                             true, | ||||
|                             maxSchematicHeight | ||||
|                     ); | ||||
|                 } | ||||
|                 if (blockArrayClipboard1.hasBiomes()) { | ||||
|                     BiomeType biome = blockArrayClipboard1.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ())); | ||||
| @@ -430,10 +465,15 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|                             y + min.getBlockY(), | ||||
|                             z + min.getBlockZ() | ||||
|                     )); | ||||
|                     if (!id.getBlockType().getMaterial().isAir()) { | ||||
|                         schem2PopulationNeeded |= id.hasNbtData(); | ||||
|                         addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z - shift), id, false, h2); | ||||
|                     } | ||||
|                     schem2PopulationNeeded |= id.hasNbtData(); | ||||
|                     addOverlayBlock( | ||||
|                             (short) (x - shift), | ||||
|                             (short) (y + roadY), | ||||
|                             (short) (z - shift), | ||||
|                             id, | ||||
|                             false, | ||||
|                             maxSchematicHeight | ||||
|                     ); | ||||
|                 } | ||||
|                 if (blockArrayClipboard2.hasBiomes()) { | ||||
|                     BiomeType biome = blockArrayClipboard2.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ())); | ||||
| @@ -443,6 +483,10 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @deprecated This method should not be available for public API usage and will be made private. | ||||
|      */ | ||||
|     @Deprecated(forRemoval = true, since = "TODO") | ||||
|     public void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) { | ||||
|         if (z < 0) { | ||||
|             z += this.SIZE; | ||||
| @@ -462,13 +506,22 @@ public class HybridPlotWorld extends ClassicPlotWorld { | ||||
|         if (y >= height) { | ||||
|             if (y > lastOverlayHeightError) { | ||||
|                 lastOverlayHeightError = y; | ||||
|                 LOGGER.error(String.format("Error adding overlay block. `y > height`. y=%s, height=%s", y, height)); | ||||
|                 LOGGER.error( | ||||
|                         "Error adding overlay block in world {}. `y > height`. y={}, height={}", | ||||
|                         getWorldName(), | ||||
|                         y, | ||||
|                         height | ||||
|                 ); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         existing[y] = id; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @deprecated This method should not be available for public API usage and will be made private. | ||||
|      */ | ||||
|     @Deprecated(forRemoval = true, since = "TODO") | ||||
|     public void addOverlayBiome(short x, short z, BiomeType id) { | ||||
|         if (z < 0) { | ||||
|             z += this.SIZE; | ||||
|   | ||||
| @@ -36,7 +36,6 @@ import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.PlotTitle; | ||||
| import com.plotsquared.core.plot.PlotWeather; | ||||
| import com.plotsquared.core.plot.comment.CommentManager; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.flag.GlobalFlagContainer; | ||||
| import com.plotsquared.core.plot.flag.PlotFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.DenyExitFlag; | ||||
| @@ -163,8 +162,8 @@ public class PlotListener { | ||||
|             if ((last != null) && !last.getId().equals(plot.getId())) { | ||||
|                 plotExit(player, last); | ||||
|             } | ||||
|             if (ExpireManager.IMP != null) { | ||||
|                 ExpireManager.IMP.handleEntry(player, plot); | ||||
|             if (PlotSquared.platform().expireManager() != null) { | ||||
|                 PlotSquared.platform().expireManager().handleEntry(player, plot); | ||||
|             } | ||||
|             lastPlot.set(plot); | ||||
|         } | ||||
|   | ||||
| @@ -162,7 +162,6 @@ public enum Permission { | ||||
|     PERMISSION_LIST_AREA("plots.list.area"), | ||||
|     PERMISSION_ADMIN_COMMAND_LOAD("plots.admin.command.load"), | ||||
|     PERMISSION_ADMIN_COMMAND_MERGE("plots.admin.command.merge"), | ||||
|     PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE("plots.admin.command.merge.other.offline"), | ||||
|     PERMISSION_ADMIN_COMMAND_SET_OWNER("plots.admin.command.setowner"), | ||||
|     PERMISSION_COMMENT("plots.comment"), | ||||
|     PERMISSION_INBOX("plots.inbox"), | ||||
|   | ||||
| @@ -42,7 +42,6 @@ import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.PlotCluster; | ||||
| import com.plotsquared.core.plot.PlotId; | ||||
| import com.plotsquared.core.plot.PlotWeather; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.flag.implementations.DoneFlag; | ||||
| import com.plotsquared.core.plot.world.PlotAreaManager; | ||||
| import com.plotsquared.core.plot.world.SinglePlotArea; | ||||
| @@ -618,8 +617,8 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer, | ||||
|                 LOGGER.info("Plot {} was deleted + cleared due to {} getting banned", owned.getId(), getName()); | ||||
|             } | ||||
|         } | ||||
|         if (ExpireManager.IMP != null) { | ||||
|             ExpireManager.IMP.storeDate(getUUID(), System.currentTimeMillis()); | ||||
|         if (PlotSquared.platform().expireManager() != null) { | ||||
|             PlotSquared.platform().expireManager().storeDate(getUUID(), System.currentTimeMillis()); | ||||
|         } | ||||
|         PlotSquared.platform().playerManager().removePlayer(this); | ||||
|         PlotSquared.platform().unregister(this); | ||||
|   | ||||
| @@ -40,7 +40,6 @@ import com.plotsquared.core.location.Location; | ||||
| import com.plotsquared.core.permissions.Permission; | ||||
| import com.plotsquared.core.player.ConsolePlayer; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.expiration.PlotAnalysis; | ||||
| import com.plotsquared.core.plot.flag.FlagContainer; | ||||
| import com.plotsquared.core.plot.flag.GlobalFlagContainer; | ||||
| @@ -1105,8 +1104,8 @@ public class Plot { | ||||
|      * @return A boolean indicating whether or not the operation succeeded | ||||
|      */ | ||||
|     public <V> boolean setFlag(final @NonNull PlotFlag<V, ?> flag) { | ||||
|         if (flag instanceof KeepFlag && ExpireManager.IMP != null) { | ||||
|             ExpireManager.IMP.updateExpired(this); | ||||
|         if (flag instanceof KeepFlag && PlotSquared.platform().expireManager() != null) { | ||||
|             PlotSquared.platform().expireManager().updateExpired(this); | ||||
|         } | ||||
|         for (final Plot plot : this.getConnectedPlots()) { | ||||
|             plot.getFlagContainer().addFlag(flag); | ||||
| @@ -2831,11 +2830,11 @@ public class Plot { | ||||
|                     Component members = PlayerManager.getPlayerList(this.getMembers(), player); | ||||
|                     Component denied = PlayerManager.getPlayerList(this.getDenied(), player); | ||||
|                     String seen; | ||||
|                     if (Settings.Enabled_Components.PLOT_EXPIRY && ExpireManager.IMP != null) { | ||||
|                     if (Settings.Enabled_Components.PLOT_EXPIRY && PlotSquared.platform().expireManager() != null) { | ||||
|                         if (this.isOnline()) { | ||||
|                             seen = TranslatableCaption.of("info.now").getComponent(player); | ||||
|                         } else { | ||||
|                             int time = (int) (ExpireManager.IMP.getAge(this, false) / 1000); | ||||
|                             int time = (int) (PlotSquared.platform().expireManager().getAge(this, false) / 1000); | ||||
|                             if (time != 0) { | ||||
|                                 seen = TimeUtil.secToTime(time); | ||||
|                             } else { | ||||
|   | ||||
| @@ -18,6 +18,8 @@ | ||||
|  */ | ||||
| package com.plotsquared.core.plot.expiration; | ||||
|  | ||||
| import com.google.inject.Inject; | ||||
| import com.plotsquared.core.PlotPlatform; | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.caption.Caption; | ||||
| import com.plotsquared.core.configuration.caption.Templates; | ||||
| @@ -60,6 +62,10 @@ import java.util.concurrent.ConcurrentLinkedDeque; | ||||
|  | ||||
| public class ExpireManager { | ||||
|  | ||||
|     /** | ||||
|      * @deprecated Use {@link PlotPlatform#expireManager()} instead | ||||
|      */ | ||||
|     @Deprecated(forRemoval = true, since = "TODO") | ||||
|     public static ExpireManager IMP; | ||||
|     private final ConcurrentHashMap<UUID, Long> dates_cache; | ||||
|     private final ConcurrentHashMap<UUID, Long> account_age_cache; | ||||
| @@ -71,6 +77,7 @@ public class ExpireManager { | ||||
|      */ | ||||
|     private int running; | ||||
|  | ||||
|     @Inject | ||||
|     public ExpireManager(final @NonNull EventDispatcher eventDispatcher) { | ||||
|         this.tasks = new ArrayDeque<>(); | ||||
|         this.dates_cache = new ConcurrentHashMap<>(); | ||||
|   | ||||
| @@ -18,6 +18,7 @@ | ||||
|  */ | ||||
| package com.plotsquared.core.plot.expiration; | ||||
|  | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.Settings; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.PlotArea; | ||||
| @@ -72,8 +73,9 @@ public class ExpiryTask { | ||||
|                         min = false; | ||||
|                         diff = plots.size() - settings.REQUIRED_PLOTS; | ||||
|                     } | ||||
|                     ExpireManager expireManager = PlotSquared.platform().expireManager(); | ||||
|                     List<Long> entireList = | ||||
|                             plots.stream().map(plot -> ExpireManager.IMP.getAge(plot, settings.DELETE_IF_OWNER_IS_UNKNOWN)) | ||||
|                             plots.stream().map(plot -> expireManager.getAge(plot, settings.DELETE_IF_OWNER_IS_UNKNOWN)) | ||||
|                                     .collect(Collectors.toList()); | ||||
|                     List<Long> top = new ArrayList<>(diff + 1); | ||||
|                     if (diff > 1000) { | ||||
|   | ||||
| @@ -116,7 +116,7 @@ public class BlockArrayCacheScopedQueueCoordinator extends ScopedQueueCoordinato | ||||
|         x += offsetX; | ||||
|         z += offsetZ; | ||||
|         if (x >= scopeMinX && x < scopeMaxX && y >= minY && y <= maxY && z >= scopeMinZ && z < scopeMaxZ) { | ||||
|             blockStates[y - minY][x][z] = id.toImmutableState(); | ||||
|             blockStates[y - minY][x - scopeMinX][z - scopeMinZ] = id.toImmutableState(); | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|   | ||||
| @@ -20,6 +20,7 @@ package com.plotsquared.core.util; | ||||
|  | ||||
| import com.google.common.eventbus.EventBus; | ||||
| import com.intellectualsites.annotations.DoNotUse; | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.configuration.Settings; | ||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||
| import com.plotsquared.core.events.PlayerAutoPlotEvent; | ||||
| @@ -59,7 +60,6 @@ import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.PlotId; | ||||
| import com.plotsquared.core.plot.Rating; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
| import com.plotsquared.core.plot.flag.PlotFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.DeviceInteractFlag; | ||||
| import com.plotsquared.core.plot.flag.implementations.MiscPlaceFlag; | ||||
| @@ -300,8 +300,8 @@ public class EventDispatcher { | ||||
|         if (player == null) { | ||||
|             return; //possible future warning message to figure out where we are retrieving null | ||||
|         } | ||||
|         if (ExpireManager.IMP != null) { | ||||
|             ExpireManager.IMP.handleJoin(player); | ||||
|         if (PlotSquared.platform().expireManager() != null) { | ||||
|             PlotSquared.platform().expireManager().handleJoin(player); | ||||
|         } | ||||
|         if (this.worldEdit != null) { | ||||
|             if (player.getAttribute("worldedit")) { | ||||
|   | ||||
| @@ -29,7 +29,6 @@ import com.sk89q.worldedit.extension.input.ParserContext; | ||||
| import com.sk89q.worldedit.extension.platform.Actor; | ||||
| import com.sk89q.worldedit.function.pattern.BlockPattern; | ||||
| import com.sk89q.worldedit.function.pattern.Pattern; | ||||
| import com.sk89q.worldedit.function.pattern.RandomPattern; | ||||
| import com.sk89q.worldedit.math.BlockVector3; | ||||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||||
| import com.sk89q.worldedit.world.block.BlockState; | ||||
| @@ -44,7 +43,7 @@ public class PatternUtil { | ||||
|  | ||||
|     public static BaseBlock apply(@NonNull Pattern pattern, int x, int y, int z) { | ||||
|         Preconditions.checkNotNull(pattern, "Pattern may not be null"); | ||||
|         if (pattern instanceof BlockPattern || pattern instanceof RandomPattern | ||||
|         if (pattern instanceof BlockPattern | ||||
|                 || pattern instanceof BlockState || pattern instanceof BlockType | ||||
|                 || pattern instanceof BaseBlock) { | ||||
|             return pattern.applyBlock(BlockVector3.ZERO); | ||||
|   | ||||
| @@ -36,7 +36,8 @@ import java.util.regex.Pattern; | ||||
|  | ||||
| public class StringMan { | ||||
|  | ||||
|     private static final Pattern STRING_SPLIT_PATTERN = Pattern.compile("(?<quoted>\"[\\w ]+\")|(?<single>\\w+)"); | ||||
|     // Stolen from https://stackoverflow.com/a/366532/12620913 | Debug: https://regex101.com/r/DudJLb/1 | ||||
|     private static final Pattern STRING_SPLIT_PATTERN = Pattern.compile("[^\\s\"]+|\"([^\"]*)\""); | ||||
|  | ||||
|     public static String replaceFromMap(String string, Map<String, String> replacements) { | ||||
|         StringBuilder sb = new StringBuilder(string); | ||||
| @@ -355,7 +356,7 @@ public class StringMan { | ||||
|         var matcher = StringMan.STRING_SPLIT_PATTERN.matcher(message); | ||||
|         List<String> splitMessages = new ArrayList<>(); | ||||
|         while (matcher.find()) { | ||||
|             splitMessages.add(matcher.group(0).replaceAll("\"", "")); | ||||
|             splitMessages.add(matcher.group(matcher.groupCount() - 1).replaceAll("\"", "")); | ||||
|         } | ||||
|         return splitMessages; | ||||
|     } | ||||
|   | ||||
| @@ -18,8 +18,8 @@ | ||||
|  */ | ||||
| package com.plotsquared.core.util.query; | ||||
|  | ||||
| import com.plotsquared.core.PlotSquared; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.expiration.ExpireManager; | ||||
|  | ||||
| import java.util.Collection; | ||||
|  | ||||
| @@ -27,7 +27,7 @@ class ExpiredPlotProvider implements PlotProvider { | ||||
|  | ||||
|     @Override | ||||
|     public Collection<Plot> getPlots() { | ||||
|         return ExpireManager.IMP.getPendingExpired(); | ||||
|         return PlotSquared.platform().expireManager().getPendingExpired(); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -101,7 +101,7 @@ public class FlagTest { | ||||
|     public void shouldSuccessfullyParseTitleFlagWithTitleEmptyAndSubTitleSingleWord() { | ||||
|         Assertions.assertDoesNotThrow(() -> { | ||||
|             var title = PlotTitleFlag.TITLE_FLAG_DEFAULT.parse("\"\" \"single\"").getValue(); | ||||
|             Assertions.assertEquals(" ", title.title()); | ||||
|             Assertions.assertEquals("", title.title()); | ||||
|             Assertions.assertEquals("single", title.subtitle()); | ||||
|         }, "Should not throw a FlagParseException"); | ||||
|     } | ||||
|   | ||||
| @@ -32,7 +32,9 @@ public class StringManTest { | ||||
|                 new Message("title", List.of("title")), | ||||
|                 new Message("title \"sub title\"", List.of("title", "sub title")), | ||||
|                 new Message("\"a title\" subtitle", List.of("a title", "subtitle")), | ||||
|                 new Message("\"title\" \"subtitle\"", List.of("title", "subtitle")) | ||||
|                 new Message("\"title\" \"subtitle\"", List.of("title", "subtitle")), | ||||
|                 new Message("\"How <bold>bold</bold> of you\" \"to assume I like <rainbow>rainbows</rainbow>\"", | ||||
|                         List.of("How <bold>bold</bold> of you", "to assume I like <rainbow>rainbows</rainbow>")) | ||||
|         ); | ||||
|  | ||||
|         for (Message message : messages) { | ||||
|   | ||||
| @@ -1,8 +1,7 @@ | ||||
| [versions] | ||||
| # Platform expectations | ||||
| paper = "1.18.1-R0.1-SNAPSHOT" | ||||
| guice = "5.1.0" | ||||
| spotbugs = "4.7.2" | ||||
| spotbugs = "4.7.3" | ||||
|  | ||||
| # Plugins | ||||
| worldedit = "7.2.12" | ||||
| @@ -26,9 +25,6 @@ licenser = "0.6.1" | ||||
| nexus = "1.1.0" | ||||
|  | ||||
| [libraries] | ||||
| # Platform expectations | ||||
| paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" } | ||||
|  | ||||
| # Platform expectations | ||||
| guice = { group = "com.google.inject", name = "guice", version.ref = "guice" } | ||||
| guiceassistedinject = { group = "com.google.inject.extensions", name = "guice-assistedinject", version.ref = "guice" } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user