From 7da921e075cf2f066ac690ede4b2689abf32b2e4 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 22 Dec 2021 20:58:23 +0100 Subject: [PATCH] refactor: Deprecate `IMP` initializors in favor of builders --- .../v1_17_R1_2/PaperweightFaweAdapter.java | 4 +- .../PaperweightFaweWorldNativeAccess.java | 4 +- .../fawe/v1_17_R1_2/PaperweightGetBlocks.java | 10 +- .../PaperweightPlatformAdapter.java | 14 +- .../PaperweightStarlightRelighter.java | 8 +- .../v1_17_R1_2/regen/PaperweightRegen.java | 10 +- .../fawe/v1_18_R1/PaperweightFaweAdapter.java | 4 +- .../PaperweightFaweWorldNativeAccess.java | 4 +- .../fawe/v1_18_R1/PaperweightGetBlocks.java | 10 +- .../v1_18_R1/PaperweightPlatformAdapter.java | 12 +- .../PaperweightStarlightRelighter.java | 8 +- .../fawe/v1_18_R1/regen/PaperweightRegen.java | 10 +- .../fastasyncworldedit/bukkit/FaweBukkit.java | 14 +- .../bukkit/adapter/IBukkitAdapter.java | 2 +- .../bukkit/adapter/NMSAdapter.java | 6 +- .../bukkit/adapter/NMSRelighterFactory.java | 2 +- .../bukkit/adapter/Regenerator.java | 2 +- .../bukkit/listener/ChunkListener.java | 28 +- .../bukkit/listener/ChunkListener9.java | 6 +- .../bukkit/listener/RenderListener.java | 14 +- .../bukkit/regions/ResidenceFeature.java | 2 +- .../FaweDelegateRegionManager.java | 34 +- .../FaweDelegateSchematicHandler.java | 4 +- .../plotsquared/FaweQueueCoordinator.java | 6 +- .../bukkit/regions/plotsquared/FaweTrim.java | 2 +- .../regions/plotsquared/PlotSetBiome.java | 2 +- .../regions/plotsquared/ReplaceAll.java | 6 +- .../bukkit/util/BukkitItemStack.java | 6 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 6 +- .../sk89q/worldedit/bukkit/BukkitWorld.java | 2 +- .../worldedit/bukkit/WorldEditPlugin.java | 2 +- .../bukkit/adapter/BukkitImplAdapter.java | 2 +- .../com/fastasyncworldedit/core/Fawe.java | 67 ++-- .../com/fastasyncworldedit/core/FaweAPI.java | 29 +- .../fastasyncworldedit/core/FaweCache.java | 18 +- .../core/command/AnvilCommands.java | 2 +- .../core/command/CFICommands.java | 16 +- .../core/command/ListFilters.java | 2 +- .../core/command/PlotLoader.java | 4 +- .../command/tool/brush/BrushSettings.java | 2 +- .../core/command/tool/brush/InspectBrush.java | 4 +- .../core/configuration/Settings.java | 342 +++++++++--------- .../core/database/RollbackDatabase.java | 10 +- .../core/entity/LazyBaseEntity.java | 2 +- .../platform/binding/ConsumeBindings.java | 2 +- .../core/extent/FaweRegionExtent.java | 14 +- .../core/extent/MemoryCheckingExtent.java | 2 +- .../core/extent/ProcessedWEExtent.java | 14 +- .../clipboard/DiskOptimizedClipboard.java | 8 +- .../clipboard/MemoryOptimizedClipboard.java | 2 +- .../extent/clipboard/ReadOnlyClipboard.java | 4 +- .../clipboard/io/FastSchematicReader.java | 4 +- .../clipboard/io/FastSchematicWriter.java | 2 +- .../io/schematic/MinecraftStructure.java | 10 +- .../clipboard/io/schematic/PNGWriter.java | 2 +- .../io/schematic/visualizer/SchemVis.java | 4 +- .../extent/filter/block/CharFilterBlock.java | 2 +- .../processor/ExtentBatchProcessorHolder.java | 2 +- .../extent/processor/MultiBatchProcessor.java | 4 +- .../heightmap/HeightmapProcessor.java | 4 +- .../processor/lighting/NMSRelighter.java | 12 +- .../processor/lighting/RelightProcessor.java | 4 +- .../function/pattern/BufferedPattern.java | 2 +- .../core/history/DiskStorageHistory.java | 10 +- .../core/history/MemoryOptimizedHistory.java | 12 +- .../history/changeset/AbstractChangeSet.java | 6 +- .../changeset/FaweStreamChangeSet.java | 4 +- .../core/math/MutableBlockVector3.java | 2 +- .../core/math/MutableVector3.java | 4 +- .../core/queue/IBlocks.java | 4 +- .../core/queue/implementation/Flood.java | 2 +- .../implementation/ParallelQueueExtent.java | 4 +- .../queue/implementation/QueueHandler.java | 8 +- .../SingleThreadQueueExtent.java | 22 +- .../implementation/blocks/BitSetBlocks.java | 2 +- .../implementation/blocks/CharBlocks.java | 2 +- .../implementation/blocks/CharSetBlocks.java | 4 +- .../implementation/blocks/NullChunkGet.java | 2 +- .../implementation/chunk/ChunkHolder.java | 4 +- .../implementation/packet/ChunkPacket.java | 8 +- .../preloader/AsyncPreloader.java | 10 +- .../core/regions/FaweMaskManager.java | 4 +- .../core/util/MainUtil.java | 72 ++-- .../fastasyncworldedit/core/util/MemUtil.java | 2 +- .../core/util/TaskManager.java | 41 ++- .../core/util/TextureUtil.java | 14 +- .../core/util/UpdateNotification.java | 8 +- .../core/util/WEManager.java | 22 +- .../core/util/collection/MemBlockSet.java | 2 +- .../core/util/image/ImageUtil.java | 8 +- .../util/progress/DefaultProgressTracker.java | 8 +- .../core/util/task/AsyncNotifyQueue.java | 2 +- .../util/task/SingleThreadIntervalQueue.java | 8 +- .../core/world/SimpleWorld.java | 2 +- .../core/wrappers/AsyncPlayer.java | 22 +- .../core/wrappers/WorldWrapper.java | 10 +- .../java/com/sk89q/worldedit/EditSession.java | 8 +- .../sk89q/worldedit/EditSessionBuilder.java | 30 +- .../com/sk89q/worldedit/LocalSession.java | 38 +- .../worldedit/command/BrushCommands.java | 14 +- .../worldedit/command/ClipboardCommands.java | 2 +- .../worldedit/command/GeneralCommands.java | 4 +- .../worldedit/command/GenerationCommands.java | 2 +- .../worldedit/command/HistorySubCommands.java | 10 +- .../worldedit/command/SchematicCommands.java | 42 +-- .../worldedit/command/UtilityCommands.java | 14 +- .../worldedit/command/WorldEditCommands.java | 10 +- .../worldedit/command/tool/SelectionWand.java | 4 +- .../worldedit/command/util/EntityRemover.java | 2 +- .../util/annotation/ConfirmHandler.java | 2 +- .../command/util/annotation/Preload.java | 2 +- .../util/annotation/PreloadHandler.java | 2 +- .../com/sk89q/worldedit/entity/Player.java | 10 +- .../platform/AbstractNonPlayerActor.java | 2 +- .../platform/AbstractPlayerActor.java | 6 +- .../worldedit/extension/platform/Actor.java | 4 +- .../platform/PlatformCommandManager.java | 4 +- .../extent/AbstractDelegateExtent.java | 4 +- .../com/sk89q/worldedit/extent/Extent.java | 2 +- .../sk89q/worldedit/extent/MaskingExtent.java | 2 +- .../worldedit/extent/clipboard/Clipboard.java | 4 +- .../extent/clipboard/io/ClipboardFormats.java | 8 +- .../clipboard/io/SpongeSchematicWriter.java | 2 +- .../transform/BlockTransformExtent.java | 2 +- .../extent/world/SurvivalModeExtent.java | 2 +- .../function/visitor/BreadthFirstSearch.java | 4 +- .../function/visitor/RegionVisitor.java | 4 +- .../sk89q/worldedit/regions/CuboidRegion.java | 2 +- .../com/sk89q/worldedit/regions/Region.java | 2 +- 129 files changed, 750 insertions(+), 677 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java index 801da6ad0..ad2ec33ef 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java @@ -510,10 +510,10 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements chunkPacket.setNativePacket(nmsPacket); } try { - FaweCache.IMP.CHUNK_FLAG.get().set(true); + FaweCache.INSTANCE.CHUNK_FLAG.get().set(true); entityPlayer.connection.send(nmsPacket); } finally { - FaweCache.IMP.CHUNK_FLAG.get().set(false); + FaweCache.INSTANCE.CHUNK_FLAG.get().set(false); } } }); diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java index ba56db4a7..68824d9e6 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java @@ -250,7 +250,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess TaskManager.IMP.sync(runnableVal)); + TaskManager.taskManager().async(() -> TaskManager.taskManager().sync(runnableVal)); } @Override @@ -269,7 +269,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess chunkTiles = new HashMap<>(nmsChunk.getBlockEntities()); @@ -726,7 +726,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc nmsChunk.mustNotSave = false; nmsChunk.markUnsaved(); // send to player - if (Settings.IMP.LIGHTING.MODE == 0 || !Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) { + if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { this.send(finalMask, finalLightUpdate); } if (finalizer != null) { @@ -735,7 +735,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc }; } if (syncTasks != null) { - QueueHandler queueHandler = Fawe.get().getQueueHandler(); + QueueHandler queueHandler = Fawe.instance().getQueueHandler(); Runnable[] finalSyncTasks = syncTasks; // Chain the sync tasks and the callback @@ -851,7 +851,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc data = new char[4096]; Arrays.fill(data, (char) 1); } - if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { + if (data == null || data == FaweCache.INSTANCE.EMPTY_CHAR_4096) { data = new char[4096]; Arrays.fill(data, (char) 1); } @@ -884,7 +884,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc return data; } - char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); + char[] paletteToOrdinal = FaweCache.INSTANCE.PALETTE_TO_BLOCK_CHAR.get(); try { if (num_palette != 1) { for (int i = 0; i < num_palette; i++) { diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java index 38d54e0ef..1f7706b57 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java @@ -215,7 +215,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { e.printStackTrace(); } } - return TaskManager.IMP.sync(() -> serverLevel.getChunk(chunkX, chunkZ)); + return TaskManager.taskManager().sync(() -> serverLevel.getChunk(chunkX, chunkZ)); } public static ChunkHolder getPlayerChunk(ServerLevel nmsWorld, final int chunkX, final int chunkZ) { @@ -247,7 +247,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { return; } LevelChunk levelChunk = optional.get(); - TaskManager.IMP.task(() -> { + TaskManager.taskManager().task(() -> { ClientboundLevelChunkPacket chunkPacket = new ClientboundLevelChunkPacket(levelChunk); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(chunkPacket)); if (lighting) { @@ -283,10 +283,10 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { if (set == null) { return newChunkSection(layer); } - final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get(); - final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get(); - final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get(); - final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get(); + final int[] blockToPalette = FaweCache.INSTANCE.BLOCK_TO_PALETTE.get(); + final int[] paletteToBlock = FaweCache.INSTANCE.PALETTE_TO_BLOCK.get(); + final long[] blockStates = FaweCache.INSTANCE.BLOCK_STATES.get(); + final int[] blocksCopy = FaweCache.INSTANCE.SECTION_BLOCKS.get(); try { int[] num_palette_buffer = new int[1]; Map ticking_blocks = new HashMap<>(); @@ -303,7 +303,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { int num_palette = num_palette_buffer[0]; // BlockStates int bitsPerEntry = MathMan.log2nlz(num_palette - 1); - if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { + if (Settings.settings().PROTOCOL_SUPPORT_FIX || num_palette != 1) { bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry } else { bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java index bd8363ece..d51b3a6fc 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java @@ -129,7 +129,7 @@ public class PaperweightStarlightRelighter implements Relighter { while (iterator.hasNext()) { coords.add(new ChunkPos(iterator.nextLong())); } - TaskManager.IMP.task(() -> { + TaskManager.taskManager().task(() -> { // trigger chunk load and apply ticket on main thread List> futures = new ArrayList<>(); for (ChunkPos pos : coords) { @@ -153,9 +153,9 @@ public class PaperweightStarlightRelighter implements Relighter { LOGGER.warn("Processed {} chunks instead of {}", i, coords.size()); } // post process chunks on main thread - TaskManager.IMP.task(() -> postProcessChunks(coords)); + TaskManager.taskManager().task(() -> postProcessChunks(coords)); // call callback on our own threads - TaskManager.IMP.async(andThen); + TaskManager.taskManager().async(andThen); } ) ); @@ -184,7 +184,7 @@ public class PaperweightStarlightRelighter implements Relighter { * Also, if chunk packets are sent delayed, we need to do that here */ private void postProcessChunks(Set coords) { - boolean delay = Settings.IMP.LIGHTING.DELAY_PACKET_SENDING; + boolean delay = Settings.settings().LIGHTING.DELAY_PACKET_SENDING; for (ChunkPos pos : coords) { int x = pos.x; int z = pos.z; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java index 2e16b9f28..6807c7a05 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java @@ -232,7 +232,7 @@ public class PaperweightRegen extends Regenerator) () -> new ServerLevel( + freshWorld = Fawe.instance().getQueueHandler().sync((Supplier) () -> new ServerLevel( server, server.executor, session, @@ -336,7 +336,7 @@ public class PaperweightRegen extends Regenerator { + Fawe.instance().getQueueHandler().sync(() -> { try { freshChunkProvider.close(false); } catch (IOException e) { @@ -348,7 +348,7 @@ public class PaperweightRegen extends Regenerator blockPopulator.populate(freshWorld.getWorld(), random, levelChunk.getBukkitChunk())); + TaskManager.taskManager().task(() -> blockPopulator.populate(freshWorld.getWorld(), random, levelChunk.getBukkitChunk())); } @Override @@ -403,7 +403,7 @@ public class PaperweightRegen extends Regenerator { + Fawe.instance().getQueueHandler().sync(() -> { try { Map map = (Map) serverWorldsField.get(Bukkit.getServer()); map.remove("worldeditregentempworld"); diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweAdapter.java index 76c9f6225..c04b4254a 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweAdapter.java @@ -504,10 +504,10 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements chunkPacket.setNativePacket(nmsPacket); } try { - FaweCache.IMP.CHUNK_FLAG.get().set(true); + FaweCache.INSTANCE.CHUNK_FLAG.get().set(true); entityPlayer.connection.send(nmsPacket); } finally { - FaweCache.IMP.CHUNK_FLAG.get().set(false); + FaweCache.INSTANCE.CHUNK_FLAG.get().set(false); } } }); diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java index e6bb23523..d95e260b6 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java @@ -250,7 +250,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess TaskManager.IMP.sync(runnableVal)); + TaskManager.taskManager().async(() -> TaskManager.taskManager().sync(runnableVal)); } @Override @@ -269,7 +269,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess chunkTiles = new HashMap<>(nmsChunk.getBlockEntities()); @@ -755,7 +755,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc nmsChunk.mustNotSave = false; nmsChunk.setUnsaved(true); // send to player - if (Settings.IMP.LIGHTING.MODE == 0 || !Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) { + if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { this.send(finalMask, finalLightUpdate); } if (finalizer != null) { @@ -764,7 +764,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc }; } if (syncTasks != null) { - QueueHandler queueHandler = Fawe.get().getQueueHandler(); + QueueHandler queueHandler = Fawe.instance().getQueueHandler(); Runnable[] finalSyncTasks = syncTasks; // Chain the sync tasks and the callback @@ -881,7 +881,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc data = new char[4096]; Arrays.fill(data, (char) 1); } - if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { + if (data == null || data == FaweCache.INSTANCE.EMPTY_CHAR_4096) { data = new char[4096]; Arrays.fill(data, (char) 1); } @@ -921,7 +921,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc return data; } - char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); + char[] paletteToOrdinal = FaweCache.INSTANCE.PALETTE_TO_BLOCK_CHAR.get(); try { if (num_palette != 1) { for (int i = 0; i < num_palette; i++) { diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightPlatformAdapter.java index a7bdb4825..47b67b009 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightPlatformAdapter.java @@ -236,7 +236,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { e.printStackTrace(); } } - return TaskManager.IMP.sync(() -> serverLevel.getChunk(chunkX, chunkZ)); + return TaskManager.taskManager().sync(() -> serverLevel.getChunk(chunkX, chunkZ)); } public static ChunkHolder getPlayerChunk(ServerLevel nmsWorld, final int chunkX, final int chunkZ) { @@ -268,7 +268,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { return; } LevelChunk levelChunk = optional.get(); - TaskManager.IMP.task(() -> { + TaskManager.taskManager().task(() -> { ClientboundLevelChunkWithLightPacket packet = new ClientboundLevelChunkWithLightPacket(levelChunk, nmsWorld.getChunkSource().getLightEngine(), null, null , true, false); // last false is to not bother with x-ray @@ -299,10 +299,10 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { if (set == null) { return newChunkSection(layer, biomeRegistry, biomes); } - final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get(); - final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get(); - final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get(); - final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get(); + final int[] blockToPalette = FaweCache.INSTANCE.BLOCK_TO_PALETTE.get(); + final int[] paletteToBlock = FaweCache.INSTANCE.PALETTE_TO_BLOCK.get(); + final long[] blockStates = FaweCache.INSTANCE.BLOCK_STATES.get(); + final int[] blocksCopy = FaweCache.INSTANCE.SECTION_BLOCKS.get(); try { int[] num_palette_buffer = new int[1]; Map ticking_blocks = new HashMap<>(); diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java index 8b7042d63..767674188 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java @@ -130,7 +130,7 @@ public class PaperweightStarlightRelighter implements Relighter { while (iterator.hasNext()) { coords.add(new ChunkPos(iterator.nextLong())); } - TaskManager.IMP.task(() -> { + TaskManager.taskManager().task(() -> { // trigger chunk load and apply ticket on main thread List> futures = new ArrayList<>(); for (ChunkPos pos : coords) { @@ -154,9 +154,9 @@ public class PaperweightStarlightRelighter implements Relighter { LOGGER.warn("Processed {} chunks instead of {}", i, coords.size()); } // post process chunks on main thread - TaskManager.IMP.task(() -> postProcessChunks(coords)); + TaskManager.taskManager().task(() -> postProcessChunks(coords)); // call callback on our own threads - TaskManager.IMP.async(andThen); + TaskManager.taskManager().async(andThen); } ) ); @@ -185,7 +185,7 @@ public class PaperweightStarlightRelighter implements Relighter { * Also, if chunk packets are sent delayed, we need to do that here */ private void postProcessChunks(Set coords) { - boolean delay = Settings.IMP.LIGHTING.DELAY_PACKET_SENDING; + boolean delay = Settings.settings().LIGHTING.DELAY_PACKET_SENDING; for (ChunkPos pos : coords) { int x = pos.x; int z = pos.z; diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java index f916ebb91..85fb06d67 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java @@ -238,7 +238,7 @@ // PrimaryLevelData newWorldData = new PrimaryLevelData(newWorldSettings, newOpts, Lifecycle.stable()); // // //init world -// freshWorld = Fawe.get().getQueueHandler().sync((Supplier) () -> new ServerLevel( +// freshWorld = Fawe.instance().getQueueHandler().sync((Supplier) () -> new ServerLevel( // server, // server.executor, // session, @@ -345,7 +345,7 @@ // // //shutdown chunk provider // try { -// Fawe.get().getQueueHandler().sync(() -> { +// Fawe.instance().getQueueHandler().sync(() -> { // try { // freshChunkProvider.close(false); // } catch (IOException e) { @@ -357,7 +357,7 @@ // // //remove world from server // try { -// Fawe.get().getQueueHandler().sync(this::removeWorldFromWorldsMap); +// Fawe.instance().getQueueHandler().sync(this::removeWorldFromWorldsMap); // } catch (Exception ignored) { // } // @@ -397,7 +397,7 @@ // @Override // protected void populate(LevelChunk levelChunk, Random random, BlockPopulator blockPopulator) { // // BlockPopulator#populate has to be called synchronously for TileEntity access -// TaskManager.IMP.task(() -> blockPopulator.populate(freshWorld.getWorld(), random, levelChunk.getBukkitChunk())); +// TaskManager.taskManager().task(() -> blockPopulator.populate(freshWorld.getWorld(), random, levelChunk.getBukkitChunk())); // } // // @Override @@ -412,7 +412,7 @@ // // //util // private void removeWorldFromWorldsMap() { -// Fawe.get().getQueueHandler().sync(() -> { +// Fawe.instance().getQueueHandler().sync(() -> { // try { // Map map = (Map) serverWorldsField.get(Bukkit.getServer()); // map.remove("worldeditregentempworld"); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java index 3d02b0de7..8aff475d1 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java @@ -68,7 +68,7 @@ public class FaweBukkit implements IFawe, Listener { public FaweBukkit(Plugin plugin) { this.plugin = plugin; try { - Settings.IMP.TICK_LIMITER.ENABLED = !Bukkit.hasWhitelist(); + Settings.settings().TICK_LIMITER.ENABLED = !Bukkit.hasWhitelist(); Fawe.set(this); Fawe.setupInjector(); try { @@ -76,7 +76,7 @@ public class FaweBukkit implements IFawe, Listener { } catch (Throwable e) { LOGGER.error("Brush Listener Failed", e); } - if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { + if (PaperLib.isPaper() && Settings.settings().EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { new RenderListener(plugin); } } catch (final Throwable e) { @@ -89,12 +89,12 @@ public class FaweBukkit implements IFawe, Listener { platformAdapter = new NMSAdapter(); //PlotSquared support is limited to Spigot/Paper as of 02/20/2020 - TaskManager.IMP.later(this::setupPlotSquared, 0); + TaskManager.taskManager().later(this::setupPlotSquared, 0); // Registered delayed Event Listeners - TaskManager.IMP.task(() -> { + TaskManager.taskManager().task(() -> { // Fix for ProtocolSupport - Settings.IMP.PROTOCOL_SUPPORT_FIX = + Settings.settings().PROTOCOL_SUPPORT_FIX = Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport"); // This class @@ -141,7 +141,7 @@ public class FaweBukkit implements IFawe, Listener { try { this.itemUtil = tmp = new ItemUtil(); } catch (Throwable e) { - Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES = false; + Settings.settings().EXPERIMENTAL.PERSISTENT_BRUSHES = false; LOGGER.error("Persistent Brushes Failed", e); } } @@ -311,7 +311,7 @@ public class FaweBukkit implements IFawe, Listener { return; } if (PlotSquared.get().getVersion().version[0] == 6) { - WEManager.IMP.addManager(new com.fastasyncworldedit.bukkit.regions.plotsquared.PlotSquaredFeature()); + WEManager.weManager().addManager(new com.fastasyncworldedit.bukkit.regions.plotsquared.PlotSquaredFeature()); LOGGER.info("Plugin 'PlotSquared' v6 found. Using it now."); } else { LOGGER.error("Incompatible version of PlotSquared found. Please use PlotSquared v6."); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java index aaac5c69f..29162b607 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java @@ -389,7 +389,7 @@ public interface IBukkitAdapter { * @return list of {@link org.bukkit.entity.Entity} */ default List getEntities(org.bukkit.World world) { - return TaskManager.IMP.sync(world::getEntities); + return TaskManager.taskManager().sync(world::getEntities); } } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java index 9f6b97d6a..f7bfd7d33 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java @@ -44,7 +44,7 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl { } char lastOrdinal = 0; boolean lastticking = false; - boolean tick_placed = Settings.IMP.EXPERIMENTAL.ALLOW_TICK_PLACED; + boolean tick_placed = Settings.settings().EXPERIMENTAL.ALLOW_TICK_PLACED; for (int i = 0; i < 4096; i++) { char ordinal = set[i]; switch (ordinal) { @@ -121,8 +121,8 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl { } char lastOrdinal = 0; boolean lastticking = false; - boolean tick_placed = Settings.IMP.EXPERIMENTAL.ALLOW_TICK_PLACED; - boolean tick_existing = Settings.IMP.EXPERIMENTAL.ALLOW_TICK_EXISTING; + boolean tick_placed = Settings.settings().EXPERIMENTAL.ALLOW_TICK_PLACED; + boolean tick_existing = Settings.settings().EXPERIMENTAL.ALLOW_TICK_EXISTING; for (int i = 0; i < 4096; i++) { char ordinal = set[i]; switch (ordinal) { diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSRelighterFactory.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSRelighterFactory.java index 89f16bafd..4fd78df85 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSRelighterFactory.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSRelighterFactory.java @@ -18,7 +18,7 @@ public class NMSRelighterFactory implements RelighterFactory { Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent queue) { return new NMSRelighter( queue, - relightMode != null ? relightMode : RelightMode.valueOf(Settings.IMP.LIGHTING.MODE) + relightMode != null ? relightMode : RelightMode.valueOf(Settings.settings().LIGHTING.MODE) ); } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java index 97e15b9a6..58fd32512 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java @@ -151,7 +151,7 @@ public abstract class Regeneratorimp().getPlugin(); + Plugin plugin = Fawe.platform().getPlugin(); plm.registerEvents(this, plugin); - TaskManager.IMP.repeat(() -> { + TaskManager.taskManager().repeat(() -> { Location tmpLoc = lastCancelPos; if (tmpLoc != null) { LOGGER.info("[FAWE Tick Limiter] Detected and cancelled physics lag source at {}", tmpLoc); @@ -80,7 +80,7 @@ public abstract class ChunkListener implements Listener { counter.put(key, badLimit); } badChunks.clear(); - }, Settings.IMP.TICK_LIMITER.INTERVAL); + }, Settings.settings().TICK_LIMITER.INTERVAL); } } @@ -241,13 +241,13 @@ public abstract class ChunkListener implements Listener { if ((++physSkip & 1023) != 0) { return; } - FaweTimer timer = Fawe.get().getTimer(); + FaweTimer timer = Fawe.instance().getTimer(); if (timer.getTick() != physTick) { physTick = timer.getTick(); physStart = System.currentTimeMillis(); return; } else if (System.currentTimeMillis() - physStart - < Settings.IMP.TICK_LIMITER.PHYSICS_MS) { + < Settings.settings().TICK_LIMITER.PHYSICS_MS) { return; } } @@ -324,15 +324,15 @@ public abstract class ChunkListener implements Listener { int cx = x >> 4; int cz = z >> 4; int[] count = getCount(cx, cz); - if (count[1] >= Settings.IMP.TICK_LIMITER.FALLING) { + if (count[1] >= Settings.settings().TICK_LIMITER.FALLING) { event.setCancelled(true); return; } if (event.getEntityType() == EntityType.FALLING_BLOCK) { - if (++count[1] >= Settings.IMP.TICK_LIMITER.FALLING) { + if (++count[1] >= Settings.settings().TICK_LIMITER.FALLING) { // Only cancel falling blocks when it's lagging - if (Fawe.get().getTimer().getTPS() < 18) { + if (Fawe.instance().getTimer().getTPS() < 18) { cancelNearby(cx, cz); if (rateLimit <= 0) { rateLimit = 20; @@ -351,7 +351,7 @@ public abstract class ChunkListener implements Listener { */ @EventHandler(priority = EventPriority.LOWEST) public void onChunkLoad(ChunkLoadEvent event) { - if (!Settings.IMP.TICK_LIMITER.FIREWORKS_LOAD_CHUNKS) { + if (!Settings.settings().TICK_LIMITER.FIREWORKS_LOAD_CHUNKS) { Chunk chunk = event.getChunk(); Entity[] entities = chunk.getEntities(); World world = chunk.getWorld(); @@ -398,11 +398,11 @@ public abstract class ChunkListener implements Listener { int cx = loc.getBlockX() >> 4; int cz = loc.getBlockZ() >> 4; int[] count = getCount(cx, cz); - if (count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) { + if (count[2] >= Settings.settings().TICK_LIMITER.ITEMS) { event.setCancelled(true); return; } - if (++count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) { + if (++count[2] >= Settings.settings().TICK_LIMITER.ITEMS) { cleanup(loc.getChunk()); cancelNearby(cx, cz); if (rateLimit <= 0) { diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener9.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener9.java index 0726af748..0d93b95d3 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener9.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener9.java @@ -37,13 +37,13 @@ public class ChunkListener9 extends ChunkListener { event.setCancelled(true); return; } - if (System.currentTimeMillis() - physStart > Settings.IMP.TICK_LIMITER.PHYSICS_MS) { + if (System.currentTimeMillis() - physStart > Settings.settings().TICK_LIMITER.PHYSICS_MS) { physCancelPair = pair; event.setCancelled(true); return; } } - FaweTimer timer = Fawe.get().getTimer(); + FaweTimer timer = Fawe.instance().getTimer(); if (timer.getTick() != physTick) { physTick = timer.getTick(); physStart = System.currentTimeMillis(); @@ -52,7 +52,7 @@ public class ChunkListener9 extends ChunkListener { return; } if ((++physSkip & 1023) == 0) { - if (System.currentTimeMillis() - physStart > Settings.IMP.TICK_LIMITER.PHYSICS_MS) { + if (System.currentTimeMillis() - physStart > Settings.settings().TICK_LIMITER.PHYSICS_MS) { Block block = event.getBlock(); int cx = block.getX() >> 4; int cz = block.getZ() >> 4; diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/RenderListener.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/RenderListener.java index c76d85739..22a09deb8 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/RenderListener.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/RenderListener.java @@ -28,7 +28,7 @@ public class RenderListener implements Listener { public RenderListener(Plugin plugin) { Bukkit.getPluginManager().registerEvents(this, plugin); - TaskManager.IMP.repeat(new Runnable() { + TaskManager.taskManager().repeat(new Runnable() { private long last = 0; @Override @@ -38,7 +38,7 @@ public class RenderListener implements Listener { } long now = System.currentTimeMillis(); - int tps32 = (int) (Math.round(Fawe.get().getTimer().getTPS()) * 32); + int tps32 = (int) (Math.round(Fawe.instance().getTimer().getTPS()) * 32); long diff = now - last; last = now; if (diff > 75) { @@ -56,7 +56,7 @@ public class RenderListener implements Listener { if (entrySet == null || !entrySet.hasNext()) { entrySet = views.entrySet().iterator(); } - int nowTick = (int) (Fawe.get().getTimer().getTick()); + int nowTick = (int) (Fawe.instance().getTimer().getTick()); while (entrySet.hasNext()) { Map.Entry entry = entrySet.next(); Player player = Bukkit.getPlayer(entry.getKey()); @@ -81,17 +81,17 @@ public class RenderListener implements Listener { private void setViewDistance(Player player, int value) { UUID uuid = player.getUniqueId(); - if (value == Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING) { + if (value == Settings.settings().EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING) { views.remove(uuid); } else { int[] val = views.get(uuid); if (val == null) { - val = new int[]{value, (int) Fawe.get().getTimer().getTick()}; + val = new int[]{value, (int) Fawe.instance().getTimer().getTick()}; UUID uid = player.getUniqueId(); views.put(uid, val); } else { if (value <= val[0]) { - val[1] = (int) Fawe.get().getTimer().getTick(); + val[1] = (int) Fawe.instance().getTimer().getTick(); } if (val[0] == value) { return; @@ -105,7 +105,7 @@ public class RenderListener implements Listener { private int getViewDistance(Player player) { int[] value = views.get(player.getUniqueId()); - return value == null ? Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING : value[0]; + return value == null ? Settings.settings().EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING : value[0]; } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/ResidenceFeature.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/ResidenceFeature.java index 05243974d..d72769176 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/ResidenceFeature.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/ResidenceFeature.java @@ -33,7 +33,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { return residence != null && (residence.getOwner().equals(player.getName()) || residence.getOwner().equals(player.getUniqueId().toString()) || - type == MaskType.MEMBER && TaskManager.IMP.sync(() -> residence + type == MaskType.MEMBER && TaskManager.taskManager().sync(() -> residence .getPermissions() .playerHas(player, "build", false))); } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java index 7d10ac33a..61f1943b1 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java @@ -53,7 +53,7 @@ public class FaweDelegateRegionManager { int maxY, Runnable whenDone ) { - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { synchronized (FaweDelegateRegionManager.class) { World world = BukkitAdapter.adapt(getWorld(area.getWorldName())); EditSession session = WorldEdit.getInstance().newEditSessionBuilder().world(world).checkMemory(false). @@ -67,14 +67,14 @@ public class FaweDelegateRegionManager { session.flushQueue(); for (CuboidRegion region : regions) { FaweAPI.fixLighting(world, region, null, - RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE) + RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE) ); } } catch (MaxChangedBlocksException e) { e.printStackTrace(); } finally { if (whenDone != null) { - TaskManager.IMP.task(whenDone); + TaskManager.taskManager().task(whenDone); } } } @@ -92,7 +92,7 @@ public class FaweDelegateRegionManager { @Nullable Runnable whenDone, @Nonnull PlotManager manager ) { - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { synchronized (FaweDelegateRegionManager.class) { final HybridPlotWorld hybridPlotWorld = ((HybridPlotManager) manager).getHybridPlotWorld(); World world = BukkitAdapter.adapt(getWorld(hybridPlotWorld.getWorldName())); @@ -176,10 +176,10 @@ public class FaweDelegateRegionManager { world, new CuboidRegion(plot.getBottomAbs().getBlockVector3(), plot.getTopAbs().getBlockVector3()), null, - RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE) + RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE) ); if (whenDone != null) { - TaskManager.IMP.task(whenDone); + TaskManager.taskManager().task(whenDone); } } }); @@ -192,7 +192,7 @@ public class FaweDelegateRegionManager { Location swapPos, final Runnable whenDone ) { - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { synchronized (FaweDelegateRegionManager.class) { //todo because of the following code this should proably be in the Bukkit module World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName())); @@ -231,7 +231,7 @@ public class FaweDelegateRegionManager { e.printStackTrace(); } FaweAPI.fixLighting(pos1World, new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()), null, - RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE) + RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE) ); FaweAPI.fixLighting(pos1World, new CuboidRegion( swapPos.getBlockVector3(), @@ -241,10 +241,10 @@ public class FaweDelegateRegionManager { swapPos.getZ() + pos2.getZ() - pos1.getZ() ) ), null, - RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE) + RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE) ); if (whenDone != null) { - TaskManager.IMP.task(whenDone); + TaskManager.taskManager().task(whenDone); } } }); @@ -253,7 +253,7 @@ public class FaweDelegateRegionManager { public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, String world, Runnable whenDone) { region.expand(BlockVector3.at(extendBiome, 0, extendBiome)); region.expand(BlockVector3.at(-extendBiome, 0, -extendBiome)); - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { synchronized (FaweDelegateRegionManager.class) { EditSession editSession = WorldEdit .getInstance() @@ -273,7 +273,7 @@ public class FaweDelegateRegionManager { e.printStackTrace(); } if (whenDone != null) { - TaskManager.IMP.task(whenDone); + TaskManager.taskManager().task(whenDone); } } }); @@ -285,7 +285,7 @@ public class FaweDelegateRegionManager { final @NonNull Location pos3, final @NonNull Runnable whenDone ) { - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { synchronized (FaweDelegateRegionManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName())); World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorldName())); @@ -319,21 +319,21 @@ public class FaweDelegateRegionManager { pos3.getBlockVector3(), pos3.getBlockVector3().add(pos2.getBlockVector3().subtract(pos1.getBlockVector3())) ), - null, RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE) + null, RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE) ); } catch (MaxChangedBlocksException e) { e.printStackTrace(); } } if (whenDone != null) { - TaskManager.IMP.task(whenDone); + TaskManager.taskManager().task(whenDone); } }); return true; } public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) { - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { synchronized (FaweDelegateRegionManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName())); try (EditSession editSession = WorldEdit.getInstance().newEditSessionBuilder().world(pos1World) @@ -350,7 +350,7 @@ public class FaweDelegateRegionManager { editSession.flushQueue(); } if (whenDone != null) { - TaskManager.IMP.task(whenDone); + TaskManager.taskManager().task(whenDone); } } }); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java index e61cacce2..7ed54786e 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java @@ -132,7 +132,7 @@ public class FaweDelegateSchematicHandler { } }; if (Fawe.isMainThread()) { - com.fastasyncworldedit.core.util.TaskManager.IMP.async(r); + com.fastasyncworldedit.core.util.TaskManager.taskManager().async(r); } else { r.run(); } @@ -186,7 +186,7 @@ public class FaweDelegateSchematicHandler { } return; } - final CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag); + final CompoundTag weTag = (CompoundTag) FaweCache.INSTANCE.asTag(tag); SchematicHandler.upload(uuid, file, "schem", new RunnableVal<>() { @Override public void run(OutputStream output) { diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java index 692a594aa..9c8888a8e 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java @@ -35,8 +35,8 @@ public class FaweQueueCoordinator extends QueueCoordinator { public FaweQueueCoordinator(World world) { super(world); this.world = world; - instance = Fawe.get().getQueueHandler().getQueue(world); - Fawe.get().getQueueHandler().unCache(); + instance = Fawe.instance().getQueueHandler().getQueue(world); + Fawe.instance().getQueueHandler().unCache(); } @Override @@ -194,7 +194,7 @@ public class FaweQueueCoordinator extends QueueCoordinator { @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - instance.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag)); + instance.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.INSTANCE.asTag(tag)); return true; } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweTrim.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweTrim.java index f2621d90b..8bfab4939 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweTrim.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweTrim.java @@ -37,7 +37,7 @@ public class FaweTrim extends SubCommand { return false; } ran = true; - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { try { // TODO NOT IMPLEMENTED //PlotTrim trim = new PlotTrim(plotPlayer, plotPlayer.getPlotAreaAbs(), strings[0], Boolean.parseBoolean(strings[1])); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java index 3977cf808..87db6655a 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java @@ -89,7 +89,7 @@ public class PlotSetBiome extends Command { return; } plot.addRunning(); - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { EditSession session = WorldEdit .getInstance() diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/ReplaceAll.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/ReplaceAll.java index d894596df..ed77b3668 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/ReplaceAll.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/ReplaceAll.java @@ -46,9 +46,9 @@ public class ReplaceAll extends Command { plot.addRunning(); FawePlayer fp = FawePlayer.wrap(player.getName()); Captions.TASK_START.send(player); - TaskManager.IMP.async(() -> fp.runAction(() -> { + TaskManager.taskManager().async(() -> fp.runAction(() -> { String worldName = plot.getWorldName(); - TaskManager.IMP.sync(new RunnableVal() { + TaskManager.taskManager().sync(new RunnableVal() { @Override public void run(Object value) { SetupUtils.manager.unload(worldName, true); @@ -58,7 +58,7 @@ public class ReplaceAll extends Command { String cmd = "/replaceallpattern " + worldName + " " + StringMan.join(args, " "); CommandEvent event = new CommandEvent(actor, cmd); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); - TaskManager.IMP.sync(new RunnableVal() { + TaskManager.taskManager().sync(new RunnableVal() { @Override public void run(Object value) { plot.teleportPlayer(player); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitItemStack.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitItemStack.java index 9ec00af76..1eed3ad33 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitItemStack.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitItemStack.java @@ -34,7 +34,7 @@ public class BukkitItemStack extends BaseItemStack { @Nullable @Override public Object getNativeItem() { - ItemUtil util = Fawe.imp().getItemUtil(); + ItemUtil util = Fawe.platform().getItemUtil(); if (util != null && nativeItem == null) { return nativeItem = util.getNMSItem(stack); } @@ -58,7 +58,7 @@ public class BukkitItemStack extends BaseItemStack { public CompoundTag getNbtData() { if (!loadedNBT) { loadedNBT = true; - ItemUtil util = Fawe.imp().getItemUtil(); + ItemUtil util = Fawe.platform().getItemUtil(); if (util != null) { super.setNbtData(util.getNBT(stack)); } @@ -68,7 +68,7 @@ public class BukkitItemStack extends BaseItemStack { @Override public void setNbtData(@Nullable CompoundTag nbtData) { - ItemUtil util = Fawe.imp().getItemUtil(); + ItemUtil util = Fawe.platform().getItemUtil(); if (util != null) { stack = util.setNBT(stack, nbtData); nativeItem = null; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index ebf394d43..acfd5cacd 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -107,7 +107,7 @@ public class BukkitPlayer extends AbstractPlayerActor { this.player = player; //FAWE start this.permAttachment = plugin.getPermissionAttachmentManager().getOrAddAttachment(player); - if (player != null && Settings.IMP.CLIPBOARD.USE_DISK) { + if (player != null && Settings.settings().CLIPBOARD.USE_DISK) { BukkitPlayer cached = WorldEditPlugin.getInstance().getCachedPlayer(player); if (cached == null) { loadClipboardFromDisk(); @@ -169,7 +169,7 @@ public class BukkitPlayer extends AbstractPlayerActor { player.getInventory().setItemInMainHand(newItem); HashMap overflow = inv.addItem(item); if (!overflow.isEmpty()) { - TaskManager.IMP.sync(new RunnableVal<>() { + TaskManager.taskManager().sync(new RunnableVal<>() { @Override public void run(Object value) { for (Map.Entry entry : overflow.entrySet()) { @@ -243,7 +243,7 @@ public class BukkitPlayer extends AbstractPlayerActor { } org.bukkit.World finalWorld = world; //FAWE end - return TaskManager.IMP.sync(() -> player.teleport(new Location( + return TaskManager.taskManager().sync(() -> player.teleport(new Location( finalWorld, pos.getX(), pos.getY(), diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 3c7da3f12..91ffb6674 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -317,7 +317,7 @@ public class BukkitWorld extends AbstractWorld { @Override public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) { //FAWE start - allow tree commands to be undone and obey region restrictions - return TaskManager.IMP.sync(() -> WorldEditPlugin.getInstance().getBukkitImplAdapter().generateTree(type, editSession, pt, + return TaskManager.taskManager().sync(() -> WorldEditPlugin.getInstance().getBukkitImplAdapter().generateTree(type, editSession, pt, getWorld() )); //FAWE end diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 8ea0a918d..3fe92e41d 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -380,7 +380,7 @@ public class WorldEditPlugin extends JavaPlugin { */ @Override public void onDisable() { - Fawe.get().onDisable(); + Fawe.instance().onDisable(); WorldEdit worldEdit = WorldEdit.getInstance(); worldEdit.getSessionManager().unload(); if (platform != null) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java index 799e52bb9..38fdbff91 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java @@ -314,7 +314,7 @@ public interface BukkitImplAdapter extends IBukkitAdapter { @Nullable default World createWorld(WorldCreator creator) { - return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld); + return ((FaweBukkit) Fawe.platform()).createWorldUnloaded(creator::createWorld); } /** diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java index 4cea8e2cb..3640b7a88 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java @@ -101,17 +101,17 @@ public class Fawe { this.setupConfigs(); TaskManager.IMP = this.implementation.getTaskManager(); - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { MainUtil.deleteOlder( MainUtil.getFile(this.implementation - .getDirectory(), Settings.IMP.PATHS.HISTORY), - TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS), + .getDirectory(), Settings.settings().PATHS.HISTORY), + TimeUnit.DAYS.toMillis(Settings.settings().HISTORY.DELETE_AFTER_DAYS), false ); MainUtil.deleteOlder( MainUtil.getFile(this.implementation - .getDirectory(), Settings.IMP.PATHS.CLIPBOARD), - TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS), + .getDirectory(), Settings.settings().PATHS.CLIPBOARD), + TimeUnit.DAYS.toMillis(Settings.settings().CLIPBOARD.DELETE_AFTER_DAYS), false ); }); @@ -123,28 +123,49 @@ public class Fawe { this.timer = new FaweTimer(); // Delayed worldedit setup - TaskManager.IMP.later(() -> { + TaskManager.taskManager().later(() -> { try { - WEManager.IMP.addManagers(Fawe.this.implementation.getMaskManagers()); + WEManager.weManager().addManagers(Fawe.this.implementation.getMaskManagers()); } catch (Throwable ignored) { } }, 0); - TaskManager.IMP.repeat(timer, 1); + TaskManager.taskManager().repeat(timer, 1); } /** * Get the implementation specific class. + * @deprecated use {@link #platform()} */ @SuppressWarnings("unchecked") + @Deprecated(forRemoval = true, since = "2.0.0") public static T imp() { return instance != null ? (T) instance.implementation : null; } + /** + * Get the implementation specific class. + * @since 2.0.0 + */ + @SuppressWarnings("unchecked") + public static T platform() { + return instance != null ? (T) instance.implementation : null; + } + + + /** + * Get the implementation independent class. + * @ use {@link #instance()} + */ + @Deprecated(forRemoval = true, since = "2.0.0") + public static Fawe get() { + return instance; + } + /** * Get the implementation independent class. */ - public static Fawe get() { + public static Fawe instance() { return instance; } @@ -225,8 +246,8 @@ public class Fawe { } public void onDisable() { - if (imp().getPreloader(false) != null) { - imp().getPreloader(false).cancel(); + if (platform().getPreloader(false) != null) { + platform().getPreloader(false).cancel(); } } @@ -296,7 +317,7 @@ public class Fawe { MainUtil.copyFile(MainUtil.getJarFile(), "lang/strings.json", null); // Setting up config.yml File file = new File(this.implementation.getDirectory(), "config.yml"); - Settings.IMP.PLATFORM = implementation.getPlatform().replace("\"", ""); + Settings.settings().PLATFORM = implementation.getPlatform().replace("\"", ""); try (InputStream stream = getClass().getResourceAsStream("/fawe.properties"); BufferedReader br = new BufferedReader(new InputStreamReader(stream))) { String versionString = br.readLine(); @@ -304,17 +325,17 @@ public class Fawe { String dateString = br.readLine(); br.close(); this.version = FaweVersion.tryParse(versionString, commitString, dateString); - Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toString(); - Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build; - Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit/commit/" + Integer.toHexString(version.hash); + Settings.settings().DATE = new Date(100 + version.year, version.month, version.day).toString(); + Settings.settings().BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build; + Settings.settings().COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit/commit/" + Integer.toHexString(version.hash); } catch (Throwable ignored) { } try { - Settings.IMP.reload(file); + Settings.settings().reload(file); } catch (Throwable e) { LOGGER.error("Failed to load config.", e); } - Settings.IMP.QUEUE.TARGET_SIZE = Math.max(Settings.IMP.QUEUE.TARGET_SIZE, Settings.IMP.QUEUE.PARALLEL_THREADS); + Settings.settings().QUEUE.TARGET_SIZE = Math.max(Settings.settings().QUEUE.TARGET_SIZE, Settings.settings().QUEUE.PARALLEL_THREADS); try { byte[] in = new byte[0]; byte[] compressed = LZ4Factory.fastestJavaInstance().fastCompressor().compress(in); @@ -332,14 +353,14 @@ public class Fawe { assert (Zstd.decompress(ob, compressed) == 0); LOGGER.info("ZSTD Compression Binding loaded successfully"); } catch (Throwable e) { - if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) { - Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL); - Settings.IMP.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL); + if (Settings.settings().CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.settings().HISTORY.COMPRESSION_LEVEL > 6) { + Settings.settings().CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.settings().CLIPBOARD.COMPRESSION_LEVEL); + Settings.settings().HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.settings().HISTORY.COMPRESSION_LEVEL); LOGGER.error("ZSTD Compression Binding Not Found.\n" + "FAWE will still work but compression won't work as well.", e); } } - Settings.IMP.save(file); + Settings.settings().save(file); } public WorldEdit getWorldEdit() { @@ -347,7 +368,7 @@ public class Fawe { } private void setupMemoryListener() { - if (Settings.IMP.MAX_MEMORY_PERCENT < 1 || Settings.IMP.MAX_MEMORY_PERCENT > 99) { + if (Settings.settings().MAX_MEMORY_PERCENT < 1 || Settings.settings().MAX_MEMORY_PERCENT > 99) { return; } try { @@ -371,7 +392,7 @@ public class Fawe { if (max < 0) { continue; } - final long alert = (max * Settings.IMP.MAX_MEMORY_PERCENT) / 100; + final long alert = (max * Settings.settings().MAX_MEMORY_PERCENT) / 100; mp.setUsageThreshold(alert); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java index c34052554..fcaf33288 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java @@ -65,7 +65,7 @@ public class FaweAPI { * @return TaskManager */ public static TaskManager getTaskManager() { - return TaskManager.IMP; + return TaskManager.taskManager(); } /** @@ -81,7 +81,7 @@ public class FaweAPI { * @return the queue extent */ public static IQueueExtent createQueue(World world, boolean autoQueue) { - IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world); + IQueueExtent queue = Fawe.instance().getQueueHandler().getQueue(world); if (!autoQueue) { queue.disableQueue(); } @@ -127,7 +127,7 @@ public class FaweAPI { * @return Set of FaweMaskManager */ public static Set getMaskManagers() { - return new HashSet<>(WEManager.IMP.getManagers()); + return new HashSet<>(WEManager.weManager().getManagers()); } /** @@ -143,7 +143,7 @@ public class FaweAPI { * Get a player's allowed WorldEdit region(s). */ public static Region[] getRegions(Player player) { - return WEManager.IMP.getMask(player); + return WEManager.weManager().getMask(player); } /** @@ -155,7 +155,7 @@ public class FaweAPI { * @return array of allowed regions if whitelist, else of disallowed regions. */ public static Region[] getRegions(Player player, FaweMaskManager.MaskType type, boolean isWhiteList) { - return WEManager.IMP.getMask(player, type, isWhiteList); + return WEManager.weManager().getMask(player, type, isWhiteList); } /** @@ -170,13 +170,13 @@ public class FaweAPI { */ public static void cancelEdit(AbstractDelegateExtent extent, Component reason) { try { - WEManager.IMP.cancelEdit(extent, new FaweException(reason)); + WEManager.weManager().cancelEdit(extent, new FaweException(reason)); } catch (WorldEditException ignored) { } } public static void addMaskManager(FaweMaskManager maskMan) { - WEManager.IMP.addManager(maskMan); + WEManager.weManager().addManager(maskMan); } /** @@ -186,7 +186,7 @@ public class FaweAPI { if (!file.exists() || file.isDirectory()) { throw new IllegalArgumentException("Not a file!"); } - if (Settings.IMP.HISTORY.USE_DISK) { + if (Settings.settings().HISTORY.USE_DISK) { throw new IllegalArgumentException("History on disk not enabled!"); } if (!file.getName().toLowerCase(Locale.ROOT).endsWith(".bd")) { @@ -224,11 +224,10 @@ public class FaweAPI { */ public static List getBDFiles(Location origin, UUID user, int radius, long timediff, boolean shallow) { Extent extent = origin.getExtent(); - if (!(extent instanceof World)) { + if (!(extent instanceof World world)) { throw new IllegalArgumentException("Origin is not a valid world"); } - World world = (World) extent; - File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName()); + File history = MainUtil.getFile(Fawe.platform().getDirectory(), Settings.settings().PATHS.HISTORY + File.separator + world.getName()); if (!history.exists()) { return new ArrayList<>(); } @@ -352,12 +351,12 @@ public class FaweAPI { World unwrapped = WorldWrapper.unwrap(world); if (unwrapped instanceof IQueueExtent) { queue = (IQueueExtent) unwrapped; - } else if (Settings.IMP.QUEUE.PARALLEL_THREADS > 1) { + } else if (Settings.settings().QUEUE.PARALLEL_THREADS > 1) { ParallelQueueExtent parallel = - new ParallelQueueExtent(Fawe.get().getQueueHandler(), world, true); + new ParallelQueueExtent(Fawe.instance().getQueueHandler(), world, true); queue = parallel.getExtent(); } else { - queue = Fawe.get().getQueueHandler().getQueue(world); + queue = Fawe.instance().getQueueHandler().getQueue(world); } } @@ -372,7 +371,7 @@ public class FaweAPI { } } if (mode != RelightMode.NONE) { - if (Settings.IMP.LIGHTING.REMOVE_FIRST) { + if (Settings.settings().LIGHTING.REMOVE_FIRST) { relighter.removeAndRelight(true); } else { relighter.fixSkyLighting(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java index 317d2df83..e0f840a3f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java @@ -59,7 +59,15 @@ import java.util.function.Supplier; import static com.google.common.base.Preconditions.checkNotNull; public enum FaweCache implements Trimable { - IMP; // singleton + /** + * @deprecated Use {@link #INSTANCE} to get an instance. + */ + @Deprecated(forRemoval = true, since = "2.0.0") + IMP, + /** + * @since 2.0.0 + */ + INSTANCE;// singleton private static final Logger LOGGER = LogManagerCompat.getLogger(); @@ -301,7 +309,7 @@ public enum FaweCache implements Trimable { // BlockStates int bitsPerEntry = MathMan.log2nlz(num_palette - 1); - if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { + if (Settings.settings().PROTOCOL_SUPPORT_FIX || num_palette != 1) { bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry } else { bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries @@ -387,7 +395,7 @@ public enum FaweCache implements Trimable { // BlockStates int bitsPerEntry = MathMan.log2nlz(num_palette - 1); - if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { + if (Settings.settings().PROTOCOL_SUPPORT_FIX || num_palette != 1) { bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry } else { bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries @@ -568,7 +576,7 @@ public enum FaweCache implements Trimable { Thread stuff */ public ThreadPoolExecutor newBlockingExecutor() { - int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS; + int nThreads = Settings.settings().QUEUE.PARALLEL_THREADS; ArrayBlockingQueue queue = new ArrayBlockingQueue<>(nThreads, true); return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, queue, @@ -609,7 +617,7 @@ public enum FaweCache implements Trimable { lastException = hash; LOGGER.catching(throwable); count = 0; - } else if (count < Settings.IMP.QUEUE.PARALLEL_THREADS) { + } else if (count < Settings.settings().QUEUE.PARALLEL_THREADS) { LOGGER.warn(throwable.getMessage()); count++; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/AnvilCommands.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/AnvilCommands.java index 71438bfd0..5c5ad228c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/AnvilCommands.java @@ -531,7 +531,7 @@ public class AnvilCommands { // }); // if (useData) { // for (long[] c : map) { - // BaseBlock block = FaweCache.IMP.CACHE_BLOCK[(int) c[0]]; + // BaseBlock block = FaweCache.INSTANCE.CACHE_BLOCK[(int) c[0]]; // String name = BlockType.fromID(block.getId()).getName(); // String str = String.format("%-7s (%.3f%%) %s #%d:%d", // String.valueOf(c[1]), diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/CFICommands.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/CFICommands.java index 932fc1495..d7c4afb82 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/CFICommands.java @@ -147,7 +147,7 @@ // CFISettings settings = getSettings(player).remove(); // generator.setPacketViewer(player); // settings.setGenerator(generator).bind(); -// generator.setImageViewer(Fawe.imp().getImageViewer(player)); +// generator.setImageViewer(Fawe.platform().getImageViewer(player)); // generator.update(); // mainMenu(player); // } @@ -226,7 +226,7 @@ // World world = FaweAPI.getWorld(folder.getName()); // if (world != null) { // if (player.getWorld() != world) { -// TaskManager.IMP.sync(new RunnableVal() { +// TaskManager.taskManager().sync(new RunnableVal() { // @Override // public void run(Object value) { // Location spawn = new Location(world, world.getSpawnPosition().toVector3()); @@ -425,7 +425,7 @@ // switch (argOpt.toLowerCase(Locale.ROOT)) { // case "true": // case "*": { -// generator.setTextureUtil(Fawe.get().getTextureUtil()); +// generator.setTextureUtil(Fawe.instance().getTextureUtil()); // return; // } // case "#clipboard": { @@ -453,7 +453,7 @@ // parserContext.setExtent(extent); // Request.request().setExtent(extent); // Mask mask = worldEdit.getMaskFactory().parseFromInput(argOpt, parserContext); -// TextureUtil tu = Fawe.get().getTextureUtil(); +// TextureUtil tu = Fawe.instance().getTextureUtil(); // for (int typeId : tu.getValidBlockIds()) { // BlockType type = BlockTypes.get(typeId); // extent.init(0, 0, 0, type.getDefaultState().toBaseBlock()); @@ -464,7 +464,7 @@ // break; // } // } -// generator.setTextureUtil(new FilteredTextureUtil(Fawe.get().getTextureUtil(), blocks)); +// generator.setTextureUtil(new FilteredTextureUtil(Fawe.instance().getTextureUtil(), blocks)); // coloring(player); // } // @@ -493,9 +493,9 @@ // public void complexity(Player player, int min, int max) throws FileNotFoundException { // HeightMapMCAGenerator gen = assertSettings(player).getGenerator(); // if (min == 0 && max == 100) { -// gen.setTextureUtil(Fawe.get().getTextureUtil()); +// gen.setTextureUtil(Fawe.instance().getTextureUtil()); // } else { -// gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max)); +// gen.setTextureUtil(new CleanTextureUtil(Fawe.instance().getTextureUtil(), min, max)); // } // coloring(player); // } @@ -1201,7 +1201,7 @@ // whiteOnly = true; // maskArg = null; // imageMaskArg = null; -// generator.setTextureUtil(Fawe.get().getTextureUtil()); +// generator.setTextureUtil(Fawe.instance().getTextureUtil()); // } // // public void resetComponent() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/ListFilters.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/ListFilters.java index ebb75b247..aa9556937 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/ListFilters.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/ListFilters.java @@ -95,7 +95,7 @@ public class ListFilters { } String firstArg = finalArg.substring(0, finalArg.length() - File.separator.length()); if (firstArg.length() > 3 && firstArg.length() <= 16) { - UUID fromName = Fawe.imp().getUUID(finalArg); + UUID fromName = Fawe.platform().getUUID(finalArg); if (fromName != null) { newRoot = new File(root, finalArg); if (newRoot.exists()) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/PlotLoader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/PlotLoader.java index fe4242243..fba983d93 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/PlotLoader.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/PlotLoader.java @@ -45,7 +45,7 @@ // PlotPlayer player = PlotPlayer.get(actor.getName()); // // actor.print("Claiming world"); -// Plot plot = TaskManager.IMP.sync(new RunnableVal() { +// Plot plot = TaskManager.taskManager().sync(new RunnableVal() { // @Override // public void run(Plot o) { // int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() @@ -73,7 +73,7 @@ // File folder = CFICommands.getFolder(plot.getWorldName()); // Boolean result = createTask.apply(folder); // if (result == Boolean.TRUE) { -// TaskManager.IMP.sync(() -> plot.teleportPlayer(player)); +// TaskManager.taskManager().sync(() -> plot.teleportPlayer(player)); // } // return; // } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BrushSettings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BrushSettings.java index 2a18f856a..0a4d611bb 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BrushSettings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BrushSettings.java @@ -90,7 +90,7 @@ public class BrushSettings { // } // if (settings.containsKey(SettingType.TRANSFORM.name())) { // String transformArgs = (String) settings.get(SettingType.TRANSFORM.name()); - // ResettableExtent extent = Fawe.get().getTransformParser().parseFromInput(transformArgs, parserContext); + // ResettableExtent extent = Fawe.instance().getTransformParser().parseFromInput(transformArgs, parserContext); // bs.setTransform(extent); // bs.constructor.put(SettingType.TRANSFORM, transformArgs); // } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java index d9f11976a..82d99c416 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java @@ -68,7 +68,7 @@ public class InspectBrush extends BrushTool { player.print(Caption.of("fawe.error.no-perm", "worldedit.tool.inspect")); return false; } - if (!Settings.IMP.HISTORY.USE_DATABASE) { + if (!Settings.settings().HISTORY.USE_DATABASE) { player.print(Caption.of( "fawe.error.setting.disable", "history.use-database (Import with /history import )" @@ -95,7 +95,7 @@ public class InspectBrush extends BrushTool { int from = change.from; int to = change.to; UUID uuid = edit.getUUID(); - String name = Fawe.imp().getName(uuid); + String name = Fawe.platform().getName(uuid); int index = edit.getIndex(); long age = System.currentTimeMillis() - edit.getBDFile().lastModified(); String ageFormatted = MainUtil.secToTime(age / 1000); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index f6cc83158..8f899afd5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -19,12 +19,16 @@ import java.util.stream.Stream; public class Settings extends Config { + /** + * @deprecated Use {@link #settings()} instead to get an instance. + */ @Ignore + @Deprecated(forRemoval = true, since = "2.0.0") public static final Settings IMP = new Settings(); - + @Ignore + static Settings INSTANCE = new Settings(); @Ignore public boolean PROTOCOL_SUPPORT_FIX = false; - @Comment("These first 6 aren't configurable") // This is a comment @Final // Indicates that this value isn't configurable public String ISSUES = "https://github.com/IntellectualSites/FastAsyncWorldEdit/issues"; @@ -38,7 +42,6 @@ public class Settings extends Config { public String COMMIT; // These values are set from FAWE before loading @Final public String PLATFORM; // These values are set from FAWE before loading - @Comment({ "Set true to enable WorldEdit restrictions per region (e.g. PlotSquared or WorldGuard).", "To be allowed to WorldEdit in a region, users need the appropriate", @@ -51,7 +54,6 @@ public class Settings extends Config { " - Disable with 100 or -1." }) public int MAX_MEMORY_PERCENT = 95; - @Create public ENABLED_COMPONENTS ENABLED_COMPONENTS; @Create @@ -77,16 +79,178 @@ public class Settings extends Config { @Create public ConfigBlock LIMITS; + private Settings() { + INSTANCE = this; + } + + /** + * Gets an instance of Settings. + * + * @return an instance of Settings + * @since 2.0.0 + */ + public static Settings settings() { + return INSTANCE; + } + + public void reload(File file) { + load(file); + save(file); + } + + public FaweLimit getLimit(Actor actor) { + FaweLimit limit; + if (actor.hasPermission("fawe.limit.*") || actor.hasPermission("fawe.bypass")) { + limit = FaweLimit.MAX.copy(); + } else { + limit = new FaweLimit(); + } + ArrayList keys = new ArrayList<>(LIMITS.getSections()); + if (keys.remove("default")) { + keys.add("default"); + } + + boolean limitFound = false; + for (String key : keys) { + if (actor.hasPermission("fawe.limit." + key) || !limitFound && key.equals("default")) { + limitFound = true; + LIMITS newLimit = LIMITS.get(key); + limit.MAX_ACTIONS = Math.max( + limit.MAX_ACTIONS, + newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE + ); + limit.MAX_CHANGES = Math.max( + limit.MAX_CHANGES, + newLimit.MAX_CHANGES != -1 ? newLimit.MAX_CHANGES : Long.MAX_VALUE + ); + limit.MAX_BLOCKSTATES = Math.max( + limit.MAX_BLOCKSTATES, + newLimit.MAX_BLOCKSTATES != -1 ? newLimit.MAX_BLOCKSTATES : Integer.MAX_VALUE + ); + limit.MAX_CHECKS = Math.max( + limit.MAX_CHECKS, + newLimit.MAX_CHECKS != -1 ? newLimit.MAX_CHECKS : Long.MAX_VALUE + ); + limit.MAX_ENTITIES = Math.max( + limit.MAX_ENTITIES, + newLimit.MAX_ENTITIES != -1 ? newLimit.MAX_ENTITIES : Integer.MAX_VALUE + ); + limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE); + limit.MAX_ITERATIONS = Math.max( + limit.MAX_ITERATIONS, + newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE + ); + limit.MAX_HISTORY = Math.max( + limit.MAX_HISTORY, + newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE + ); + limit.MAX_EXPRESSION_MS = Math.max( + limit.MAX_EXPRESSION_MS, + newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE + ); + limit.INVENTORY_MODE = Math.min(limit.INVENTORY_MODE, newLimit.INVENTORY_MODE); + limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION); + limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT; + limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE; + limit.RESTRICT_HISTORY_TO_REGIONS &= newLimit.RESTRICT_HISTORY_TO_REGIONS; + if (limit.STRIP_NBT == null) { + limit.STRIP_NBT = newLimit.STRIP_NBT.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.STRIP_NBT); + } else if (limit.STRIP_NBT.isEmpty() || newLimit.STRIP_NBT.isEmpty()) { + limit.STRIP_NBT = Collections.emptySet(); + } else { + limit.STRIP_NBT = new HashSet<>(limit.STRIP_NBT); + limit.STRIP_NBT.retainAll(newLimit.STRIP_NBT); + if (limit.STRIP_NBT.isEmpty()) { + limit.STRIP_NBT = Collections.emptySet(); + } + } + limit.UNIVERSAL_DISALLOWED_BLOCKS &= newLimit.UNIVERSAL_DISALLOWED_BLOCKS; + + if (limit.DISALLOWED_BLOCKS == null) { + limit.DISALLOWED_BLOCKS = newLimit.DISALLOWED_BLOCKS.isEmpty() ? Collections.emptySet() : new HashSet<>( + newLimit.DISALLOWED_BLOCKS); + } else if (limit.DISALLOWED_BLOCKS.isEmpty() || newLimit.DISALLOWED_BLOCKS.isEmpty()) { + limit.DISALLOWED_BLOCKS = Collections.emptySet(); + } else { + limit.DISALLOWED_BLOCKS = new HashSet<>(limit.DISALLOWED_BLOCKS); + limit.DISALLOWED_BLOCKS.retainAll(newLimit.DISALLOWED_BLOCKS + .stream() + .map(s -> s.contains(":") ? s.toLowerCase(Locale.ROOT) : ("minecraft:" + s).toLowerCase(Locale.ROOT)) + .collect(Collectors.toSet())); + if (limit.DISALLOWED_BLOCKS.isEmpty()) { + limit.DISALLOWED_BLOCKS = Collections.emptySet(); + } + } + + if (limit.REMAP_PROPERTIES == null) { + limit.REMAP_PROPERTIES = newLimit.REMAP_PROPERTIES.isEmpty() ? Collections.emptySet() : + newLimit.REMAP_PROPERTIES.stream().flatMap(s -> { + String propertyStr = s.substring(0, s.indexOf('[')); + List> properties = + BlockTypesCache.getAllProperties().get(propertyStr.toLowerCase(Locale.ROOT)); + if (properties == null || properties.isEmpty()) { + return Stream.empty(); + } + String[] mappings = s.substring(s.indexOf('[') + 1, s.indexOf(']')).split(","); + Set> remaps = new HashSet<>(); + for (Property property : properties) { + for (String mapping : mappings) { + try { + String[] fromTo = mapping.split(":"); + remaps.add(property.getRemap( + property.getValueFor(fromTo[0]), + property.getValueFor(fromTo[1]) + )); + } catch (IllegalArgumentException ignored) { + // This property is unlikely to be the one being targeted. + break; + } + } + } + return remaps.stream(); + }).collect(Collectors.toSet()); + } else if (limit.REMAP_PROPERTIES.isEmpty() || newLimit.REMAP_PROPERTIES.isEmpty()) { + limit.REMAP_PROPERTIES = Collections.emptySet(); + } else { + limit.REMAP_PROPERTIES = new HashSet<>(limit.REMAP_PROPERTIES); + limit.REMAP_PROPERTIES.retainAll(newLimit.REMAP_PROPERTIES.stream().flatMap(s -> { + String propertyStr = s.substring(0, s.indexOf('[')); + List> properties = + BlockTypesCache.getAllProperties().get(propertyStr.toLowerCase(Locale.ROOT)); + if (properties == null || properties.isEmpty()) { + return Stream.empty(); + } + String[] mappings = s.substring(s.indexOf('[') + 1, s.indexOf(']')).split(","); + Set> remaps = new HashSet<>(); + for (Property property : properties) { + for (String mapping : mappings) { + try { + String[] fromTo = mapping.split(":"); + remaps.add(property.getRemap( + property.getValueFor(fromTo[0]), + property.getValueFor(fromTo[1]) + )); + } catch (IllegalArgumentException ignored) { + // This property is unlikely to be the one being targeted. + break; + } + } + } + return remaps.stream(); + }).collect(Collectors.toSet())); + if (limit.REMAP_PROPERTIES.isEmpty()) { + limit.REMAP_PROPERTIES = Collections.emptySet(); + } + } + } + } + return limit; + } + @Comment("Enable or disable core components") public static final class ENABLED_COMPONENTS { public boolean COMMANDS = true; - @Comment({ - "Disable the FAWE-PlotSquared hook to take over most intense P2 queueing", - "Specific aspects can be turned on and off further below", - "Only disables/enables the hook with v4. For v6, see PlotSquared settings.yml" - }) - public boolean PLOTSQUARED_V4_HOOK = true; @Comment({"Show additional information in console. It helps us at IntellectualSites to find out more about an issue.", "Leave it off if you don't need it, it can spam your console."}) public boolean DEBUG = false; @@ -341,12 +505,12 @@ public class Settings extends Config { @Comment("This relates to how FAWE places chunks") public static class QUEUE { + @Create + public static PROGRESS PROGRESS; @Comment({ "This should equal the number of processors you have", }) public int PARALLEL_THREADS = Math.max(1, Runtime.getRuntime().availableProcessors()); - @Create - public static PROGRESS PROGRESS; @Comment({ "When doing edits that effect more than this many chunks:", " - FAWE will start placing before all calculations are finished", @@ -575,158 +739,4 @@ public class Settings extends Config { } - public void reload(File file) { - load(file); - save(file); - } - - public FaweLimit getLimit(Actor actor) { - FaweLimit limit; - if (actor.hasPermission("fawe.limit.*") || actor.hasPermission("fawe.bypass")) { - limit = FaweLimit.MAX.copy(); - } else { - limit = new FaweLimit(); - } - ArrayList keys = new ArrayList<>(LIMITS.getSections()); - if (keys.remove("default")) { - keys.add("default"); - } - - boolean limitFound = false; - for (String key : keys) { - if (actor.hasPermission("fawe.limit." + key) || !limitFound && key.equals("default")) { - limitFound = true; - LIMITS newLimit = LIMITS.get(key); - limit.MAX_ACTIONS = Math.max( - limit.MAX_ACTIONS, - newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE - ); - limit.MAX_CHANGES = Math.max( - limit.MAX_CHANGES, - newLimit.MAX_CHANGES != -1 ? newLimit.MAX_CHANGES : Long.MAX_VALUE - ); - limit.MAX_BLOCKSTATES = Math.max( - limit.MAX_BLOCKSTATES, - newLimit.MAX_BLOCKSTATES != -1 ? newLimit.MAX_BLOCKSTATES : Integer.MAX_VALUE - ); - limit.MAX_CHECKS = Math.max( - limit.MAX_CHECKS, - newLimit.MAX_CHECKS != -1 ? newLimit.MAX_CHECKS : Long.MAX_VALUE - ); - limit.MAX_ENTITIES = Math.max( - limit.MAX_ENTITIES, - newLimit.MAX_ENTITIES != -1 ? newLimit.MAX_ENTITIES : Integer.MAX_VALUE - ); - limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE); - limit.MAX_ITERATIONS = Math.max( - limit.MAX_ITERATIONS, - newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE - ); - limit.MAX_HISTORY = Math.max( - limit.MAX_HISTORY, - newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE - ); - limit.MAX_EXPRESSION_MS = Math.max( - limit.MAX_EXPRESSION_MS, - newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE - ); - limit.INVENTORY_MODE = Math.min(limit.INVENTORY_MODE, newLimit.INVENTORY_MODE); - limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION); - limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT; - limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE; - limit.RESTRICT_HISTORY_TO_REGIONS &= newLimit.RESTRICT_HISTORY_TO_REGIONS; - if (limit.STRIP_NBT == null) { - limit.STRIP_NBT = newLimit.STRIP_NBT.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.STRIP_NBT); - } else if (limit.STRIP_NBT.isEmpty() || newLimit.STRIP_NBT.isEmpty()) { - limit.STRIP_NBT = Collections.emptySet(); - } else { - limit.STRIP_NBT = new HashSet<>(limit.STRIP_NBT); - limit.STRIP_NBT.retainAll(newLimit.STRIP_NBT); - if (limit.STRIP_NBT.isEmpty()) { - limit.STRIP_NBT = Collections.emptySet(); - } - } - limit.UNIVERSAL_DISALLOWED_BLOCKS &= newLimit.UNIVERSAL_DISALLOWED_BLOCKS; - - if (limit.DISALLOWED_BLOCKS == null) { - limit.DISALLOWED_BLOCKS = newLimit.DISALLOWED_BLOCKS.isEmpty() ? Collections.emptySet() : new HashSet<>( - newLimit.DISALLOWED_BLOCKS); - } else if (limit.DISALLOWED_BLOCKS.isEmpty() || newLimit.DISALLOWED_BLOCKS.isEmpty()) { - limit.DISALLOWED_BLOCKS = Collections.emptySet(); - } else { - limit.DISALLOWED_BLOCKS = new HashSet<>(limit.DISALLOWED_BLOCKS); - limit.DISALLOWED_BLOCKS.retainAll(newLimit.DISALLOWED_BLOCKS - .stream() - .map(s -> s.contains(":") ? s.toLowerCase(Locale.ROOT) : ("minecraft:" + s).toLowerCase(Locale.ROOT)) - .collect(Collectors.toSet())); - if (limit.DISALLOWED_BLOCKS.isEmpty()) { - limit.DISALLOWED_BLOCKS = Collections.emptySet(); - } - } - - if (limit.REMAP_PROPERTIES == null) { - limit.REMAP_PROPERTIES = newLimit.REMAP_PROPERTIES.isEmpty() ? Collections.emptySet() : - newLimit.REMAP_PROPERTIES.stream().flatMap(s -> { - String propertyStr = s.substring(0, s.indexOf('[')); - List> properties = - BlockTypesCache.getAllProperties().get(propertyStr.toLowerCase(Locale.ROOT)); - if (properties == null || properties.isEmpty()) { - return Stream.empty(); - } - String[] mappings = s.substring(s.indexOf('[') + 1, s.indexOf(']')).split(","); - Set> remaps = new HashSet<>(); - for (Property property : properties) { - for (String mapping : mappings) { - try { - String[] fromTo = mapping.split(":"); - remaps.add(property.getRemap( - property.getValueFor(fromTo[0]), - property.getValueFor(fromTo[1]) - )); - } catch (IllegalArgumentException ignored) { - // This property is unlikely to be the one being targeted. - break; - } - } - } - return remaps.stream(); - }).collect(Collectors.toSet()); - } else if (limit.REMAP_PROPERTIES.isEmpty() || newLimit.REMAP_PROPERTIES.isEmpty()) { - limit.REMAP_PROPERTIES = Collections.emptySet(); - } else { - limit.REMAP_PROPERTIES = new HashSet<>(limit.REMAP_PROPERTIES); - limit.REMAP_PROPERTIES.retainAll(newLimit.REMAP_PROPERTIES.stream().flatMap(s -> { - String propertyStr = s.substring(0, s.indexOf('[')); - List> properties = - BlockTypesCache.getAllProperties().get(propertyStr.toLowerCase(Locale.ROOT)); - if (properties == null || properties.isEmpty()) { - return Stream.empty(); - } - String[] mappings = s.substring(s.indexOf('[') + 1, s.indexOf(']')).split(","); - Set> remaps = new HashSet<>(); - for (Property property : properties) { - for (String mapping : mappings) { - try { - String[] fromTo = mapping.split(":"); - remaps.add(property.getRemap( - property.getValueFor(fromTo[0]), - property.getValueFor(fromTo[1]) - )); - } catch (IllegalArgumentException ignored) { - // This property is unlikely to be the one being targeted. - break; - } - } - } - return remaps.stream(); - }).collect(Collectors.toSet())); - if (limit.REMAP_PROPERTIES.isEmpty()) { - limit.REMAP_PROPERTIES = Collections.emptySet(); - } - } - } - } - return limit; - } - } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java index 9dd001687..0e4843f2f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java @@ -44,14 +44,14 @@ public class RollbackDatabase extends AsyncNotifyQueue { this.prefix = ""; this.world = world; this.dbLocation = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + "summary.db" + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HISTORY + File.separator + world.getName() + File.separator + "summary.db" ); connection = openConnection(); try { init().get(); - purge((int) TimeUnit.DAYS.toSeconds(Settings.IMP.HISTORY.DELETE_AFTER_DAYS)); + purge((int) TimeUnit.DAYS.toSeconds(Settings.settings().HISTORY.DELETE_AFTER_DAYS)); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } @@ -284,8 +284,8 @@ public class RollbackDatabase extends AsyncNotifyQueue { if (checkConnection()) { return connection; } - if (!Fawe.imp().getDirectory().exists()) { - Fawe.imp().getDirectory().mkdirs(); + if (!Fawe.platform().getDirectory().exists()) { + Fawe.platform().getDirectory().mkdirs(); } if (!dbLocation.exists()) { try { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java index 3f0ca3f0c..28ed77fed 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java @@ -27,7 +27,7 @@ public class LazyBaseEntity extends BaseEntity { if (Fawe.isMainThread()) { setNbtData(tmp.get()); } else { - setNbtData(TaskManager.IMP.sync(tmp)); + setNbtData(TaskManager.taskManager().sync(tmp)); } } return super.getNbtData(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java index 478cbc46a..3c7ad1f4d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java @@ -166,7 +166,7 @@ public class ConsumeBindings extends Bindings { if (argument.length() > 16) { uuid = UUID.fromString(argument); } else { - uuid = Fawe.imp().getUUID(argument); + uuid = Fawe.platform().getUUID(argument); } if (uuid == null) { throw new InputParseException(Caption.of("fawe.error.player.not.found", TextComponent.of(argument))); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java index b38a1b101..ac869b630 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java @@ -75,7 +75,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc throws WorldEditException { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); + WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return false; } @@ -86,7 +86,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public boolean setBiome(int x, int y, int z, BiomeType biome) { if (!contains(x, y, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); + WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return false; } @@ -97,7 +97,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BiomeType getBiome(BlockVector3 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); + WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return null; } @@ -108,7 +108,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BiomeType getBiomeType(int x, int y, int z) { if (!contains(x, z)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); + WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return null; } @@ -119,7 +119,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BaseBlock getFullBlock(BlockVector3 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); + WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return BlockTypes.AIR.getDefaultState().toBaseBlock(); } @@ -130,7 +130,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public BlockState getBlock(BlockVector3 position) { if (!contains(position)) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); + WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return BlockTypes.AIR.getDefaultState(); } @@ -142,7 +142,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc public Entity createEntity(Location location, BaseEntity entity) { if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) { if (!limit.MAX_FAILS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION); + WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION); } return null; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/MemoryCheckingExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/MemoryCheckingExtent.java index a4398dc69..e2d215c56 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/MemoryCheckingExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/MemoryCheckingExtent.java @@ -29,7 +29,7 @@ public class MemoryCheckingExtent extends PassthroughExtent { this.actor.print(Caption.of("fawe.info.worldedit.oom.admin")); } } - WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY); + WEManager.weManager().cancelEdit(this, FaweCache.LOW_MEMORY); } return super.getExtent(); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java index ab8c1d47b..9635497b2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java @@ -37,7 +37,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { return null; } if (!limit.MAX_ENTITIES()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_ENTITIES); + WEManager.weManager().cancelEditSafe(this, FaweCache.MAX_ENTITIES); return null; } return super.createEntity(location, entity); @@ -46,7 +46,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public BlockState getBlock(int x, int y, int z) { if (!limit.MAX_CHECKS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS); + WEManager.weManager().cancelEditSafe(this, FaweCache.MAX_CHECKS); return BlockTypes.AIR.getDefaultState(); } else { return extent.getBlock(x, y, z); @@ -56,7 +56,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public BaseBlock getFullBlock(BlockVector3 pos) { if (!limit.MAX_CHECKS()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS); + WEManager.weManager().cancelEditSafe(this, FaweCache.MAX_CHECKS); return BlockTypes.AIR.getDefaultState().toBaseBlock(); } else { return extent.getFullBlock(pos); @@ -80,18 +80,18 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { boolean hasNbt = block instanceof BaseBlock && block.hasNbtData(); if (hasNbt) { if (!limit.MAX_BLOCKSTATES()) { - WEManager.IMP.cancelEdit(this, FaweCache.MAX_TILES); + WEManager.weManager().cancelEdit(this, FaweCache.MAX_TILES); return false; } else { if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES); + WEManager.weManager().cancelEdit(this, FaweCache.MAX_CHANGES); return false; } return extent.setBlock(x, y, z, block); } } if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES); + WEManager.weManager().cancelEdit(this, FaweCache.MAX_CHANGES); return false; } else { return extent.setBlock(x, y, z, block); @@ -101,7 +101,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { if (!limit.MAX_CHANGES()) { - WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHANGES); + WEManager.weManager().cancelEditSafe(this, FaweCache.MAX_CHANGES); return false; } return super.setBiome(position, biome); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java index 30f854b3d..6ace08060 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java @@ -72,8 +72,8 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable this( region.getDimensions(), MainUtil.getFile( - Fawe.get() != null ? Fawe.imp().getDirectory() : new File("."), - Settings.IMP.PATHS.CLIPBOARD + File.separator + uuid + ".bd" + Fawe.instance() != null ? Fawe.platform().getDirectory() : new File("."), + Settings.settings().PATHS.CLIPBOARD + File.separator + uuid + ".bd" ) ); setOffset(region.getMinimumPoint()); @@ -84,8 +84,8 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable this( dimensions, MainUtil.getFile( - Fawe.imp() != null ? Fawe.imp().getDirectory() : new File("."), - Settings.IMP.PATHS.CLIPBOARD + File.separator + UUID.randomUUID() + ".bd" + Fawe.platform() != null ? Fawe.platform().getDirectory() : new File("."), + Settings.settings().PATHS.CLIPBOARD + File.separator + UUID.randomUUID() + ".bd" ) ); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java index 8854027eb..6823acc97 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java @@ -54,7 +54,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard { private final int compressionLevel; public MemoryOptimizedClipboard(Region region) { - this(region, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL); + this(region, Settings.settings().CLIPBOARD.COMPRESSION_LEVEL); } public MemoryOptimizedClipboard(Region region, int compressionLevel) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java index 24b3a4daf..e46c58c0e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java @@ -39,12 +39,12 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard { } public static ReadOnlyClipboard of(Extent extent, final Region region) { - Fawe.get().getQueueHandler().unCache(); + Fawe.instance().getQueueHandler().unCache(); return of(() -> extent, region); } public static ReadOnlyClipboard of(Extent extent, final Region region, boolean copyEntities, boolean copyBiomes) { - Fawe.get().getQueueHandler().unCache(); + Fawe.instance().getQueueHandler().unCache(); return of(() -> extent, region, copyEntities, copyBiomes); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java index 6d3a61359..5c60b91c5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java @@ -327,7 +327,7 @@ public class FastSchematicReader extends NBTSchematicReader { // tiles if (tiles != null && !tiles.isEmpty()) { for (Map tileRaw : tiles) { - CompoundTag tile = FaweCache.IMP.asTag(tileRaw); + CompoundTag tile = FaweCache.INSTANCE.asTag(tileRaw); int[] pos = tile.getIntArray("Pos"); int x; @@ -372,7 +372,7 @@ public class FastSchematicReader extends NBTSchematicReader { // entities if (entities != null && !entities.isEmpty()) { for (Map entRaw : entities) { - Map value = new HashMap<>(FaweCache.IMP.asTag(entRaw).getValue()); + Map value = new HashMap<>(FaweCache.INSTANCE.asTag(entRaw).getValue()); StringTag id = (StringTag) value.get("Id"); if (id == null) { id = (StringTag) value.get("id"); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java index f5861e4d1..696dd3ef5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java @@ -123,7 +123,7 @@ public class FastSchematicWriter implements ClipboardWriter { out1.writeNamedTag("WEOffsetX", offset.getBlockX()); out1.writeNamedTag("WEOffsetY", offset.getBlockY()); out1.writeNamedTag("WEOffsetZ", offset.getBlockZ()); - out1.writeNamedTag("FAWEVersion", Fawe.get().getVersion().build); + out1.writeNamedTag("FAWEVersion", Fawe.instance().getVersion().build); }); ByteArrayOutputStream blocksCompressed = new ByteArrayOutputStream(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java index 600ccf50b..79d5f8186 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java @@ -165,7 +165,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { if (width > WARN_SIZE || height > WARN_SIZE || length > WARN_SIZE) { LOGGER.info("A structure longer than 32 is unsupported by minecraft (but probably still works)"); } - Map structure = FaweCache.IMP.asMap("version", 1, "author", owner); + Map structure = FaweCache.INSTANCE.asMap("version", 1, "author", owner); // ignored: version / owner Int2ObjectArrayMap indexes = new Int2ObjectArrayMap<>(); // Size @@ -217,10 +217,10 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { point.getY() - min.getY(), point.getZ() - min.getZ() ); if (!block.hasNbtData()) { - blocks.add(FaweCache.IMP.asMap("state", index, "pos", pos)); + blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos)); } else { blocks.add( - FaweCache.IMP.asMap("state", index, "pos", pos, "nbt", block.getNbtData())); + FaweCache.INSTANCE.asMap("state", index, "pos", pos, "nbt", block.getNbtData())); } } } @@ -240,14 +240,14 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { // Replace rotation data nbtMap.put("Rotation", writeRotation(entity.getLocation())); nbtMap.put("id", new StringTag(state.getType().getId())); - Map entityMap = FaweCache.IMP.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt); + Map entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt); entities.add(entityMap); } } if (!entities.isEmpty()) { structure.put("entities", entities); } - out.writeNamedTag("", FaweCache.IMP.asTag(structure)); + out.writeNamedTag("", FaweCache.INSTANCE.asTag(structure)); close(); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java index b4812e2e8..92be10e66 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java @@ -26,7 +26,7 @@ public class PNGWriter implements ClipboardWriter { public PNGWriter(OutputStream out) throws IOException { this.out = ImageIO.createImageOutputStream(out); - this.tu = Fawe.get().getCachedTextureUtil(false, 0, 100); + this.tu = Fawe.instance().getCachedTextureUtil(false, 0, 100); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/visualizer/SchemVis.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/visualizer/SchemVis.java index b1a393c51..7debe40dd 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/visualizer/SchemVis.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/visualizer/SchemVis.java @@ -203,7 +203,7 @@ // */ // private void clean() { // if (chunks.size() > 225) { -// TaskManager.IMP.sync(() -> { +// TaskManager.taskManager().sync(() -> { // if (chunks.size() > 225) { // synchronized (SchemVis.this) { // Location pos = player.toWorldEditPlayer().getLocation(); @@ -233,7 +233,7 @@ // * @param chunkZ // */ // private void send(IQueueExtent packetQueue, int chunkX, int chunkZ) { -// TaskManager.IMP.getPublicForkJoinPool().submit(() -> { +// TaskManager.taskManager().getPublicForkJoinPool().submit(() -> { // try { // int OX = chunkOffset.getBlockX(); // int OZ = chunkOffset.getBlockZ(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java index 9cefe420f..1a2e4705e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java @@ -71,7 +71,7 @@ public class CharFilterBlock extends ChunkFilterBlock { maxLayer = this.get.getMaxSectionPosition(); this.layer = layer; if (!iget.hasSection(layer)) { - getArr = FaweCache.IMP.EMPTY_CHAR_4096; + getArr = FaweCache.INSTANCE.EMPTY_CHAR_4096; } else { getArr = iget.load(layer); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/ExtentBatchProcessorHolder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/ExtentBatchProcessorHolder.java index b83ea2c4b..20dced74e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/ExtentBatchProcessorHolder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/ExtentBatchProcessorHolder.java @@ -21,7 +21,7 @@ public abstract class ExtentBatchProcessorHolder extends BatchProcessorHolder im @Override public Extent enableHistory(AbstractChangeSet changeSet) { - if (Settings.IMP.HISTORY.SEND_BEFORE_HISTORY) { + if (Settings.settings().HISTORY.SEND_BEFORE_HISTORY) { return this.addPostProcessor(changeSet); } else { return this.addProcessor(changeSet); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java index 55ed8aab7..ca463f911 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java @@ -34,7 +34,7 @@ public class MultiBatchProcessor implements IBatchProcessor { private static final Logger LOGGER = LogManagerCompat.getLogger(); private final LoadingCache, Map> classToThreadIdToFilter = - FaweCache.IMP.createCache((Supplier>) ConcurrentHashMap::new); + FaweCache.INSTANCE.createCache((Supplier>) ConcurrentHashMap::new); // Array for lazy avoidance of concurrent modification exceptions and needless overcomplication of code (synchronisation is // not very important) private boolean[] faweExceptionReasonsUsed = new boolean[FaweException.Type.values().length]; @@ -157,7 +157,7 @@ public class MultiBatchProcessor implements IBatchProcessor { lastException = hash; exceptionCount = 0; LOGGER.catching(e); - } else if (exceptionCount < Settings.IMP.QUEUE.PARALLEL_THREADS) { + } else if (exceptionCount < Settings.settings().QUEUE.PARALLEL_THREADS) { exceptionCount++; LOGGER.warn(message); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/heightmap/HeightmapProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/heightmap/HeightmapProcessor.java index c42d51677..efdf79846 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/heightmap/HeightmapProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/heightmap/HeightmapProcessor.java @@ -62,7 +62,7 @@ public class HeightmapProcessor implements IBatchProcessor { continue; } char[] setSection = hasSectionSet ? set.loadIfPresent(layer) : null; - if (setSection == null || Arrays.equals(setSection, FaweCache.IMP.EMPTY_CHAR_4096) || + if (setSection == null || Arrays.equals(setSection, FaweCache.INSTANCE.EMPTY_CHAR_4096) || Arrays.equals(setSection, AIR_LAYER)) { hasSectionSet = false; } @@ -86,7 +86,7 @@ public class HeightmapProcessor implements IBatchProcessor { } else if (getSection == null) { getSection = get.load(layer); // skip empty layer - if (Arrays.equals(getSection, FaweCache.IMP.EMPTY_CHAR_4096) + if (Arrays.equals(getSection, FaweCache.INSTANCE.EMPTY_CHAR_4096) || Arrays.equals(getSection, AIR_LAYER)) { hasSectionGet = false; if (!hasSectionSet) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java index 7be725bc8..ef8b73f21 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java @@ -77,7 +77,7 @@ public class NMSRelighter implements Relighter { this.concurrentLightQueue = new ConcurrentHashMap<>(12); this.maxY = queue.getMaxY(); this.minY = queue.getMinY(); - this.relightMode = relightMode != null ? relightMode : RelightMode.valueOf(Settings.IMP.LIGHTING.MODE); + this.relightMode = relightMode != null ? relightMode : RelightMode.valueOf(Settings.settings().LIGHTING.MODE); this.lightingLock = new ReentrantLock(); } @@ -911,11 +911,11 @@ public class NMSRelighter implements Relighter { chunk.setBitMask(bitMask); iter.remove(); } - if (Settings.IMP.LIGHTING.ASYNC) { + if (Settings.settings().LIGHTING.ASYNC) { queue.flush(); finished.set(true); } else { - TaskManager.IMP.sync(new RunnableVal<>() { + TaskManager.taskManager().sync(new RunnableVal<>() { @Override public void run(Object value) { queue.flush(); @@ -943,16 +943,16 @@ public class NMSRelighter implements Relighter { ChunkHolder chunk = (ChunkHolder) queue.getOrCreateChunk(x, z); chunk.setBitMask(bitMask); chunk.flushLightToGet(); - Fawe.imp().getPlatformAdapter().sendChunk(chunk.getOrCreateGet(), bitMask, true); + Fawe.platform().getPlatformAdapter().sendChunk(chunk.getOrCreateGet(), bitMask, true); iter.remove(); } finished.set(true); } }; - if (Settings.IMP.LIGHTING.ASYNC) { + if (Settings.settings().LIGHTING.ASYNC) { runnable.run(); } else { - TaskManager.IMP.sync(runnable); + TaskManager.taskManager().sync(runnable); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/RelightProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/RelightProcessor.java index c9b71beb1..8ac56c0f1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/RelightProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/RelightProcessor.java @@ -25,9 +25,9 @@ public class RelightProcessor implements IBatchProcessor { @Override public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) { - if (Settings.IMP.LIGHTING.MODE == 2) { + if (Settings.settings().LIGHTING.MODE == 2) { relighter.addChunk(chunk.getX(), chunk.getZ(), null, chunk.getBitMask()); - } else if (Settings.IMP.LIGHTING.MODE == 1) { + } else if (Settings.settings().LIGHTING.MODE == 1) { byte[] fix = new byte[get.getSectionCount()]; boolean relight = false; for (int i = get.getMaxSectionPosition(); i >= get.getMinSectionPosition(); i--) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern.java index 84cc42d45..399d96663 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern.java @@ -32,7 +32,7 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter } actionTime = tmp; this.pattern = parent; - this.timer = Fawe.get().getTimer(); + this.timer = Fawe.instance().getTimer(); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/DiskStorageHistory.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/DiskStorageHistory.java index 1e307c560..5adeb0c91 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/DiskStorageHistory.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/DiskStorageHistory.java @@ -75,8 +75,8 @@ public class DiskStorageHistory extends FaweStreamChangeSet { private void init(UUID uuid, String worldName) { final File folder = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HISTORY + File.separator + worldName + File.separator + uuid + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HISTORY + File.separator + worldName + File.separator + uuid ); final int max = NEXT_INDEX.computeIfAbsent(worldName, _worldName -> new ConcurrentHashMap<>()) @@ -111,8 +111,8 @@ public class DiskStorageHistory extends FaweStreamChangeSet { this.uuid = uuid; this.index = i; File folder = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HISTORY + File.separator + getWorld().getName() + File.separator + uuid + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HISTORY + File.separator + getWorld().getName() + File.separator + uuid ); initFiles(folder); } @@ -120,7 +120,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet { @Override public void delete() { deleteFiles(); - if (Settings.IMP.HISTORY.USE_DATABASE) { + if (Settings.settings().HISTORY.USE_DATABASE) { RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld()); db.delete(uuid, index); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/MemoryOptimizedHistory.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/MemoryOptimizedHistory.java index 32ac92b48..9e575c2a7 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/MemoryOptimizedHistory.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/MemoryOptimizedHistory.java @@ -149,7 +149,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { } synchronized (this) { setOrigin(x, z); - idsStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE); + idsStream = new FastByteArrayOutputStream(Settings.settings().HISTORY.BUFFER_SIZE); idsStreamZip = getCompressedOS(idsStream); writeHeader(idsStreamZip, x, y, z); return idsStreamZip; @@ -170,7 +170,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { return biomeStreamZip; } synchronized (this) { - biomeStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE); + biomeStream = new FastByteArrayOutputStream(Settings.settings().HISTORY.BUFFER_SIZE); biomeStreamZip = getCompressedOS(biomeStream); return biomeStreamZip; } @@ -191,7 +191,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { if (entCStreamZip != null) { return entCStreamZip; } - entCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE); + entCStream = new FastByteArrayOutputStream(Settings.settings().HISTORY.BUFFER_SIZE); return entCStreamZip = new NBTOutputStream(getCompressedOS(entCStream)); } @@ -200,7 +200,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { if (entRStreamZip != null) { return entRStreamZip; } - entRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE); + entRStream = new FastByteArrayOutputStream(Settings.settings().HISTORY.BUFFER_SIZE); return entRStreamZip = new NBTOutputStream(getCompressedOS(entRStream)); } @@ -209,7 +209,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { if (tileCStreamZip != null) { return tileCStreamZip; } - tileCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE); + tileCStream = new FastByteArrayOutputStream(Settings.settings().HISTORY.BUFFER_SIZE); return tileCStreamZip = new NBTOutputStream(getCompressedOS(tileCStream)); } @@ -218,7 +218,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { if (tileRStreamZip != null) { return tileRStreamZip; } - tileRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE); + tileRStream = new FastByteArrayOutputStream(Settings.settings().HISTORY.BUFFER_SIZE); return tileRStreamZip = new NBTOutputStream(getCompressedOS(tileRStream)); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java index 37fdcbf55..83114a473 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java @@ -64,7 +64,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { return; } waitingAsync.incrementAndGet(); - TaskManager.IMP.async(() -> { + TaskManager.taskManager().async(() -> { waitingAsync.decrementAndGet(); synchronized (waitingAsync) { waitingAsync.notifyAll(); @@ -168,7 +168,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { char[] blocksGet; char[] tmp = get.load(layer); if (tmp == null) { - blocksGet = FaweCache.IMP.EMPTY_CHAR_4096; + blocksGet = FaweCache.INSTANCE.EMPTY_CHAR_4096; } else { System.arraycopy(tmp, 0, (blocksGet = new char[4096]), 0, 4096); } @@ -379,7 +379,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { wrappedTask.run(); return Futures.immediateCancelledFuture(); } else { - return Fawe.get().getQueueHandler().submit(wrappedTask); + return Fawe.instance().getQueueHandler().submit(wrappedTask); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/FaweStreamChangeSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/FaweStreamChangeSet.java index c780297cc..77869a7ce 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/FaweStreamChangeSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/FaweStreamChangeSet.java @@ -43,7 +43,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { protected FaweStreamPositionDelegate posDel; public FaweStreamChangeSet(World world) { - this(world, Settings.IMP.HISTORY.COMPRESSION_LEVEL, Settings.IMP.HISTORY.STORE_REDO, Settings.IMP.HISTORY.SMALL_EDITS); + this(world, Settings.settings().HISTORY.COMPRESSION_LEVEL, Settings.settings().HISTORY.STORE_REDO, Settings.settings().HISTORY.SMALL_EDITS); } public FaweStreamChangeSet(World world, int compression, boolean storeRedo, boolean smallLoc) { @@ -764,7 +764,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { } try (FaweInputStream fis = getBlockIS()) { if (!shallow) { - int amount = (Settings.IMP.HISTORY.BUFFER_SIZE - HEADER_SIZE) / 9; + int amount = (Settings.settings().HISTORY.BUFFER_SIZE - HEADER_SIZE) / 9; MutableFullBlockChange change = new MutableFullBlockChange(null, 0, false); for (int i = 0; i < amount; i++) { int x = posDel.readX(fis) + ox; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java index 2dad4500d..baa20163f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java @@ -14,7 +14,7 @@ public class MutableBlockVector3 extends BlockVector3 { } public static MutableBlockVector3 get(int x, int y, int z) { - return FaweCache.IMP.MUTABLE_BLOCKVECTOR3.get().setComponents(x, y, z); + return FaweCache.INSTANCE.MUTABLE_BLOCKVECTOR3.get().setComponents(x, y, z); } public MutableBlockVector3() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java index a23b910ce..22d85d38a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java @@ -27,11 +27,11 @@ public class MutableVector3 extends Vector3 { } public static MutableVector3 get(int x, int y, int z) { - return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z); + return FaweCache.INSTANCE.MUTABLE_VECTOR3.get().setComponents(x, y, z); } public static MutableVector3 get(double x, double y, double z) { - return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z); + return FaweCache.INSTANCE.MUTABLE_VECTOR3.get().setComponents(x, y, z); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java index c57be1117..c37e2ee70 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java @@ -129,9 +129,9 @@ public interface IBlocks extends Trimable { sectionWriter.writeShort(nonEmpty); // non empty FaweCache.Palette palette; if (stretched) { - palette = FaweCache.IMP.toPalette(0, ids); + palette = FaweCache.INSTANCE.toPalette(0, ids); } else { - palette = FaweCache.IMP.toPaletteUnstretched(0, ids); + palette = FaweCache.INSTANCE.toPaletteUnstretched(0, ids); } sectionWriter.writeByte(palette.bitsPerEntry); // bits per block diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/Flood.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/Flood.java index 142e79d67..6d431c1b6 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/Flood.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/Flood.java @@ -45,7 +45,7 @@ public class Flood { } public synchronized void run(World world) { - QueueHandler queueHandler = Fawe.get().getQueueHandler(); + QueueHandler queueHandler = Fawe.instance().getQueueHandler(); IQueueExtent fq = queueHandler.getQueue(world); while (!chunkQueues.isEmpty()) { long firstKey = chunkQueues.firstLongKey(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java index 58671f0ba..89c3b549f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java @@ -99,7 +99,7 @@ public class ParallelQueueExtent extends PassthroughExtent { final Iterator chunksIter = chunks.iterator(); // Get a pool, to operate on the chunks in parallel - final int size = Math.min(chunks.size(), Settings.IMP.QUEUE.PARALLEL_THREADS); + final int size = Math.min(chunks.size(), Settings.settings().QUEUE.PARALLEL_THREADS); if (size <= 1 && chunksIter.hasNext()) { BlockVector2 pos = chunksIter.next(); getExtent().apply(null, filter, region, pos.getX(), pos.getZ(), full); @@ -147,7 +147,7 @@ public class ParallelQueueExtent extends PassthroughExtent { lastException = hash; exceptionCount = 0; LOGGER.catching(e); - } else if (exceptionCount < Settings.IMP.QUEUE.PARALLEL_THREADS) { + } else if (exceptionCount < Settings.settings().QUEUE.PARALLEL_THREADS) { exceptionCount++; LOGGER.warn(message); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java index 83e9da4f9..cd731d10b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java @@ -41,7 +41,7 @@ public abstract class QueueHandler implements Trimable, Runnable { private final ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool(); private final ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool(); - private final ThreadPoolExecutor blockingExecutor = FaweCache.IMP.newBlockingExecutor(); + private final ThreadPoolExecutor blockingExecutor = FaweCache.INSTANCE.newBlockingExecutor(); private final ConcurrentLinkedQueue syncTasks = new ConcurrentLinkedQueue<>(); private final ConcurrentLinkedQueue syncWhenFree = new ConcurrentLinkedQueue<>(); @@ -56,7 +56,7 @@ public abstract class QueueHandler implements Trimable, Runnable { private double targetTPS = 18; public QueueHandler() { - TaskManager.IMP.repeat(this, 1); + TaskManager.taskManager().repeat(this, 1); } @Override @@ -87,14 +87,14 @@ public abstract class QueueHandler implements Trimable, Runnable { private long getAllocate() { long now = System.currentTimeMillis(); - targetTPS = 18 - Math.max(Settings.IMP.QUEUE.EXTRA_TIME_MS * 0.05, 0); + targetTPS = 18 - Math.max(Settings.settings().QUEUE.EXTRA_TIME_MS * 0.05, 0); long diff = 50 + this.last - (this.last = now); long absDiff = Math.abs(diff); if (diff == 0) { allocate = Math.min(50, allocate + 1); } else if (diff < 0) { allocate = Math.max(5, allocate + diff); - } else if (!Fawe.get().getTimer().isAbove(targetTPS)) { + } else if (!Fawe.instance().getTimer().isAbove(targetTPS)) { allocate = Math.max(5, allocate - 1); } return allocate - absDiff; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java index 8f1c1c489..97513aa69 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java @@ -250,7 +250,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen } } - return (V) Fawe.get().getQueueHandler().submit(chunk); + return (V) Fawe.instance().getQueueHandler().submit(chunk); } @Override @@ -266,7 +266,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen if (aggressive) { pollSubmissions(0, aggressive); } else { - pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, aggressive); + pollSubmissions(Settings.settings().QUEUE.PARALLEL_THREADS, aggressive); } } synchronized (this) { @@ -312,8 +312,8 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen // If queueing is enabled AND either of the following // - memory is low & queue size > num threads + 8 // - queue size > target size and primary queue has less than num threads submissions - if (enabledQueue && ((lowMem && size > Settings.IMP.QUEUE.PARALLEL_THREADS + 8) || (size > Settings.IMP.QUEUE.TARGET_SIZE && Fawe - .get() + if (enabledQueue && ((lowMem && size > Settings.settings().QUEUE.PARALLEL_THREADS + 8) || (size > Settings.settings().QUEUE.TARGET_SIZE && Fawe + .instance() .getQueueHandler() .isUnderutilized()))) { chunk = chunks.removeFirst(); @@ -321,9 +321,9 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen if (future != null && !future.isDone()) { final int targetSize; if (lowMem) { - targetSize = Settings.IMP.QUEUE.PARALLEL_THREADS + 8; + targetSize = Settings.settings().QUEUE.PARALLEL_THREADS + 8; } else { - targetSize = Settings.IMP.QUEUE.TARGET_SIZE; + targetSize = Settings.settings().QUEUE.TARGET_SIZE; } pollSubmissions(targetSize, lowMem); submissions.add(future); @@ -361,10 +361,10 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen * @param region region of chunks */ public void preload(Region region) { - if (Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT > 1) { + if (Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT > 1) { int loadCount = 0; for (BlockVector2 from : region.getChunks()) { - if (loadCount >= Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT) { + if (loadCount >= Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT) { break; } loadCount++; @@ -409,7 +409,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen lastException = hash; exceptionCount = 0; LOGGER.catching(e); - } else if (exceptionCount < Settings.IMP.QUEUE.PARALLEL_THREADS) { + } else if (exceptionCount < Settings.settings().QUEUE.PARALLEL_THREADS) { exceptionCount++; LOGGER.warn(message); } @@ -449,7 +449,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen lastException = hash; exceptionCount = 0; LOGGER.catching(e); - } else if (exceptionCount < Settings.IMP.QUEUE.PARALLEL_THREADS) { + } else if (exceptionCount < Settings.settings().QUEUE.PARALLEL_THREADS) { exceptionCount++; LOGGER.warn(message); } @@ -464,7 +464,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen for (IQueueChunk chunk : chunks.values()) { final Future future = submitUnchecked(chunk); if (future != null && !future.isDone()) { - pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, true); + pollSubmissions(Settings.settings().QUEUE.PARALLEL_THREADS, true); submissions.add(future); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java index 0829ac710..89c9d0519 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java @@ -124,7 +124,7 @@ public class BitSetBlocks implements IChunkSet { @Override public char[] load(int layer) { layer -= minSectionPosition; - char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get(); + char[] arr = FaweCache.INSTANCE.SECTION_BITS_TO_CHAR.get(); MemBlockSet.IRow nullRowY = row.getRow(layer); if (nullRowY instanceof MemBlockSet.RowY) { char value = blockState.getOrdinalChar(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java index 882cbe682..8b434cc8a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java @@ -201,7 +201,7 @@ public abstract class CharBlocks implements IBlocks { set(layer, index, value); } catch (ArrayIndexOutOfBoundsException exception) { LOGGER.error("Tried setting block at coordinates (" + x + "," + y + "," + z + ")"); - assert Fawe.imp() != null; + assert Fawe.platform() != null; LOGGER.error("Layer variable was = {}", layer, exception); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java index 64e3aa7ed..df8bde411 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java @@ -23,10 +23,10 @@ import java.util.stream.IntStream; public class CharSetBlocks extends CharBlocks implements IChunkSet { - private static final Pool POOL = FaweCache.IMP.registerPool( + private static final Pool POOL = FaweCache.INSTANCE.registerPool( CharSetBlocks.class, CharSetBlocks::new, - Settings.IMP.QUEUE.POOL + Settings.settings().QUEUE.POOL ); public static CharSetBlocks newInstance() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/NullChunkGet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/NullChunkGet.java index eea966ebc..8f7b8007c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/NullChunkGet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/NullChunkGet.java @@ -124,7 +124,7 @@ public final class NullChunkGet implements IChunkGet { @Nonnull public char[] load(int layer) { - return FaweCache.IMP.EMPTY_CHAR_4096; + return FaweCache.INSTANCE.EMPTY_CHAR_4096; } @Nullable diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java index 27fdf76ad..5634dd1f5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java @@ -32,10 +32,10 @@ import java.util.concurrent.Future; @SuppressWarnings("rawtypes") public class ChunkHolder> implements IQueueChunk { - private static final Pool POOL = FaweCache.IMP.registerPool( + private static final Pool POOL = FaweCache.INSTANCE.registerPool( ChunkHolder.class, ChunkHolder::new, - Settings.IMP.QUEUE.POOL + Settings.settings().QUEUE.POOL ); public static ChunkHolder newInstance() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/packet/ChunkPacket.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/packet/ChunkPacket.java index 9df1a8f9f..7f8195bbc 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/packet/ChunkPacket.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/packet/ChunkPacket.java @@ -64,8 +64,8 @@ public class ChunkPacket implements Function, Supplier { synchronized (this) { if (sectionBytes == null) { IBlocks tmpChunk = getChunk(); - byte[] buf = FaweCache.IMP.BYTE_BUFFER_8192.get(); - sectionBytes = tmpChunk.toByteArray(buf, tmpChunk.getBitMask(), this.full, Fawe.imp().isChunksStretched()); + byte[] buf = FaweCache.INSTANCE.BYTE_BUFFER_8192.get(); + sectionBytes = tmpChunk.toByteArray(buf, tmpChunk.getBitMask(), this.full, Fawe.platform().isChunksStretched()); } tmp = sectionBytes; } @@ -85,14 +85,14 @@ public class ChunkPacket implements Function, Supplier { @Override @Deprecated public byte[] get() { - return apply(FaweCache.IMP.BYTE_BUFFER_8192.get()); + return apply(FaweCache.INSTANCE.BYTE_BUFFER_8192.get()); } public CompoundTag getHeightMap() { HashMap map = new HashMap<>(); map.put("MOTION_BLOCKING", new long[36]); // TODO - return FaweCache.IMP.asTag(map); + return FaweCache.INSTANCE.asTag(map); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java index 43d18f3a7..29e82790d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java @@ -31,7 +31,7 @@ public class AsyncPreloader implements Preloader, Runnable { public AsyncPreloader() { this.update = new ConcurrentHashMap<>(); - TaskManager.IMP.laterAsync(this, 1); + TaskManager.taskManager().laterAsync(this, 1); } @Override @@ -77,7 +77,7 @@ public class AsyncPreloader implements Preloader, Runnable { existing.setKey(world); existing.setValue(ImmutableSet.copyOf(Iterables.limit( region.getChunks(), - Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT + Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT ))); } synchronized (update) { @@ -89,12 +89,12 @@ public class AsyncPreloader implements Preloader, Runnable { @Override public void run() { - FaweTimer timer = Fawe.get().getTimer(); + FaweTimer timer = Fawe.instance().getTimer(); if (cancelled.get()) { return; } if (update.isEmpty()) { - TaskManager.IMP.laterAsync(this, 1); + TaskManager.taskManager().laterAsync(this, 1); return; } Iterator>>> plrIter = update.entrySet().iterator(); @@ -118,7 +118,7 @@ public class AsyncPreloader implements Preloader, Runnable { if (cancelled.get()) { return; } - TaskManager.IMP.laterAsync(this, 20); + TaskManager.taskManager().laterAsync(this, 20); } private void queueLoad(World world, BlockVector2 chunk) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FaweMaskManager.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FaweMaskManager.java index dd413080b..60c6e6be9 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FaweMaskManager.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FaweMaskManager.java @@ -29,7 +29,7 @@ public abstract class FaweMaskManager { public abstract FaweMask getMask(final Player player, MaskType type, boolean isWhitelist); public boolean isExclusive() { - return Settings.IMP.REGION_RESTRICTIONS_OPTIONS.EXCLUSIVE_MANAGERS.contains(this.key); + return Settings.settings().REGION_RESTRICTIONS_OPTIONS.EXCLUSIVE_MANAGERS.contains(this.key); } public enum MaskType { @@ -39,7 +39,7 @@ public abstract class FaweMaskManager { public static MaskType getDefaultMaskType() { try { return MaskType - .valueOf(Settings.IMP.REGION_RESTRICTIONS_OPTIONS.MODE.toUpperCase(Locale.ROOT)); + .valueOf(Settings.settings().REGION_RESTRICTIONS_OPTIONS.MODE.toUpperCase(Locale.ROOT)); } catch (Exception ignored) { return MEMBER; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java index d6fa8f5d1..ae64b274e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java @@ -115,7 +115,7 @@ public class MainUtil { public static long getTotalSize(Path path) { final AtomicLong size = new AtomicLong(0); - traverse(path, new RunnableVal2() { + traverse(path, new RunnableVal2<>() { @Override public void run(Path path, BasicFileAttributes attrs) { size.addAndGet(attrs.size()); @@ -126,7 +126,7 @@ public class MainUtil { public static void traverse(Path path, final BiConsumer onEach) { try { - Files.walkFileTree(path, new SimpleFileVisitor() { + Files.walkFileTree(path, new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { @@ -231,20 +231,19 @@ public class MainUtil { } public static long getSize(ChangeSet changeSet) { - if (changeSet instanceof FaweStreamChangeSet) { - FaweStreamChangeSet fscs = (FaweStreamChangeSet) changeSet; + if (changeSet instanceof FaweStreamChangeSet fscs) { return fscs.getSizeOnDisk() + fscs.getSizeInMemory(); // } else if (changeSet instanceof CPUOptimizedChangeSet) { // return changeSet.size() + 32; } else if (changeSet != null) { - return changeSet.size() * 128; + return changeSet.size() * 128L; } else { return 0; } } public static FaweOutputStream getCompressedOS(OutputStream os, int amount) throws IOException { - return getCompressedOS(os, amount, Settings.IMP.HISTORY.BUFFER_SIZE); + return getCompressedOS(os, amount, Settings.settings().HISTORY.BUFFER_SIZE); } private static final LZ4Factory FACTORY = LZ4Factory.fastestInstance(); @@ -350,7 +349,7 @@ public class MainUtil { } public static FaweInputStream getCompressedIS(InputStream is) throws IOException { - return getCompressedIS(is, Settings.IMP.HISTORY.BUFFER_SIZE); + return getCompressedIS(is, Settings.settings().HISTORY.BUFFER_SIZE); } public static FaweInputStream getCompressedIS(InputStream is, int buffer) throws IOException { @@ -381,7 +380,7 @@ public class MainUtil { } public static URL upload(UUID uuid, String file, String extension, @Nonnull final RunnableVal writeTask) { - return upload(Settings.IMP.WEB.URL, uuid != null, uuid != null ? uuid.toString() : null, file, extension, writeTask); + return upload(Settings.settings().WEB.URL, uuid != null, uuid != null ? uuid.toString() : null, file, extension, writeTask); } public static URL upload( @@ -413,16 +412,15 @@ public class MainUtil { StandardCharsets.UTF_8 ), true)) { String crlf = "\r\n"; - writer.append("--" + boundary).append(crlf); + writer.append("--").append(boundary).append(crlf); writer.append("Content-Disposition: form-data; name=\"param\"").append(crlf); - writer.append("Content-Type: text/plain; charset=" + StandardCharsets.UTF_8.displayName()).append(crlf); + writer.append("Content-Type: text/plain; charset=").append(StandardCharsets.UTF_8.displayName()).append(crlf); String param = "value"; writer.append(crlf).append(param).append(crlf).flush(); - writer.append("--" + boundary).append(crlf); - writer - .append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + '"') + writer.append("--").append(boundary).append(crlf); + writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"").append(filename).append(String.valueOf('"')) .append(crlf); - writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(crlf); + writer.append("Content-Type: ").append(URLConnection.guessContentTypeFromName(filename)).append(crlf); writer.append("Content-Transfer-Encoding: binary").append(crlf); writer.append(crlf).flush(); OutputStream nonClosable = new AbstractDelegateOutputStream(new BufferedOutputStream(output)) { @@ -434,7 +432,7 @@ public class MainUtil { writeTask.run(); nonClosable.flush(); writer.append(crlf).flush(); - writer.append("--" + boundary + "--").append(crlf).flush(); + writer.append("--").append(boundary).append("--").append(crlf).flush(); } int responseCode = ((HttpURLConnection) con).getResponseCode(); String content; @@ -524,7 +522,7 @@ public class MainUtil { try { return getJarFile(Fawe.class); } catch (MalformedURLException | URISyntaxException | SecurityException e) { - return new File(Fawe.imp().getDirectory().getParentFile(), "FastAsyncWorldEdit.jar"); + return new File(Fawe.platform().getDirectory().getParentFile(), "FastAsyncWorldEdit.jar"); } } @@ -598,7 +596,7 @@ public class MainUtil { public static File copyFile(File jar, String resource, File output, String fileName) { try { if (output == null) { - output = Fawe.imp().getDirectory(); + output = Fawe.platform().getDirectory(); } if (!output.exists()) { output.mkdirs(); @@ -663,21 +661,19 @@ public class MainUtil { continue; } switch (c) { - case '-': - val = -val; - break; - case '.': + case '-' -> val = -val; + case '.' -> { res[index--] = val; if (index == -1) { return res; } val = 0; numIndex = 1; - break; - default: + } + default -> { val = val + (c - 48) * numIndex; numIndex *= 10; - break; + } } } res[index] = val; @@ -802,30 +798,30 @@ public class MainUtil { int years = (int) (time / 33868800); int time1 = years * 33868800; time -= time1; - toreturn.append(years + "y "); + toreturn.append(years).append("y "); } if (time >= 604800) { int weeks = (int) (time / 604800); - time -= weeks * 604800; - toreturn.append(weeks + "w "); + time -= weeks * 604800L; + toreturn.append(weeks).append("w "); } if (time >= 86400) { int days = (int) (time / 86400); - time -= days * 86400; - toreturn.append(days + "d "); + time -= days * 86400L; + toreturn.append(days).append("d "); } if (time >= 3600) { int hours = (int) (time / 3600); - time -= hours * 3600; - toreturn.append(hours + "h "); + time -= hours * 3600L; + toreturn.append(hours).append("h "); } if (time >= 60) { int minutes = (int) (time / 60); - time -= minutes * 60; - toreturn.append(minutes + "m "); + time -= minutes * 60L; + toreturn.append(minutes).append("m "); } if (toreturn.equals("") || time > 0) { - toreturn.append((time) + "s "); + toreturn.append(time).append("s "); } return toreturn.toString().trim(); } @@ -849,23 +845,23 @@ public class MainUtil { case "wks": case "w": - time += 604800 * nums; + time += 604800L * nums; case "days": case "day": case "d": - time += 86400 * nums; + time += 86400L * nums; case "hour": case "hr": case "hrs": case "hours": case "h": - time += 3600 * nums; + time += 3600L * nums; case "minutes": case "minute": case "mins": case "min": case "m": - time += 60 * nums; + time += 60L * nums; case "seconds": case "second": case "secs": diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MemUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MemUtil.java index 7aa4036ee..7760663ea 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MemUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MemUtil.java @@ -44,7 +44,7 @@ public class MemUtil { } final long heapFreeSize = Runtime.getRuntime().freeMemory(); final int size = (int) ((heapFreeSize * 100) / heapMaxSize); - if (size > (100 - Settings.IMP.MAX_MEMORY_PERCENT)) { + if (size > (100 - Settings.settings().MAX_MEMORY_PERCENT)) { memoryPlentifulTask(); return Integer.MAX_VALUE; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java index 9124d06e0..ad69c87d6 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java @@ -21,10 +21,31 @@ public abstract class TaskManager { private static final Logger LOGGER = LogManagerCompat.getLogger(); + /** + * @deprecated Use {@link #taskManager()} to get an instance. + */ + @Deprecated(forRemoval = true, since = "2.0.0") public static TaskManager IMP; - + static TaskManager INSTANCE; private final ForkJoinPool pool = new ForkJoinPool(); + protected TaskManager() { + INSTANCE = this; + } + + /** + * Gets an instance of the TaskManager. + * + * @return an instance of the TaskManager + * @since 2.0.0 + */ + public static TaskManager taskManager() { + if (INSTANCE == null) { + INSTANCE = Fawe.platform().getTaskManager(); + } + return INSTANCE; + } + /** * Run a repeating task on the main thread. * @@ -68,8 +89,8 @@ public abstract class TaskManager { /** * Run a bunch of tasks in parallel using the shared thread pool. */ - public void parallel(Collection runnables) { - for (Runnable run : runnables) { + public void parallel(Collection runables) { + for (Runnable run : runables) { pool.submit(run); } pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS); @@ -87,7 +108,7 @@ public abstract class TaskManager { return; } if (numThreads == null) { - numThreads = Settings.IMP.QUEUE.PARALLEL_THREADS; + numThreads = Settings.settings().QUEUE.PARALLEL_THREADS; } if (numThreads <= 1) { for (Runnable run : runnables) { @@ -135,7 +156,7 @@ public abstract class TaskManager { * Disable async catching for a specific task. */ public void runUnsafe(Runnable run) { - QueueHandler queue = Fawe.get().getQueueHandler(); + QueueHandler queue = Fawe.instance().getQueueHandler(); queue.startSet(true); try { run.run(); @@ -256,7 +277,7 @@ public abstract class TaskManager { synchronized (running) { while (running.get()) { running.wait(timeout); - if (running.get() && System.currentTimeMillis() - start > Settings.IMP.QUEUE.DISCARD_AFTER_MS) { + if (running.get() && System.currentTimeMillis() - start > Settings.settings().QUEUE.DISCARD_AFTER_MS) { new RuntimeException("FAWE is taking a long time to execute a task (might just be a symptom): ").printStackTrace(); LOGGER.info("For full debug information use: /fawe threads"); } @@ -278,7 +299,7 @@ public abstract class TaskManager { if (Fawe.isMainThread()) { run.run(); } else { - Fawe.get().getQueueHandler().sync(run); + Fawe.instance().getQueueHandler().sync(run); } } @@ -293,7 +314,7 @@ public abstract class TaskManager { return function.value; } try { - return Fawe.get().getQueueHandler().sync((Supplier) function).get(); + return Fawe.instance().getQueueHandler().sync((Supplier) function).get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } @@ -309,7 +330,7 @@ public abstract class TaskManager { return supplier.get(); } try { - return Fawe.get().getQueueHandler().sync(supplier).get(); + return Fawe.instance().getQueueHandler().sync(supplier).get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } @@ -334,7 +355,7 @@ public abstract class TaskManager { return function.get(); } try { - return Fawe.get().getQueueHandler().sync(function).get(); + return Fawe.instance().getQueueHandler().sync(function).get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java index d1e9a17a9..2a7da6939 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java @@ -340,7 +340,7 @@ public class TextureUtil implements TextureHolder { * Do not use. Use {@link Fawe#getTextureUtil()} */ public TextureUtil() throws FileNotFoundException { - this(MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.TEXTURES)); + this(MainUtil.getFile(Fawe.platform().getDirectory(), Settings.settings().PATHS.TEXTURES)); } /** @@ -351,12 +351,12 @@ public class TextureUtil implements TextureHolder { if (!folder.exists()) { try { LOGGER.info("Downloading asset jar from Mojang, please wait..."); - new File(Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/").mkdirs(); + new File(Fawe.platform().getDirectory() + "/" + Settings.settings().PATHS.TEXTURES + "/").mkdirs(); try (BufferedInputStream in = new BufferedInputStream( new URL("https://launcher.mojang.com/v1/objects/7e46fb47609401970e2818989fa584fd467cd036/client.jar") .openStream()); FileOutputStream fileOutputStream = new FileOutputStream( - Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/1.18.1.jar")) { + Fawe.platform().getDirectory() + "/" + Settings.settings().PATHS.TEXTURES + "/1.18.1.jar")) { byte[] dataBuffer = new byte[1024]; int bytesRead; while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { @@ -395,7 +395,7 @@ public class TextureUtil implements TextureHolder { } public static TextureUtil fromBlocks(Set blocks) throws FileNotFoundException { - return new FilteredTextureUtil(Fawe.get().getTextureUtil(), blocks); + return new FilteredTextureUtil(Fawe.instance().getTextureUtil(), blocks); } public static TextureUtil fromMask(Mask mask) throws FileNotFoundException { @@ -404,7 +404,7 @@ public class TextureUtil implements TextureHolder { SingleFilterBlock extent = new SingleFilterBlock(); new MaskTraverser(mask).reset(extent); - TextureUtil tu = Fawe.get().getTextureUtil(); + TextureUtil tu = Fawe.instance().getTextureUtil(); for (int typeId : tu.getValidBlockIds()) { BlockType block = BlockTypes.get(typeId); extent.init(0, 0, 0, block.getDefaultState().toBaseBlock()); @@ -807,13 +807,13 @@ public class TextureUtil implements TextureHolder { // Get all the jar files File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar")); if (files.length == 0) { - new File(Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/") + new File(Fawe.platform().getDirectory() + "/" + Settings.settings().PATHS.TEXTURES + "/") .mkdirs(); try (BufferedInputStream in = new BufferedInputStream( new URL("https://launcher.mojang.com/v1/objects/7e46fb47609401970e2818989fa584fd467cd036/client.jar") .openStream()); FileOutputStream fileOutputStream = new FileOutputStream( - Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/1.18.1.jar")) { + Fawe.platform().getDirectory() + "/" + Settings.settings().PATHS.TEXTURES + "/1.18.1.jar")) { byte[] dataBuffer = new byte[1024]; int bytesRead; while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java index 30c14c92f..6425cfd14 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java @@ -27,14 +27,14 @@ public class UpdateNotification { * Check whether a new build with a higher build number than the current build is available. */ public static void doUpdateCheck() { - if (Settings.IMP.ENABLED_COMPONENTS.UPDATE_NOTIFICATIONS) { + if (Settings.settings().ENABLED_COMPONENTS.UPDATE_NOTIFICATIONS) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new URL("https://ci.athion.net/job/FastAsyncWorldEdit/api/xml/").openStream()); faweVersion = doc.getElementsByTagName("lastSuccessfulBuild").item(0).getFirstChild().getTextContent(); - FaweVersion faweVersion = Fawe.get().getVersion(); + FaweVersion faweVersion = Fawe.instance().getVersion(); if (faweVersion.build == 0) { LOGGER.warn("You are using a snapshot or a custom version of FAWE. This is not an official build distributed " + "via https://www.spigotmc.org/resources/13932/"); @@ -66,9 +66,9 @@ public class UpdateNotification { * @param actor The player to notify. */ public static void doUpdateNotification(Actor actor) { - if (Settings.IMP.ENABLED_COMPONENTS.UPDATE_NOTIFICATIONS) { + if (Settings.settings().ENABLED_COMPONENTS.UPDATE_NOTIFICATIONS) { if (actor.hasPermission("fawe.admin") && UpdateNotification.hasUpdate) { - FaweVersion faweVersion = Fawe.get().getVersion(); + FaweVersion faweVersion = Fawe.instance().getVersion(); int versionDifference = Integer.parseInt(UpdateNotification.faweVersion) - faweVersion.build; actor.print(Caption.of( "fawe.info.update-available", diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java index cbb5695ec..3b2a4782e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java @@ -26,10 +26,28 @@ import java.util.Set; public class WEManager { - public static final WEManager IMP = new WEManager(); private static final Logger LOGGER = LogManagerCompat.getLogger(); + private static WEManager INSTANCE; + /** + * @deprecated Use {@link #weManager()} instead. + */ + @Deprecated(forRemoval = true, since = "2.0.0") + private final WEManager IMP = new WEManager(); private final ArrayDeque managers = new ArrayDeque<>(); + private WEManager() { + INSTANCE = this; + } + + /** + * Get an instance of the WEManager. + * + * @return an instance of the WEManager + */ + public static WEManager weManager() { + return INSTANCE; + } + public ArrayDeque getManagers() { return managers; } @@ -81,7 +99,7 @@ public class WEManager { * @return array of allowed regions if whitelist, else of disallowed regions. */ public Region[] getMask(Player player, FaweMaskManager.MaskType type, final boolean isWhitelist) { - if (!Settings.IMP.REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) { + if (!Settings.settings().REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) { return new Region[]{RegionWrapper.GLOBAL()}; } Location loc = player.getLocation(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java index 6da6b471e..50512235c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java @@ -22,7 +22,7 @@ import java.util.Set; public final class MemBlockSet extends BlockSet { public static final int BITS_PER_WORD = 6; - public static final int WORDS = FaweCache.IMP.BLOCKS_PER_LAYER >> BITS_PER_WORD; + public static final int WORDS = FaweCache.INSTANCE.BLOCKS_PER_LAYER >> BITS_PER_WORD; public static final IRow NULL_ROW_X = new NullRowX(); public static final IRow NULL_ROW_Z = new NullRowZ(); public static final IRow NULL_ROW_Y = new NullRowY(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java index ee8ee6251..a8998e1f0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java @@ -212,8 +212,8 @@ public class ImageUtil { if (arg.startsWith("file:/")) { arg = arg.replaceFirst("file:/+", ""); File file = MainUtil.getFile(MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HEIGHTMAP + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HEIGHTMAP ), arg); return MainUtil.readImage(file); } @@ -234,8 +234,8 @@ public class ImageUtil { if (arg.startsWith("file:/")) { arg = arg.replaceFirst("file:/+", ""); File file = MainUtil.getFile(MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HEIGHTMAP + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HEIGHTMAP ), arg); if (!file.exists()) { throw new InputParseException(Caption.of( diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java index ef92296c0..c14ca93eb 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java @@ -17,8 +17,8 @@ public class DefaultProgressTracker implements BiConsumer { this.task = new Runnable() { @Override public void run() { - long allowedTick = Fawe.get().getTimer().getTick() - 1; + long allowedTick = Fawe.instance().getTimer().getTick() - 1; Iterator> iter = objMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = iter.next(); @@ -32,7 +32,7 @@ public abstract class SingleThreadIntervalQueue { } synchronized (objMap) { if (!objMap.isEmpty()) { - TaskManager.IMP.laterAsync(this, interval); + TaskManager.taskManager().laterAsync(this, interval); } else { queued.set(false); } @@ -51,10 +51,10 @@ public abstract class SingleThreadIntervalQueue { public void queue(T obj) { synchronized (objMap) { - objMap.put(obj, Fawe.get().getTimer().getTick()); + objMap.put(obj, Fawe.instance().getTimer().getTick()); if (!queued.get()) { queued.set(true); - TaskManager.IMP.laterAsync(task, 3); + TaskManager.taskManager().laterAsync(task, 3); } } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java index 70c7abd9c..dcc65ae21 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java @@ -97,7 +97,7 @@ public interface SimpleWorld extends World { @Override default boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) { - Fawe.get().getQueueHandler().sync((Supplier) () -> playEffect( + Fawe.instance().getQueueHandler().sync((Supplier) () -> playEffect( position, 2001, blockType.getLegacyCombinedId() >> 4 diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java index b7d9acace..700070611 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java @@ -38,7 +38,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public void findFreePosition(Location searchPos) { - TaskManager.IMP.sync(new RunnableVal() { + TaskManager.taskManager().sync(new RunnableVal() { @Override public void run(Boolean value) { getBasePlayer().findFreePosition(searchPos); @@ -48,7 +48,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public void setOnGround(Location searchPos) { - TaskManager.IMP.sync(new RunnableVal() { + TaskManager.taskManager().sync(new RunnableVal() { @Override public void run(Boolean value) { getBasePlayer().setOnGround(searchPos); @@ -58,7 +58,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public void findFreePosition() { - TaskManager.IMP.sync(new RunnableVal() { + TaskManager.taskManager().sync(new RunnableVal() { @Override public void run(Boolean value) { getBasePlayer().findFreePosition(); @@ -68,12 +68,12 @@ public class AsyncPlayer extends PlayerProxy { @Override public boolean ascendLevel() { - return TaskManager.IMP.sync(() -> getBasePlayer().ascendLevel()); + return TaskManager.taskManager().sync(() -> getBasePlayer().ascendLevel()); } @Override public boolean descendLevel() { - return TaskManager.IMP.sync(() -> getBasePlayer().descendLevel()); + return TaskManager.taskManager().sync(() -> getBasePlayer().descendLevel()); } @Override @@ -155,7 +155,7 @@ public class AsyncPlayer extends PlayerProxy { unwrap(getBasePlayer())).build(); edit.setBlock(BlockVector3.at(x, y - 1, z), BlockTypes.GLASS); edit.flushQueue(); - LocalSession session = Fawe.get().getWorldEdit().getSessionManager().get(this); + LocalSession session = Fawe.instance().getWorldEdit().getSessionManager().get(this); if (session != null) { session.remember(edit, true, getBasePlayer().getLimit().MAX_HISTORY); } @@ -173,12 +173,12 @@ public class AsyncPlayer extends PlayerProxy { @Override public void setPosition(Vector3 pos, float pitch, float yaw) { - Fawe.get().getQueueHandler().sync(() -> super.setPosition(pos, pitch, yaw)); + Fawe.instance().getQueueHandler().sync(() -> super.setPosition(pos, pitch, yaw)); } @Override public Location getBlockTrace(int range, boolean useLastBlock) { - return TaskManager.IMP.sync(() -> { + return TaskManager.taskManager().sync(() -> { TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D); return useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock(); }); @@ -186,7 +186,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public Location getBlockTraceFace(int range, boolean useLastBlock) { - return TaskManager.IMP.sync(() -> { + return TaskManager.taskManager().sync(() -> { TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D); return useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace(); }); @@ -194,7 +194,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public Location getSolidBlockTrace(int range) { - return TaskManager.IMP.sync(() -> { + return TaskManager.taskManager().sync(() -> { TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D); return tb.getSolidTargetBlock(); }); @@ -207,7 +207,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public boolean passThroughForwardWall(int range) { - return TaskManager.IMP.sync(() -> { + return TaskManager.taskManager().sync(() -> { int searchDist = 0; TargetBlock hitBlox = new TargetBlock(AsyncPlayer.this, range, 0.2); Extent world = getLocation().getExtent(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java index 8374cba7c..0537aef0a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java @@ -238,7 +238,7 @@ public class WorldWrapper extends AbstractWorld { @Override public void simulateBlockMine(BlockVector3 pt) { - TaskManager.IMP.sync(new RunnableVal() { + TaskManager.taskManager().sync(new RunnableVal() { @Override public void run(Object value) { parent.simulateBlockMine(pt); @@ -249,7 +249,7 @@ public class WorldWrapper extends AbstractWorld { //FAWE start @Override public Collection getBlockDrops(final BlockVector3 position) { - return TaskManager.IMP.sync(() -> parent.getBlockDrops(position)); + return TaskManager.taskManager().sync(() -> parent.getBlockDrops(position)); } //FAWE end @@ -266,7 +266,7 @@ public class WorldWrapper extends AbstractWorld { @Override public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException { - return TaskManager.IMP.sync(() -> { + return TaskManager.taskManager().sync(() -> { try { return parent.generateTree(type, editSession, position); } catch (MaxChangedBlocksException e) { @@ -307,12 +307,12 @@ public class WorldWrapper extends AbstractWorld { @Override public List getEntities(Region region) { - return TaskManager.IMP.sync(() -> parent.getEntities(region)); + return TaskManager.taskManager().sync(() -> parent.getEntities(region)); } @Override public List getEntities() { - return TaskManager.IMP.sync(parent::getEntities); + return TaskManager.taskManager().sync(parent::getEntities); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index f1e21c067..77757fe77 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1289,7 +1289,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { // Don't relight twice! if (!relighter.isFinished() && relighter.getLock().tryLock()) { try { - if (Settings.IMP.LIGHTING.REMOVE_FIRST) { + if (Settings.settings().LIGHTING.REMOVE_FIRST) { relighter.removeAndRelight(true); } else { relighter.fixLightingSafe(true); @@ -1305,14 +1305,14 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } // Cancel any preloader associated with the actor if present if (getActor() instanceof Player) { - Preloader preloader = Fawe.imp().getPreloader(false); + Preloader preloader = Fawe.platform().getPreloader(false); if (preloader != null) { preloader.cancel(getActor()); } } // Enqueue it if (getChangeSet() != null) { - if (Settings.IMP.HISTORY.COMBINE_STAGES) { + if (Settings.settings().HISTORY.COMBINE_STAGES) { ((AbstractChangeSet) getChangeSet()).closeAsync(); } else { try { @@ -3649,7 +3649,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } if (containsAny) { changes++; - TaskManager.IMP.sync(new RunnableVal() { + TaskManager.taskManager().sync(new RunnableVal() { @Override public void run(Object value) { regenerateChunk(cx, cz, biome, seed); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java index 13d159913..e8af94c69 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java @@ -303,7 +303,7 @@ public final class EditSessionBuilder { */ public EditSessionBuilder changeSet(boolean disk, @Nullable UUID uuid) { if (disk) { - if (Settings.IMP.HISTORY.USE_DATABASE) { + if (Settings.settings().HISTORY.USE_DATABASE) { this.changeSet = new RollbackOptimizedHistory(world, uuid); } else { this.changeSet = new DiskStorageHistory(world, uuid); @@ -437,7 +437,7 @@ public final class EditSessionBuilder { } if (fastMode == null) { if (actor == null) { - fastMode = !Settings.IMP.HISTORY.ENABLE_FOR_CONSOLE; + fastMode = !Settings.settings().HISTORY.ENABLE_FOR_CONSOLE; } else { fastMode = actor.getSession().hasFastMode(); } @@ -466,12 +466,12 @@ public final class EditSessionBuilder { wnaMode = false; if (unwrapped instanceof IQueueExtent) { extent = queue = (IQueueExtent) unwrapped; - } else if (Settings.IMP.QUEUE.PARALLEL_THREADS > 1 && !Fawe.isMainThread()) { - ParallelQueueExtent parallel = new ParallelQueueExtent(Fawe.get().getQueueHandler(), world, fastMode); + } else if (Settings.settings().QUEUE.PARALLEL_THREADS > 1 && !Fawe.isMainThread()) { + ParallelQueueExtent parallel = new ParallelQueueExtent(Fawe.instance().getQueueHandler(), world, fastMode); queue = parallel.getExtent(); extent = parallel; } else { - extent = queue = Fawe.get().getQueueHandler().getQueue(world); + extent = queue = Fawe.instance().getQueueHandler().getQueue(world); } } else { wnaMode = true; @@ -480,7 +480,7 @@ public final class EditSessionBuilder { if (combineStages == null) { combineStages = // If it's enabled in the settings - Settings.IMP.HISTORY.COMBINE_STAGES + Settings.settings().HISTORY.COMBINE_STAGES // If fast placement is disabled, it's slower to perform a copy on each chunk && this.limit.FAST_PLACEMENT // If the edit uses items from the inventory we can't use a delayed task @@ -490,17 +490,17 @@ public final class EditSessionBuilder { this.bypassHistory = this.extent = wrapExtent(bypassAll, eventBus, event, EditSession.Stage.BEFORE_REORDER); if (!this.fastMode || changeSet != null) { if (changeSet == null) { - if (Settings.IMP.HISTORY.USE_DISK) { + if (Settings.settings().HISTORY.USE_DISK) { UUID uuid = actor == null ? Identifiable.CONSOLE : actor.getUniqueId(); - if (Settings.IMP.HISTORY.USE_DATABASE) { + if (Settings.settings().HISTORY.USE_DATABASE) { changeSet = new RollbackOptimizedHistory(world, uuid); } else { changeSet = new DiskStorageHistory(world, uuid); } -// } else if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0) { +// } else if (combineStages && Settings.settings().HISTORY.COMPRESSION_LEVEL == 0) { // changeSet = new CPUOptimizedChangeSet(world); } else { - if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0) { + if (combineStages && Settings.settings().HISTORY.COMPRESSION_LEVEL == 0) { //TODO add CPUOptimizedChangeSet } changeSet = new MemoryOptimizedHistory(world); @@ -528,7 +528,7 @@ public final class EditSessionBuilder { } } } - if (allowedRegions == null && Settings.IMP.REGION_RESTRICTIONS) { + if (allowedRegions == null && Settings.settings().REGION_RESTRICTIONS) { if (actor != null && !actor.hasPermission("fawe.bypass") && !actor.hasPermission("fawe.bypass.regions")) { if (actor instanceof Player) { Player player = (Player) actor; @@ -536,7 +536,7 @@ public final class EditSessionBuilder { } } } - if (disallowedRegions == null && Settings.IMP.REGION_RESTRICTIONS && Settings.IMP.REGION_RESTRICTIONS_OPTIONS.ALLOW_BLACKLISTS) { + if (disallowedRegions == null && Settings.settings().REGION_RESTRICTIONS && Settings.settings().REGION_RESTRICTIONS_OPTIONS.ALLOW_BLACKLISTS) { if (actor != null && !actor.hasPermission("fawe.bypass") && !actor.hasPermission("fawe.bypass.regions")) { if (actor instanceof Player) { Player player = (Player) actor; @@ -562,7 +562,7 @@ public final class EditSessionBuilder { } // There's no need to do lighting (and it'll also just be a pain to implement) if we're not placing chunks if (placeChunks) { - if (((relightMode != null && relightMode != RelightMode.NONE) || (relightMode == null && Settings.IMP.LIGHTING.MODE > 0))) { + if (((relightMode != null && relightMode != RelightMode.NONE) || (relightMode == null && Settings.settings().LIGHTING.MODE > 0))) { relighter = WorldEdit.getInstance().getPlatformManager() .queryCapability(Capability.WORLD_EDITING) .getRelighterFactory().createRelighter(relightMode, world, queue); @@ -704,13 +704,13 @@ public final class EditSessionBuilder { } if (toReturn != extent) { String className = toReturn.getClass().getName().toLowerCase(Locale.ROOT); - for (String allowed : Settings.IMP.EXTENT.ALLOWED_PLUGINS) { + for (String allowed : Settings.settings().EXTENT.ALLOWED_PLUGINS) { if (className.contains(allowed.toLowerCase(Locale.ROOT))) { this.wrapped = true; return toReturn; } } - if (Settings.IMP.EXTENT.DEBUG) { + if (Settings.settings().EXTENT.DEBUG) { if (event.getActor() != null) { event.getActor().printDebug(TextComponent.of("Potentially unsafe extent blocked: " + toReturn .getClass() diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 2fd81d469..236ea7403 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -225,7 +225,7 @@ public class LocalSession implements TextureHolder { if (world == null || uuid == null) { return false; } - if (Settings.IMP.HISTORY.USE_DISK) { + if (Settings.settings().HISTORY.USE_DISK) { MAX_HISTORY_SIZE = Integer.MAX_VALUE; } world = WorldWrapper.unwrap(world); @@ -248,8 +248,8 @@ public class LocalSession implements TextureHolder { private boolean loadHistoryChangeSets(UUID uuid, World world) { SparseBitSet set = new SparseBitSet(); final File folder = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid ); if (folder.isDirectory()) { folder.listFiles(pathname -> { @@ -282,12 +282,12 @@ public class LocalSession implements TextureHolder { } private void loadHistoryNegativeIndex(UUID uuid, World world) { - if (!Settings.IMP.HISTORY.USE_DISK) { + if (!Settings.settings().HISTORY.USE_DISK) { return; } File file = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index" + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index" ); if (file.exists()) { try (FaweInputStream is = new FaweInputStream(new FileInputStream(file))) { @@ -301,12 +301,12 @@ public class LocalSession implements TextureHolder { } private void saveHistoryNegativeIndex(UUID uuid, World world) { - if (world == null || !Settings.IMP.HISTORY.USE_DISK) { + if (world == null || !Settings.settings().HISTORY.USE_DISK) { return; } File file = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index" + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index" ); if (getHistoryNegativeIndex() != 0) { try { @@ -450,8 +450,8 @@ public class LocalSession implements TextureHolder { } if (o instanceof Integer) { File folder = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HISTORY + File.separator + currentWorld.getName() + File.separator + uuid + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HISTORY + File.separator + currentWorld.getName() + File.separator + uuid ); File specific = new File(folder, o.toString()); if (specific.isDirectory()) { @@ -467,7 +467,7 @@ public class LocalSession implements TextureHolder { public void remember(Identifiable player, World world, ChangeSet changeSet, FaweLimit limit) { historyWriteLock.lock(); try { - if (Settings.IMP.HISTORY.USE_DISK) { + if (Settings.settings().HISTORY.USE_DISK) { LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE; } if (changeSet.size() == 0) { @@ -500,7 +500,7 @@ public class LocalSession implements TextureHolder { } if (limit != null) { int limitMb = limit.MAX_HISTORY; - while (((!Settings.IMP.HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history + while (((!Settings.settings().HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history .size() > 1) { ChangeSet item = (ChangeSet) history.remove(0); item.delete(); @@ -516,7 +516,7 @@ public class LocalSession implements TextureHolder { public void remember(EditSession editSession, boolean append, int limitMb) { historyWriteLock.lock(); try { - if (Settings.IMP.HISTORY.USE_DISK) { + if (Settings.settings().HISTORY.USE_DISK) { LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE; } // It should have already been flushed, but just in case! @@ -564,7 +564,7 @@ public class LocalSession implements TextureHolder { } else { history.add(0, changeSet); } - while (((!Settings.IMP.HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history + while (((!Settings.settings().HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history .size() > 1) { ChangeSet item = (ChangeSet) history.remove(0); item.delete(); @@ -1146,7 +1146,7 @@ public class LocalSession implements TextureHolder { @Nullable public Tool getTool(Player player) { loadDefaults(player, false); - if (!Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && tools.isEmpty()) { + if (!Settings.settings().EXPERIMENTAL.PERSISTENT_BRUSHES && tools.isEmpty()) { return null; } BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); @@ -1157,7 +1157,7 @@ public class LocalSession implements TextureHolder { public Tool getTool(BaseItem item, Player player) { loadDefaults(player, false); - if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) { + if (Settings.settings().EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) { BrushTool tool = BrushCache.getTool(player, this, item); if (tool != null) { return tool; @@ -1303,7 +1303,7 @@ public class LocalSession implements TextureHolder { } Tool previous; - if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) { + if (player != null && (tool instanceof BrushTool || tool == null) && Settings.settings().EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) { previous = BrushCache.getCachedTool(item); BrushCache.setTool(item, (BrushTool) tool); if (tool != null) { @@ -1782,7 +1782,7 @@ public class LocalSession implements TextureHolder { TextureUtil tmp = texture; if (tmp == null) { synchronized (this) { - tmp = Fawe.get().getCachedTextureUtil(true, 0, 100); + tmp = Fawe.instance().getCachedTextureUtil(true, 0, 100); this.texture = tmp; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index b115afbca..77cb921cc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -860,8 +860,8 @@ public class BrushCommands { } String filenamePng = filename.endsWith(".png") ? filename : filename + ".png"; File file = new File( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.HEIGHTMAP + File.separator + filenamePng + Fawe.platform().getDirectory(), + Settings.settings().PATHS.HEIGHTMAP + File.separator + filenamePng ); if (file.exists()) { return new FileInputStream(file); @@ -936,7 +936,7 @@ public class BrushCommands { if (tool != null) { root |= name.startsWith("../"); name = FileSystems.getDefault().getPath(name).getFileName().toString(); - File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes"); + File folder = MainUtil.getFile(Fawe.platform().getDirectory(), "brushes"); name = name.endsWith(".jsgz") ? name : name + ".jsgz"; File file; if (root && player.hasPermission("worldedit.brush.save.other")) { @@ -971,7 +971,7 @@ public class BrushCommands { public void loadBrush(Player player, LocalSession session, @Arg(desc = "String name") String name) throws WorldEditException, IOException { name = FileSystems.getDefault().getPath(name).getFileName().toString(); - File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes"); + File folder = MainUtil.getFile(Fawe.platform().getDirectory(), "brushes"); name = name.endsWith(".jsgz") ? name : name + ".jsgz"; File file = new File(folder, player.getUniqueId() + File.separator + name); if (!file.exists()) { @@ -1006,7 +1006,7 @@ public class BrushCommands { int page ) throws WorldEditException { String baseCmd = "/brush loadbrush"; - File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes"); + File dir = MainUtil.getFile(Fawe.platform().getDirectory(), "brushes"); // TODO NOT IMPLEMENTED // UtilityCommands.list(dir, actor, args, page, null, true, baseCmd); } @@ -1310,7 +1310,7 @@ public class BrushCommands { worldEdit.checkMaxBrushRadius(radius); //FAWE start - FaweLimit limit = Settings.IMP.getLimit(player); + FaweLimit limit = Settings.settings().getLimit(player); iterations = Math.min(limit.MAX_ITERATIONS, iterations); //FAWE end @@ -1345,7 +1345,7 @@ public class BrushCommands { worldEdit.checkMaxBrushRadius(radius); //FAWE start - FaweLimit limit = Settings.IMP.getLimit(player); + FaweLimit limit = Settings.settings().getLimit(player); iterations = Math.min(limit.MAX_ITERATIONS, iterations); //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 61c220f68..f3a24ed9c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -405,7 +405,7 @@ public class ClipboardCommands { url = null; } } else { - if (Settings.IMP.WEB.URL.isEmpty()) { + if (Settings.settings().WEB.URL.isEmpty()) { actor.print(Caption.of("fawe.error.setting.disable", "web.url")); return; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index c7bcc7e65..3d54e40a7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -475,7 +475,7 @@ public class GeneralCommands { String arg = arguments.get(0); String argLower = arg.toLowerCase(Locale.ROOT); - TextureUtil util = Fawe.get().getTextureUtil(); + TextureUtil util = Fawe.instance().getTextureUtil(); int randomIndex = 1; boolean checkRandomization = true; if (arguments.size() >= 2 && MathMan.isInteger(arguments.get(0)) && MathMan.isInteger(arguments.get(1))) { @@ -500,7 +500,7 @@ public class GeneralCommands { Clipboard clipboard = session.getClipboard().getClipboard(); util = TextureUtil.fromClipboard(clipboard); } else if (argLower.equals("*") || argLower.equals("true")) { - util = Fawe.get().getTextureUtil(); + util = Fawe.instance().getTextureUtil(); } else { ParserContext parserContext = new ParserContext(); parserContext.setActor(actor); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index d63f26e52..b34e7860f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -582,7 +582,7 @@ public class GenerationCommands { @Arg(desc = "TODO", def = "100") int threshold, @Arg(desc = "BlockVector2", def = "") BlockVector2 dimensions ) throws WorldEditException, IOException { - TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold); + TextureUtil tu = Fawe.instance().getCachedTextureUtil(randomize, 0, threshold); URL url = new URL(imageURL); if (!url.getHost().equalsIgnoreCase("i.imgur.com")) { throw new IOException("Only i.imgur.com links are allowed!"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java index 1d97c13d2..3688041d4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java @@ -114,7 +114,7 @@ public class HistorySubCommands { @Switch(name = 'f', desc = "Restore instead of rollback") boolean restore ) throws WorldEditException { - if (!Settings.IMP.HISTORY.USE_DATABASE) { + if (!Settings.settings().HISTORY.USE_DATABASE) { player.print(Caption.of("fawe.error.setting.disable", "history.use-database (Import with /history import )")); return; } @@ -168,7 +168,7 @@ public class HistorySubCommands { @CommandPermissions("fawe.rollback.import") @Confirm public synchronized void importdb(Actor actor) throws WorldEditException { - File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY); + File folder = MainUtil.getFile(Fawe.platform().getDirectory(), Settings.settings().PATHS.HISTORY); if (folder.exists()) { for (File worldFolder : Objects.requireNonNull(folder.listFiles())) { if (worldFolder != null && worldFolder.isDirectory()) { @@ -238,7 +238,7 @@ public class HistorySubCommands { } Location origin = player.getLocation(); - String name = Fawe.imp().getName(edit.getUUID()); + String name = Fawe.platform().getName(edit.getUUID()); String cmd = edit.getCommand(); BlockVector3 pos1 = edit.getMinimumPoint(); BlockVector3 pos2 = edit.getMaximumPoint(); @@ -319,7 +319,7 @@ public class HistorySubCommands { UUID uuid = rollback.getUUID(); int index = rollback.getIndex(); - String name = Fawe.imp().getName(rollback.getUUID()); + String name = Fawe.platform().getName(rollback.getUUID()); String cmd = rollback.getCommand(); BlockVector3 pos1 = rollback.getMinimumPoint(); @@ -382,7 +382,7 @@ public class HistorySubCommands { @ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page ) throws WorldEditException { - if (!Settings.IMP.HISTORY.USE_DATABASE) { + if (!Settings.settings().HISTORY.USE_DATABASE) { player.print(Caption.of("fawe.error.setting.disable", "history.use-database (Import with //history import )")); return; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 6e7f5f4fd..4065c56ad 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -203,7 +203,7 @@ public class SchematicCommands { } else { final LocalConfiguration config = this.worldEdit.getConfiguration(); File working = this.worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); - File root = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; + File root = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; uri = new File(root, fileName).toURI(); } @@ -238,13 +238,13 @@ public class SchematicCommands { IOException { LocalConfiguration config = worldEdit.getConfiguration(); File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); - File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; + File dir = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; File destDir = new File(dir, directory); if (!MainUtil.isInSubDirectory(working, destDir)) { actor.print(Caption.of("worldedit.schematic.directory-does-not-exist", TextComponent.of(String.valueOf(destDir)))); return; } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !actor.hasPermission( + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !actor.hasPermission( "worldedit.schematic.move.other")) { actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.move.other")); return; @@ -265,7 +265,7 @@ public class SchematicCommands { actor.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists", destFile)); continue; } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory( + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory( dir, destFile ) || !MainUtil.isInSubDirectory(dir, source)) && !actor.hasPermission("worldedit.schematic.delete.other")) { @@ -333,7 +333,7 @@ public class SchematicCommands { return; } UUID uuid = UUID.fromString(filename.substring(4)); - URL webUrl = new URL(Settings.IMP.WEB.URL); + URL webUrl = new URL(Settings.settings().WEB.URL); format = ClipboardFormats.findByAlias(formatName); URL url = new URL(webUrl, "uploads/" + uuid + "." + format.getPrimaryFileExtension()); ReadableByteChannel byteChannel = Channels.newChannel(url.openStream()); @@ -341,7 +341,7 @@ public class SchematicCommands { uri = url.toURI(); } else { File saveDir = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); - File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, actor.getUniqueId().toString()) : saveDir; + File dir = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, actor.getUniqueId().toString()) : saveDir; File file; if (filename.startsWith("#")) { format = ClipboardFormats.findByAlias(formatName); @@ -357,7 +357,7 @@ public class SchematicCommands { return; } } else { - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern .compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}") .matcher(filename) .find()) { @@ -446,7 +446,7 @@ public class SchematicCommands { File dir = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); //FAWE start - if (!global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) { + if (!global && Settings.settings().PATHS.PER_PLAYER_SCHEMATICS) { dir = new File(dir, actor.getUniqueId().toString()); } @@ -580,7 +580,7 @@ public class SchematicCommands { final boolean hasShow = false; //If player forgot -p argument - boolean playerFolder = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS; + boolean playerFolder = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS; UUID uuid = playerFolder ? actor.getUniqueId() : null; List files = UtilityCommands.getFiles(dir, actor, args, formatName, playerFolder, oldFirst, newFirst); List> entries = UtilityCommands.filesToEntry(dir, files, uuid); @@ -670,14 +670,14 @@ public class SchematicCommands { String headerBytesElem = String.format("%.1fkb", totalBytes / 1000.0); - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1) { + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1) { headerBytesElem += String.format( " / %dkb", - Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT + Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT ); } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) { + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS) { String fullHeader = "| My Schematics: " + headerBytesElem + " |"; PaginationBox paginationBox = PaginationBox.fromComponents(fullHeader, pageCommand, components); actor.print(paginationBox.create(page)); @@ -704,7 +704,7 @@ public class SchematicCommands { LocalConfiguration config = worldEdit.getConfiguration(); File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); //FAWE start - File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; + File dir = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; List files = new ArrayList<>(); if (filename.equalsIgnoreCase("*")) { @@ -723,7 +723,7 @@ public class SchematicCommands { actor.print(Caption.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename))); continue; } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission( + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission( "worldedit.schematic.delete.other")) { actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.delete.other")); continue; @@ -806,8 +806,8 @@ public class SchematicCommands { Clipboard target; //FAWE start - boolean checkFilesize = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS - && Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1; + boolean checkFilesize = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS + && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1; double directorysizeKb = 0; String curFilepath = file.getAbsolutePath(); @@ -838,7 +838,7 @@ public class SchematicCommands { } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) { + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) { if (numFiles == -1) { numFiles = 0; @@ -851,7 +851,7 @@ public class SchematicCommands { } } } - int limit = Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT; + int limit = Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT; if (numFiles >= limit) { TextComponent noSlotsErr = TextComponent.of( //TODO - to be moved into captions/translatablecomponents @@ -902,7 +902,7 @@ public class SchematicCommands { if (checkFilesize) { double curKb = filesizeKb + directorysizeKb; - int allocatedKb = Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT; + int allocatedKb = Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT; if (overwrite) { curKb -= oldKbOverwritten; @@ -937,11 +937,11 @@ public class SchematicCommands { actor.print(kbRemainingNotif); } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) { + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) { TextComponent slotsRemainingNotif = TextComponent.of( //TODO - to be moved into captions/translatablecomponents - "You have " + (Settings.IMP.EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT - numFiles) + "You have " + (Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT - numFiles) + " schematic file slots left.", TextColor.GRAY ); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 4dbbc29dc..9a7de94a4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -135,9 +135,9 @@ public class UtilityCommands { @Arg(name = "max", desc = "int", def = "200") int max ) throws IOException { actor.print(TextComponent.of("Please wait while we generate the minified heightmaps.")); - File srcFolder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP); + File srcFolder = MainUtil.getFile(Fawe.platform().getDirectory(), Settings.settings().PATHS.HEIGHTMAP); - File webSrc = new File(Fawe.imp().getDirectory(), "web" + File.separator + "heightmap"); + File webSrc = new File(Fawe.platform().getDirectory(), "web" + File.separator + "heightmap"); File minImages = new File(webSrc, "images" + File.separator + "min"); File maxImages = new File(webSrc, "images" + File.separator + "max"); final int sub = srcFolder.getAbsolutePath().length(); @@ -698,7 +698,7 @@ public class UtilityCommands { //FAWE start - run this sync int finalRadius = radius; - int killed = TaskManager.IMP.sync(() -> killMatchingEntities(finalRadius, actor, flags::createFunction)); + int killed = TaskManager.taskManager().sync(() -> killMatchingEntities(finalRadius, actor, flags::createFunction)); //FAWE end actor.print(Caption.of( @@ -730,7 +730,7 @@ public class UtilityCommands { } //FAWE start - run this sync - int removed = TaskManager.IMP.sync(() -> killMatchingEntities(radius, actor, remover::createFunction)); + int removed = TaskManager.taskManager().sync(() -> killMatchingEntities(radius, actor, remover::createFunction)); //FAWE end actor.print(Caption.of("worldedit.remove.removed", TextComponent.of(removed))); return removed; @@ -953,7 +953,7 @@ public class UtilityCommands { String dirFilter = File.separator; boolean listMine = false; - boolean listGlobal = !Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS; + boolean listGlobal = !Settings.settings().PATHS.PER_PLAYER_SCHEMATICS; if (len > 0) { for (String arg : args) { switch (arg.toLowerCase(Locale.ROOT)) { @@ -982,7 +982,7 @@ public class UtilityCommands { if (!exists) { arg = arg.substring(0, arg.length() - File.separator.length()); if (arg.length() > 3 && arg.length() <= 16) { - UUID fromName = Fawe.imp().getUUID(arg); + UUID fromName = Fawe.platform().getUUID(arg); if (fromName != null) { newDirFilter = dirFilter + fromName + File.separator; listGlobal = true; @@ -1103,7 +1103,7 @@ public class UtilityCommands { if (newList.isEmpty()) { String checkName = filter.replace("\\", "/").split("/")[0]; if (checkName.length() > 3 && checkName.length() <= 16) { - UUID fromName = Fawe.imp().getUUID(checkName); + UUID fromName = Fawe.platform().getUUID(checkName); if (fromName != null) { lowerFilter = filter.replaceFirst(checkName, fromName.toString()).toLowerCase(Locale.ROOT); for (int i = 0; i < normalizedNames.length; i++) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index c145fa61f..4a5883b90 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -81,7 +81,7 @@ public class WorldEditCommands { @CommandPermissions(queued = false) public void version(Actor actor) { //FAWE start - use own, minimized message that doesn't print "Platforms" and "Capabilities" - FaweVersion fVer = Fawe.get().getVersion(); + FaweVersion fVer = Fawe.instance().getVersion(); String fVerStr = fVer == null ? "unknown" : "-" + fVer.build; actor.print(TextComponent.of("FastAsyncWorldEdit" + fVerStr)); actor.print(TextComponent.of("Authors: Empire92, MattBDev, IronApollo, dordsor21 and NotMyFault")); @@ -105,7 +105,7 @@ public class WorldEditCommands { .queryCapability(Capability.CONFIGURATION) .getConfiguration())); //FAWE start - Fawe.get().setupConfigs(); + Fawe.instance().setupConfigs(); //FAWE end actor.print(Caption.of("worldedit.reload.config")); } @@ -120,9 +120,9 @@ public class WorldEditCommands { String dest; try { final File logFile = new File("logs/latest.log"); - final File config = new File(Fawe.imp().getDirectory(), "config.yml"); - final File worldeditConfig = new File(Fawe.imp().getDirectory(), "worldedit-config.yml"); - dest = IncendoPaster.debugPaste(logFile, Fawe.imp().getDebugInfo(), config, worldeditConfig); + final File config = new File(Fawe.platform().getDirectory(), "config.yml"); + final File worldeditConfig = new File(Fawe.platform().getDirectory(), "worldedit-config.yml"); + dest = IncendoPaster.debugPaste(logFile, Fawe.platform().getDebugInfo(), config, worldeditConfig); } catch (IOException e) { actor.printInfo(TextComponent.of(e.getMessage())); return; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java index f1e8c2e04..79bd7be24 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java @@ -56,7 +56,7 @@ public enum SelectionWand implements DoubleActionBlockTool { if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) { //FAWE start - if (Settings.IMP.EXPERIMENTAL.OTHER) { + if (Settings.settings().EXPERIMENTAL.OTHER) { LOGGER.info("actSecondary Hit and about to explain with explainPrimarySelection"); } //FAWE end @@ -79,7 +79,7 @@ public enum SelectionWand implements DoubleActionBlockTool { if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) { //FAWE start - if (Settings.IMP.EXPERIMENTAL.OTHER) { + if (Settings.settings().EXPERIMENTAL.OTHER) { LOGGER.info("actPrimary Hit and about to explain with explainSecondarySelection"); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java index 023b33672..f2310a211 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java @@ -148,7 +148,7 @@ public class EntityRemover { if (registryType != null) { if (type.matches(registryType)) { //FAWE start - Calling this async violates thread safety - TaskManager.IMP.sync(entity::remove); + TaskManager.taskManager().sync(entity::remove); //FAWE end return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java index eeb5989f2..5bf1ccc6c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/ConfirmHandler.java @@ -29,7 +29,7 @@ public class ConfirmHandler implements CommandCallListener { } Actor actor = actorOpt.get(); // don't check confirmation if actor doesn't need to confirm - if (!Settings.IMP.getLimit(actor).CONFIRM_LARGE) { + if (!Settings.settings().getLimit(actor).CONFIRM_LARGE) { return; } if (!confirmAnnotation.value().passes(actor, parameters, 1)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Preload.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Preload.java index 3c1104321..ae05397bd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Preload.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Preload.java @@ -32,7 +32,7 @@ public @interface Preload { @Override public void preload(Actor actor, InjectedValueAccess context) { World world = context.injectedValue(Key.of(EditSession.class)).get().getWorld(); - Preloader preloader = Fawe.imp().getPreloader(true); + Preloader preloader = Fawe.platform().getPreloader(true); if (preloader != null) { preloader.update(actor, world); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java index 034101537..9e1dc106f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/PreloadHandler.java @@ -29,7 +29,7 @@ public class PreloadHandler implements CommandCallListener { } Actor actor = actorOpt.get(); // Don't attempt to preload if effectively disabled - if (Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT <= 1) { + if (Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT <= 1) { return; } preloadAnnotation.value().preload(actor, parameters); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index 5d4206c71..b6c39a34c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -425,7 +425,7 @@ public interface Player extends Entity, Actor { default void unregister() { cancel(true); LocalSession session = getSession(); - if (Settings.IMP.CLIPBOARD.USE_DISK && Settings.IMP.CLIPBOARD.DELETE_ON_LOGOUT) { + if (Settings.settings().CLIPBOARD.USE_DISK && Settings.settings().CLIPBOARD.DELETE_ON_LOGOUT) { ClipboardHolder holder = session.getExistingClipboard(); if (holder != null) { for (Clipboard clipboard : holder.getClipboards()) { @@ -441,10 +441,10 @@ public interface Player extends Entity, Actor { doc.getFile().delete(); } } - } else if (Settings.IMP.CLIPBOARD.DELETE_ON_LOGOUT || Settings.IMP.CLIPBOARD.USE_DISK) { + } else if (Settings.settings().CLIPBOARD.DELETE_ON_LOGOUT || Settings.settings().CLIPBOARD.USE_DISK) { session.setClipboard(null); } - if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) { + if (Settings.settings().HISTORY.DELETE_ON_LOGOUT) { session.clearHistory(); } } @@ -456,8 +456,8 @@ public interface Player extends Entity, Actor { */ default void loadClipboardFromDisk() { File file = MainUtil.getFile( - Fawe.imp().getDirectory(), - Settings.IMP.PATHS.CLIPBOARD + File.separator + getUniqueId() + ".bd" + Fawe.platform().getDirectory(), + Settings.settings().PATHS.CLIPBOARD + File.separator + getUniqueId() + ".bd" ); try { if (file.exists() && file.length() > 5) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java index 1edad0ba1..0b8909198 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java @@ -110,7 +110,7 @@ public abstract class AbstractNonPlayerActor implements Actor { if (async) { asyncNotifyQueue.run(wrapped); } else { - TaskManager.IMP.taskNow(wrapped, false); + TaskManager.taskManager().taskNow(wrapped, false); } return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 87d137283..d02819dc6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -491,7 +491,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public Region[] getAllowedRegions(FaweMaskManager.MaskType type) { - return WEManager.IMP.getMask(this, type, true); + return WEManager.weManager().getMask(this, type, true); } @Override @@ -501,7 +501,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public Region[] getDisallowedRegions(FaweMaskManager.MaskType type) { - return WEManager.IMP.getMask(this, type, false); + return WEManager.weManager().getMask(this, type, false); } @Override @@ -677,7 +677,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (async) { asyncNotifyQueue.run(wrapped); } else { - TaskManager.IMP.taskNow(wrapped, false); + TaskManager.taskManager().taskNow(wrapped, false); } return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index 1f938ea82..a2871270b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -220,13 +220,13 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab default boolean checkAction() { long time = getMeta("faweActionTick", Long.MIN_VALUE); - long tick = Fawe.get().getTimer().getTick(); + long tick = Fawe.instance().getTimer().getTick(); setMeta("faweActionTick", tick); return tick > time; } default FaweLimit getLimit() { - return Settings.IMP.getLimit(this); + return Settings.settings().getLimit(this); } default boolean runAsyncIfFree(Runnable r) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 626703203..4c23e353d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -434,7 +434,7 @@ public final class PlatformCommandManager { public void registerAllCommands() { //FAWE start - if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) { + if (Settings.settings().ENABLED_COMPONENTS.COMMANDS) { // TODO: Ping @MattBDev to reimplement (or remove) 2020-02-04 // registerSubCommands( // "patterns", @@ -674,7 +674,7 @@ public final class PlatformCommandManager { Actor actor = event.getActor(); String args = event.getArguments(); - TaskManager.IMP.taskNow(() -> { + TaskManager.taskManager().taskNow(() -> { if (!Fawe.isMainThread()) { Thread.currentThread().setName("FAWE Thread for player: " + actor.getName()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index a29903a6d..d3944a153 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -244,7 +244,7 @@ public class AbstractDelegateExtent implements Extent { @Override public Extent addProcessor(IBatchProcessor processor) { - if (Settings.IMP.EXPERIMENTAL.OTHER) { + if (Settings.settings().EXPERIMENTAL.OTHER) { LOGGER.info("addProcessor Info: \t " + processor.getClass().getName()); LOGGER.info("The following is not an error or a crash:"); StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); @@ -262,7 +262,7 @@ public class AbstractDelegateExtent implements Extent { @Override public Extent addPostProcessor(IBatchProcessor processor) { - if (Settings.IMP.EXPERIMENTAL.OTHER) { + if (Settings.settings().EXPERIMENTAL.OTHER) { LOGGER.info("addPostProcessor Info: \t " + processor.getClass().getName()); LOGGER.info("The following is not an error or a crash:"); StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 9d4fa8dfd..334ab4da4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -870,7 +870,7 @@ public interface Extent extends InputExtent, OutputExtent { } default Extent enableHistory(AbstractChangeSet changeSet) { - if (Settings.IMP.HISTORY.SEND_BEFORE_HISTORY) { + if (Settings.settings().HISTORY.SEND_BEFORE_HISTORY) { return addPostProcessor(changeSet); } else { return addProcessor(changeSet); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 345ff978f..c28f4a07a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -62,7 +62,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce checkNotNull(mask); this.mask = mask; //FAWE start - this.threadIdToFilter = FaweCache.IMP.createCache(() -> new CharFilterBlock(getExtent())); + this.threadIdToFilter = FaweCache.INSTANCE.createCache(() -> new CharFilterBlock(getExtent())); //FAWE end } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index 241425a8e..e65f9d634 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -86,9 +86,9 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl } static Clipboard create(Region region, UUID uuid) { - if (Settings.IMP.CLIPBOARD.USE_DISK) { + if (Settings.settings().CLIPBOARD.USE_DISK) { return new DiskOptimizedClipboard(region, uuid); - } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) { + } else if (Settings.settings().CLIPBOARD.COMPRESSION_LEVEL == 0) { return new CPUOptimizedClipboard(region); } else { return new MemoryOptimizedClipboard(region); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java index 70e6d4161..b00c9ea5b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java @@ -187,21 +187,21 @@ public class ClipboardFormats { } return null; } - URL base = new URL(Settings.IMP.WEB.URL); + URL base = new URL(Settings.settings().WEB.URL); input = new URL(base, "uploads/" + input.substring(4) + "." + format.getPrimaryFileExtension()).toString(); } if (input.startsWith("http")) { return null; } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other")); return null; } File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); - File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS + File dir = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working; File f; if (input.startsWith("#")) { @@ -219,7 +219,7 @@ public class ClipboardFormats { return null; } } else { - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { if (message) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java index 7a379d622..2a10e9f4b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java @@ -120,7 +120,7 @@ public class SpongeSchematicWriter implements ClipboardWriter { metadata.put("WEOffsetX", new IntTag(offset.getBlockX())); metadata.put("WEOffsetY", new IntTag(offset.getBlockY())); metadata.put("WEOffsetZ", new IntTag(offset.getBlockZ())); - metadata.put("FAWEVersion", new IntTag(Fawe.get().getVersion().build)); + metadata.put("FAWEVersion", new IntTag(Fawe.instance().getVersion().build)); schematic.put("Metadata", new CompoundTag(metadata)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 674ac46e6..8382319c9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -438,7 +438,7 @@ public class BlockTransformExtent extends ResettableExtent { if (directions != null) { int oldIndex = property.getIndex(state.getInternalId()); if (oldIndex >= directions.length) { - if (Settings.IMP.ENABLED_COMPONENTS.DEBUG) { + if (Settings.settings().ENABLED_COMPONENTS.DEBUG) { LOGGER.warn(String.format( "Index outside direction array length found for block:{%s} property:{%s}", state.getBlockType().getId(), diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java index c061b0b35..88cf4fc6f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java @@ -99,7 +99,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent { Collection drops = world.getBlockDrops(location); boolean canSet = super.setBlock(location, block); if (canSet) { - TaskManager.IMP.sync(new RunnableVal<>() { + TaskManager.taskManager().sync(new RunnableVal<>() { @Override public void run(Object value) { for (BaseItemStack stack : drops) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index 7966f1217..8decb381a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -290,13 +290,13 @@ public abstract class BreadthFirstSearch implements Operation { BlockVectorSet chunkLoadSet = new BlockVectorSet(); for (currentDepth = 0; !queue.isEmpty() && currentDepth <= maxDepth; currentDepth++) { int loadCount = 0; - if (singleQueue != null && Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT > 1) { + if (singleQueue != null && Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT > 1) { int cx = Integer.MIN_VALUE; int cz = Integer.MIN_VALUE; outer: for (BlockVector3 from : queue) { for (BlockVector3 direction : dirs) { - if (loadCount > Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT) { + if (loadCount > Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT) { break outer; } int x = from.getBlockX() + direction.getBlockX(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java index c12c793ef..ff6b67e03 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java @@ -93,7 +93,7 @@ public class RegionVisitor implements Operation { @Override public Operation resume(RunContext run) throws WorldEditException { //FAWE start > allow chunk preloading - if (singleQueue != null && Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT > 1) { + if (singleQueue != null && Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT > 1) { /* * The following is done to reduce iteration cost * - Preload chunks just in time @@ -107,7 +107,7 @@ public class RegionVisitor implements Operation { int lastTrailChunkZ = Integer.MIN_VALUE; int lastLeadChunkX = Integer.MIN_VALUE; int lastLeadChunkZ = Integer.MIN_VALUE; - int loadingTarget = Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT; + int loadingTarget = Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT; while (trailIter.hasNext()) { BlockVector3 pt = trailIter.next(); apply(pt); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 4cf937ac4..82e89aee7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -467,7 +467,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public Iterator iterator() { //FAWE start - if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9) { + if (Settings.settings().HISTORY.COMPRESSION_LEVEL >= 9) { return iterator_old(); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index 10e2f45f5..8515b8952 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -430,7 +430,7 @@ public interface Region extends Iterable, Cloneable, IBatchProcess int by = layer << 4; int ty = by + 15; if (containsEntireCuboid(bx, tx, by, ty, bz, tz)) { - set.setBlocks(layer, FaweCache.IMP.EMPTY_CHAR_4096); + set.setBlocks(layer, FaweCache.INSTANCE.EMPTY_CHAR_4096); processExtra = true; continue; }