From b17edbe3573c05ec802e09630539ae4869264fff Mon Sep 17 00:00:00 2001 From: david Date: Thu, 26 Dec 2024 18:01:15 +0100 Subject: [PATCH] Remove Lombok and refactor constructors. Replaced Lombok annotations with explicit constructors throughout the codebase. Updated usages of `@Getter` and `@RequiredArgsConstructor` to improve clarity and remove dependency on Lombok. Also refined Gradle dependencies by removing unused Lombok references. --- api/build.gradle.kts | 3 - .../worlds/api/event/WorldDeleteEvent.java | 9 +- .../api/exception/GeneratorException.java | 27 +++- .../thenextlvl/worlds/api/link/Relative.java | 15 +- .../thenextlvl/worlds/api/preset/Preset.java | 130 ++++++++++++++++-- build.gradle.kts | 4 - .../net/thenextlvl/worlds/WorldsPlugin.java | 51 ++++--- .../worlds/command/WorldCloneCommand.java | 6 +- .../worlds/command/WorldCommand.java | 6 +- .../worlds/command/WorldCreateCommand.java | 6 +- .../worlds/command/WorldDeleteCommand.java | 6 +- .../worlds/command/WorldImportCommand.java | 6 +- .../worlds/command/WorldInfoCommand.java | 6 +- .../worlds/command/WorldLinkCommand.java | 6 +- .../command/WorldLinkCreateCommand.java | 8 +- .../worlds/command/WorldLinkListCommand.java | 8 +- .../command/WorldLinkRemoveCommand.java | 8 +- .../worlds/command/WorldListCommand.java | 6 +- .../worlds/command/WorldLoadCommand.java | 6 +- .../command/WorldRegenerateCommand.java | 6 +- .../worlds/command/WorldSaveAllCommand.java | 6 +- .../worlds/command/WorldSaveCommand.java | 6 +- .../worlds/command/WorldSaveOffCommand.java | 6 +- .../worlds/command/WorldSaveOnCommand.java | 6 +- .../worlds/command/WorldSetSpawnCommand.java | 6 +- .../worlds/command/WorldSpawnCommand.java | 6 +- .../worlds/command/WorldTeleportCommand.java | 6 +- .../worlds/command/WorldUnloadCommand.java | 6 +- .../DimensionSuggestionProvider.java | 6 +- .../GeneratorSuggestionProvider.java | 6 +- .../suggestion/LevelSuggestionProvider.java | 6 +- .../RelativeSuggestionProvider.java | 6 +- .../WorldPresetSuggestionProvider.java | 6 +- .../suggestion/WorldSuggestionProvider.java | 15 +- .../WorldTypeSuggestionProvider.java | 6 +- .../controller/WorldLinkController.java | 5 +- .../worlds/listener/PortalListener.java | 6 +- .../worlds/listener/ServerListener.java | 6 +- .../thenextlvl/worlds/model/PaperLevel.java | 68 ++++++++- .../worlds/model/PaperLevelBuilder.java | 117 ++++++++++++++-- .../worlds/view/PaperLevelView.java | 6 +- 41 files changed, 504 insertions(+), 126 deletions(-) diff --git a/api/build.gradle.kts b/api/build.gradle.kts index e059082..92ce6a0 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -23,14 +23,11 @@ repositories { } dependencies { - compileOnly("org.projectlombok:lombok:1.18.36") compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT") implementation("net.thenextlvl.core:nbt:2.2.14") implementation("net.thenextlvl.core:files:2.0.0") implementation("net.thenextlvl.core:adapters:2.0.1") - - annotationProcessor("org.projectlombok:lombok:1.18.36") } diff --git a/api/src/main/java/net/thenextlvl/worlds/api/event/WorldDeleteEvent.java b/api/src/main/java/net/thenextlvl/worlds/api/event/WorldDeleteEvent.java index 6538b35..ee12f56 100644 --- a/api/src/main/java/net/thenextlvl/worlds/api/event/WorldDeleteEvent.java +++ b/api/src/main/java/net/thenextlvl/worlds/api/event/WorldDeleteEvent.java @@ -1,6 +1,5 @@ package net.thenextlvl.worlds.api.event; -import lombok.Getter; import org.bukkit.World; import org.bukkit.event.HandlerList; import org.bukkit.event.world.WorldEvent; @@ -8,7 +7,7 @@ @NullMarked public class WorldDeleteEvent extends WorldEvent { - private static final @Getter HandlerList handlerList = new HandlerList(); + private static final HandlerList handlerList = new HandlerList(); public WorldDeleteEvent(World world) { super(world, false); @@ -16,6 +15,10 @@ public WorldDeleteEvent(World world) { @Override public HandlerList getHandlers() { - return getHandlerList(); + return handlerList; + } + + public static HandlerList getHandlerList() { + return handlerList; } } diff --git a/api/src/main/java/net/thenextlvl/worlds/api/exception/GeneratorException.java b/api/src/main/java/net/thenextlvl/worlds/api/exception/GeneratorException.java index 1e475ef..9a68067 100644 --- a/api/src/main/java/net/thenextlvl/worlds/api/exception/GeneratorException.java +++ b/api/src/main/java/net/thenextlvl/worlds/api/exception/GeneratorException.java @@ -1,6 +1,5 @@ package net.thenextlvl.worlds.api.exception; -import lombok.Getter; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -8,15 +7,39 @@ * The GeneratorException class is a custom exception that is thrown when a requested plugin as a generator * cannot be found, is disabled, or doesn't provide a chunk generator or biome provider. */ -@Getter @NullMarked public class GeneratorException extends RuntimeException { private final String plugin; private final @Nullable String id; + /** + * Constructs a new GeneratorException with the specified plugin name, generator ID, and error message. + * + * @param plugin the name of the plugin associated with the generator + * @param id the unique identifier for the generator + * @param message the detailed error message describing the reason for the exception + */ public GeneratorException(String plugin, @Nullable String id, String message) { super(message); this.plugin = plugin; this.id = id; } + + /** + * Retrieves the name of the plugin associated with the generator exception. + * + * @return a string representing the plugin name + */ + public String getPlugin() { + return plugin; + } + + /** + * Retrieves the unique identifier associated with the generator exception. + * + * @return a nullable string representing the ID of the generator, or null if no ID is provided + */ + public @Nullable String getId() { + return id; + } } diff --git a/api/src/main/java/net/thenextlvl/worlds/api/link/Relative.java b/api/src/main/java/net/thenextlvl/worlds/api/link/Relative.java index 500be58..50044dd 100644 --- a/api/src/main/java/net/thenextlvl/worlds/api/link/Relative.java +++ b/api/src/main/java/net/thenextlvl/worlds/api/link/Relative.java @@ -1,8 +1,5 @@ package net.thenextlvl.worlds.api.link; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.experimental.Accessors; import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Keyed; import org.bukkit.NamespacedKey; @@ -12,10 +9,7 @@ import java.util.Arrays; import java.util.Optional; -@Getter @NullMarked -@RequiredArgsConstructor -@Accessors(fluent = true) public enum Relative implements Keyed { OVERWORLD(new NamespacedKey("relative", "overworld")), NETHER(new NamespacedKey("relative", "nether")), @@ -23,6 +17,15 @@ public enum Relative implements Keyed { private final NamespacedKey key; + Relative(NamespacedKey key) { + this.key = key; + } + + @Override + public NamespacedKey key() { + return key; + } + public static Optional valueOf(Key key) { return Arrays.stream(values()) .filter(value -> value.key().equals(key)) diff --git a/api/src/main/java/net/thenextlvl/worlds/api/preset/Preset.java b/api/src/main/java/net/thenextlvl/worlds/api/preset/Preset.java index 6ea8b1e..8af267e 100644 --- a/api/src/main/java/net/thenextlvl/worlds/api/preset/Preset.java +++ b/api/src/main/java/net/thenextlvl/worlds/api/preset/Preset.java @@ -7,9 +7,6 @@ import core.file.format.GsonFile; import core.io.IO; import core.paper.adapters.inventory.MaterialAdapter; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; import net.thenextlvl.worlds.api.preset.adapter.BiomeTypeAdapter; import net.thenextlvl.worlds.api.preset.adapter.StructureTypeAdapter; import org.bukkit.Material; @@ -19,10 +16,7 @@ import java.util.LinkedHashSet; import java.util.stream.Collectors; -@Getter -@Setter @NullMarked -@Accessors(chain = true, fluent = true) public class Preset { private Biome biome = Biome.minecraft("plains"); private boolean lakes; @@ -33,6 +27,126 @@ public class Preset { @SerializedName("structure_overrides") private LinkedHashSet structures = new LinkedHashSet<>(); + /** + * Retrieves the biome associated with the preset. + * + * @return the biome as a {@code Biome} record + */ + public Biome biome() { + return biome; + } + + /** + * Sets the biome for the current preset. + * + * @param biome the biome to be set, encapsulated in a {@code Biome} record + * @return the current {@code Preset} instance, allowing for method chaining + */ + public Preset biome(Biome biome) { + this.biome = biome; + return this; + } + + /** + * Determines whether lakes are enabled for the preset. + * + * @return true if lakes are enabled, false otherwise + */ + public boolean lakes() { + return lakes; + } + + /** + * Sets whether lakes should be included for the preset. + * + * @param lakes a boolean indicating whether lakes should be included + * @return the current Preset instance, allowing for method chaining + */ + public Preset lakes(boolean lakes) { + this.lakes = lakes; + return this; + } + + /** + * Determines whether features are enabled for the preset. + * + * @return true if features are enabled, false otherwise + */ + public boolean features() { + return features; + } + + /** + * Sets whether the features should be enabled for the preset. + * + * @param features a boolean indicating whether features are enabled + * @return the current Preset instance, allowing for method chaining + */ + public Preset features(boolean features) { + this.features = features; + return this; + } + + /** + * Determines whether decoration is enabled for the preset. + * + * @return true if decoration is enabled, false otherwise + */ + public boolean decoration() { + return decoration; + } + + /** + * Sets whether the decoration should be enabled for the preset. + * + * @param decoration a boolean indicating whether decoration is enabled + * @return the current Preset instance, allowing for method chaining + */ + public Preset decoration(boolean decoration) { + this.decoration = decoration; + return this; + } + + /** + * Retrieves the set of layers associated with the preset. + * + * @return a {@code LinkedHashSet} containing the layers of the preset + */ + public LinkedHashSet layers() { + return layers; + } + + /** + * Sets the layers for the preset. + * + * @param layers the set of layers to be associated with the preset + * @return the preset instance for method chaining + */ + public Preset layers(LinkedHashSet layers) { + this.layers = layers; + return this; + } + + /** + * Retrieves the set of structures associated with the preset. + * + * @return a {@code LinkedHashSet} containing the structures of the preset + */ + public LinkedHashSet structures() { + return structures; + } + + /** + * Sets the structures for the preset. + * + * @param structures the set of structures to be associated with the preset + * @return the preset instance for method chaining + */ + public Preset structures(LinkedHashSet structures) { + this.structures = structures; + return this; + } + /** * Add a layer to the preset * @@ -69,7 +183,7 @@ public boolean saveToFile(File file, boolean force) { } /** - * Serialize this preset into a json object. + * Serialize this preset into a JSON object. * * @return the serialized preset as a JsonObject */ @@ -85,7 +199,7 @@ public JsonObject serialize() { .create(); /** - * Deserialize a json object into a preset + * Deserialize a JSON object into a preset * * @param object the object to deserialize * @return the deserialized preset diff --git a/build.gradle.kts b/build.gradle.kts index d757baf..6552784 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,8 +30,6 @@ repositories { dependencies { paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") - compileOnly("org.projectlombok:lombok:1.18.36") - implementation("org.bstats:bstats-bukkit:3.1.0") implementation(project(":api")) @@ -40,8 +38,6 @@ dependencies { implementation("net.thenextlvl.core:i18n:1.0.20") implementation("net.thenextlvl.core:paper:2.0.2") implementation("net.thenextlvl.core:adapters:2.0.1") - - annotationProcessor("org.projectlombok:lombok:1.18.36") } tasks.shadowJar { diff --git a/src/main/java/net/thenextlvl/worlds/WorldsPlugin.java b/src/main/java/net/thenextlvl/worlds/WorldsPlugin.java index b1e364a..c2f0f3b 100644 --- a/src/main/java/net/thenextlvl/worlds/WorldsPlugin.java +++ b/src/main/java/net/thenextlvl/worlds/WorldsPlugin.java @@ -1,8 +1,6 @@ package net.thenextlvl.worlds; import core.i18n.file.ComponentBundle; -import lombok.Getter; -import lombok.experimental.Accessors; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; @@ -35,9 +33,7 @@ import static org.bukkit.persistence.PersistentDataType.BOOLEAN; import static org.bukkit.persistence.PersistentDataType.STRING; -@Getter @NullMarked -@Accessors(fluent = true) public class WorldsPlugin extends JavaPlugin implements WorldsProvider { private final GeneratorView generatorView = new PluginGeneratorView(); private final LevelView levelView = new PaperLevelView(this); @@ -61,8 +57,8 @@ public class WorldsPlugin extends JavaPlugin implements WorldsProvider { @Override public void onLoad() { - if (!presetsFolder().isDirectory()) saveDefaultPresets(); - versionChecker().checkVersion(); + if (!presetsFolder.isDirectory()) saveDefaultPresets(); + versionChecker.checkVersion(); registerServices(); } @@ -74,15 +70,38 @@ public void onEnable() { @Override public void onDisable() { - metrics().shutdown(); + metrics.shutdown(); unloadWorlds(); } + public File presetsFolder() { + return presetsFolder; + } + + public ComponentBundle bundle() { + return bundle; + } + + @Override + public GeneratorView generatorView() { + return generatorView; + } + @Override public LevelBuilder levelBuilder(File level) { return new PaperLevelBuilder(this, level); } + @Override + public LevelView levelView() { + return levelView; + } + + @Override + public LinkController linkController() { + return linkController; + } + private void unloadWorlds() { getServer().getWorlds().stream().filter(world -> !world.isAutoSave()).forEach(world -> { world.getPlayers().forEach(player -> player.kick(getServer().shutdownMessage())); @@ -121,14 +140,14 @@ private void registerCommands() { } private void saveDefaultPresets() { - Presets.BOTTOMLESS_PIT.saveToFile(new File(presetsFolder(), "bottomless-pit.json"), true); - Presets.CLASSIC_FLAT.saveToFile(new File(presetsFolder(), "classic-flat.json"), true); - Presets.DESERT.saveToFile(new File(presetsFolder(), "desert.json"), true); - Presets.OVERWORLD.saveToFile(new File(presetsFolder(), "overworld.json"), true); - Presets.REDSTONE_READY.saveToFile(new File(presetsFolder(), "redstone-ready.json"), true); - Presets.SNOWY_KINGDOM.saveToFile(new File(presetsFolder(), "snowy-kingdom.json"), true); - Presets.THE_VOID.saveToFile(new File(presetsFolder(), "the-void.json"), true); - Presets.TUNNELERS_DREAM.saveToFile(new File(presetsFolder(), "tunnelers-dream.json"), true); - Presets.WATER_WORLD.saveToFile(new File(presetsFolder(), "water-world.json"), true); + Presets.BOTTOMLESS_PIT.saveToFile(new File(presetsFolder, "bottomless-pit.json"), true); + Presets.CLASSIC_FLAT.saveToFile(new File(presetsFolder, "classic-flat.json"), true); + Presets.DESERT.saveToFile(new File(presetsFolder, "desert.json"), true); + Presets.OVERWORLD.saveToFile(new File(presetsFolder, "overworld.json"), true); + Presets.REDSTONE_READY.saveToFile(new File(presetsFolder, "redstone-ready.json"), true); + Presets.SNOWY_KINGDOM.saveToFile(new File(presetsFolder, "snowy-kingdom.json"), true); + Presets.THE_VOID.saveToFile(new File(presetsFolder, "the-void.json"), true); + Presets.TUNNELERS_DREAM.saveToFile(new File(presetsFolder, "tunnelers-dream.json"), true); + Presets.WATER_WORLD.saveToFile(new File(presetsFolder, "water-world.json"), true); } } diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldCloneCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldCloneCommand.java index f3926cf..dd8baf4 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldCloneCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldCloneCommand.java @@ -6,7 +6,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.suggestion.WorldSuggestionProvider; @@ -25,10 +24,13 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND; @NullMarked -@RequiredArgsConstructor class WorldCloneCommand { private final WorldsPlugin plugin; + WorldCloneCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("clone") .requires(source -> source.getSender().hasPermission("worlds.command.clone")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldCommand.java index 7c71628..5fdb495 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldCommand.java @@ -2,15 +2,17 @@ import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor public class WorldCommand { private final WorldsPlugin plugin; + public WorldCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + public void register() { var command = Commands.literal("world") .requires(source -> source.getSender().hasPermission("worlds.command")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldCreateCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldCreateCommand.java index ab4b0b5..253dcb2 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldCreateCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldCreateCommand.java @@ -9,7 +9,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.model.Generator; @@ -32,10 +31,13 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND; @NullMarked -@RequiredArgsConstructor class WorldCreateCommand { private final WorldsPlugin plugin; + WorldCreateCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("create") .requires(source -> source.getSender().hasPermission("worlds.command.create")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldDeleteCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldDeleteCommand.java index 4976629..bfd37ba 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldDeleteCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldDeleteCommand.java @@ -6,7 +6,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.argument.CommandFlagsArgument; @@ -18,10 +17,13 @@ import java.util.Set; @NullMarked -@RequiredArgsConstructor class WorldDeleteCommand { private final WorldsPlugin plugin; + WorldDeleteCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("delete") .requires(source -> source.getSender().hasPermission("worlds.command.delete")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldImportCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldImportCommand.java index 09dcb25..f73a489 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldImportCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldImportCommand.java @@ -7,7 +7,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.model.Generator; @@ -27,10 +26,13 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND; @NullMarked -@RequiredArgsConstructor class WorldImportCommand { private final WorldsPlugin plugin; + WorldImportCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("import") .requires(source -> source.getSender().hasPermission("worlds.command.import")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldInfoCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldInfoCommand.java index a047965..d9d3388 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldInfoCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldInfoCommand.java @@ -6,7 +6,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; @@ -21,10 +20,13 @@ import java.util.Optional; @NullMarked -@RequiredArgsConstructor class WorldInfoCommand { private final WorldsPlugin plugin; + WorldInfoCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("info") .requires(source -> source.getSender().hasPermission("worlds.command.info")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldLinkCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldLinkCommand.java index 913d451..dfe453a 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldLinkCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldLinkCommand.java @@ -3,15 +3,17 @@ import com.mojang.brigadier.builder.ArgumentBuilder; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor class WorldLinkCommand { private final WorldsPlugin plugin; + WorldLinkCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("link") .requires(source -> source.getSender().hasPermission("worlds.command.link")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldLinkCreateCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldLinkCreateCommand.java index 3d33abb..a1362d1 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldLinkCreateCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldLinkCreateCommand.java @@ -5,7 +5,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.suggestion.WorldSuggestionProvider; @@ -13,10 +12,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor -public class WorldLinkCreateCommand { +class WorldLinkCreateCommand { private final WorldsPlugin plugin; + WorldLinkCreateCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("create") .requires(source -> source.getSender().hasPermission("worlds.command.link.create")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldLinkListCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldLinkListCommand.java index d8ec802..0556eb0 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldLinkListCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldLinkListCommand.java @@ -5,7 +5,6 @@ import com.mojang.brigadier.context.CommandContext; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.link.Relative; @@ -16,10 +15,13 @@ import java.util.Objects; @NullMarked -@RequiredArgsConstructor -public class WorldLinkListCommand { +class WorldLinkListCommand { private final WorldsPlugin plugin; + WorldLinkListCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("list") .requires(source -> source.getSender().hasPermission("worlds.command.link.list")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldLinkRemoveCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldLinkRemoveCommand.java index e494fae..0422adf 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldLinkRemoveCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldLinkRemoveCommand.java @@ -5,7 +5,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.link.Relative; @@ -15,10 +14,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor -public class WorldLinkRemoveCommand { +class WorldLinkRemoveCommand { private final WorldsPlugin plugin; + WorldLinkRemoveCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("remove") .requires(source -> source.getSender().hasPermission("worlds.command.link.remove")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldListCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldListCommand.java index 9ca8f43..160b4b8 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldListCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldListCommand.java @@ -5,7 +5,6 @@ import com.mojang.brigadier.context.CommandContext; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.ClickEvent; @@ -15,10 +14,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor class WorldListCommand { private final WorldsPlugin plugin; + WorldListCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("list") .requires(source -> source.getSender().hasPermission("worlds.command.list")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java index 3f583f4..a4f2a5a 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldLoadCommand.java @@ -6,7 +6,6 @@ import com.mojang.brigadier.context.CommandContext; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.model.Level; @@ -20,10 +19,13 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND; @NullMarked -@RequiredArgsConstructor class WorldLoadCommand { private final WorldsPlugin plugin; + WorldLoadCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("load") .requires(source -> source.getSender().hasPermission("worlds.command.load")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldRegenerateCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldRegenerateCommand.java index 43d01f7..2a81060 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldRegenerateCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldRegenerateCommand.java @@ -6,7 +6,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.argument.CommandFlagsArgument; @@ -21,10 +20,13 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND; @NullMarked -@RequiredArgsConstructor class WorldRegenerateCommand { private final WorldsPlugin plugin; + WorldRegenerateCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("regenerate") .requires(source -> source.getSender().hasPermission("worlds.command.regenerate")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldSaveAllCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldSaveAllCommand.java index 98691a1..fa19f15 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldSaveAllCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldSaveAllCommand.java @@ -4,17 +4,19 @@ import com.mojang.brigadier.builder.ArgumentBuilder; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.craftbukkit.CraftServer; import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor class WorldSaveAllCommand { private final WorldsPlugin plugin; + WorldSaveAllCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("save-all") .requires(source -> source.getSender().hasPermission("worlds.command.save-all")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldSaveCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldSaveCommand.java index 325b322..205a6f0 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldSaveCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldSaveCommand.java @@ -6,7 +6,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.suggestion.WorldSuggestionProvider; @@ -14,10 +13,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor class WorldSaveCommand { private final WorldsPlugin plugin; + WorldSaveCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("save") .requires(source -> source.getSender().hasPermission("worlds.command.save")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldSaveOffCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldSaveOffCommand.java index 2d67cbb..0a886cc 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldSaveOffCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldSaveOffCommand.java @@ -5,7 +5,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.suggestion.WorldSuggestionProvider; import org.bukkit.World; @@ -13,10 +12,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor class WorldSaveOffCommand { private final WorldsPlugin plugin; + WorldSaveOffCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("save-off") .requires(source -> source.getSender().hasPermission("worlds.command.save-off")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldSaveOnCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldSaveOnCommand.java index 0c8b96c..a791be2 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldSaveOnCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldSaveOnCommand.java @@ -5,7 +5,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.suggestion.WorldSuggestionProvider; import org.bukkit.World; @@ -13,10 +12,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor class WorldSaveOnCommand { private final WorldsPlugin plugin; + WorldSaveOnCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("save-on") .requires(source -> source.getSender().hasPermission("worlds.command.save-on")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldSetSpawnCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldSetSpawnCommand.java index eff5411..e4610eb 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldSetSpawnCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldSetSpawnCommand.java @@ -7,7 +7,6 @@ import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; import io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import org.bukkit.World; @@ -15,10 +14,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor class WorldSetSpawnCommand { private final WorldsPlugin plugin; + WorldSetSpawnCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("setspawn") .requires(source -> source.getSender().hasPermission("worlds.command.setspawn")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldSpawnCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldSpawnCommand.java index e6579b0..ba14cbb 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldSpawnCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldSpawnCommand.java @@ -4,7 +4,6 @@ import com.mojang.brigadier.builder.ArgumentBuilder; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import org.bukkit.entity.Player; @@ -13,10 +12,13 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND; @NullMarked -@RequiredArgsConstructor class WorldSpawnCommand { private final WorldsPlugin plugin; + WorldSpawnCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("spawn") .requires(source -> source.getSender().hasPermission("worlds.command.spawn") diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldTeleportCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldTeleportCommand.java index da7dcb4..ab4fd73 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldTeleportCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldTeleportCommand.java @@ -9,7 +9,6 @@ import io.papermc.paper.command.brigadier.argument.ArgumentTypes; import io.papermc.paper.command.brigadier.argument.resolvers.FinePositionResolver; import io.papermc.paper.command.brigadier.argument.resolvers.selector.EntitySelectorArgumentResolver; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; @@ -26,10 +25,13 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND; @NullMarked -@RequiredArgsConstructor class WorldTeleportCommand { private final WorldsPlugin plugin; + WorldTeleportCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("teleport") .requires(source -> source.getSender().hasPermission("worlds.command.teleport")) diff --git a/src/main/java/net/thenextlvl/worlds/command/WorldUnloadCommand.java b/src/main/java/net/thenextlvl/worlds/command/WorldUnloadCommand.java index 955de27..ff78f44 100644 --- a/src/main/java/net/thenextlvl/worlds/command/WorldUnloadCommand.java +++ b/src/main/java/net/thenextlvl/worlds/command/WorldUnloadCommand.java @@ -5,7 +5,6 @@ import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.command.suggestion.WorldSuggestionProvider; @@ -14,10 +13,13 @@ import org.jspecify.annotations.Nullable; @NullMarked -@RequiredArgsConstructor class WorldUnloadCommand { private final WorldsPlugin plugin; + WorldUnloadCommand(WorldsPlugin plugin) { + this.plugin = plugin; + } + ArgumentBuilder create() { return Commands.literal("unload") .requires(source -> source.getSender().hasPermission("worlds.command.unload")) diff --git a/src/main/java/net/thenextlvl/worlds/command/suggestion/DimensionSuggestionProvider.java b/src/main/java/net/thenextlvl/worlds/command/suggestion/DimensionSuggestionProvider.java index ce2c038..f938b60 100644 --- a/src/main/java/net/thenextlvl/worlds/command/suggestion/DimensionSuggestionProvider.java +++ b/src/main/java/net/thenextlvl/worlds/command/suggestion/DimensionSuggestionProvider.java @@ -5,7 +5,6 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import core.paper.command.SuggestionProvider; import io.papermc.paper.command.brigadier.CommandSourceStack; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.jspecify.annotations.NullMarked; @@ -13,10 +12,13 @@ import java.util.concurrent.CompletableFuture; @NullMarked -@RequiredArgsConstructor public class DimensionSuggestionProvider implements SuggestionProvider { private final WorldsPlugin plugin; + public DimensionSuggestionProvider(WorldsPlugin plugin) { + this.plugin = plugin; + } + private final Map dimensions = Map.of( "minecraft:overworld", "environment.normal", "minecraft:the_end", "environment.end", diff --git a/src/main/java/net/thenextlvl/worlds/command/suggestion/GeneratorSuggestionProvider.java b/src/main/java/net/thenextlvl/worlds/command/suggestion/GeneratorSuggestionProvider.java index b99920b..a0e9114 100644 --- a/src/main/java/net/thenextlvl/worlds/command/suggestion/GeneratorSuggestionProvider.java +++ b/src/main/java/net/thenextlvl/worlds/command/suggestion/GeneratorSuggestionProvider.java @@ -4,7 +4,6 @@ import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import core.paper.command.SuggestionProvider; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.bukkit.plugin.Plugin; import org.jspecify.annotations.NullMarked; @@ -13,10 +12,13 @@ import java.util.concurrent.CompletableFuture; @NullMarked -@RequiredArgsConstructor public class GeneratorSuggestionProvider implements SuggestionProvider { private final WorldsPlugin plugin; + public GeneratorSuggestionProvider(WorldsPlugin plugin) { + this.plugin = plugin; + } + @Override public CompletableFuture suggest(CommandContext context, SuggestionsBuilder builder) { Arrays.stream(plugin.getServer().getPluginManager().getPlugins()) diff --git a/src/main/java/net/thenextlvl/worlds/command/suggestion/LevelSuggestionProvider.java b/src/main/java/net/thenextlvl/worlds/command/suggestion/LevelSuggestionProvider.java index 561ead3..ec560b6 100644 --- a/src/main/java/net/thenextlvl/worlds/command/suggestion/LevelSuggestionProvider.java +++ b/src/main/java/net/thenextlvl/worlds/command/suggestion/LevelSuggestionProvider.java @@ -5,7 +5,6 @@ import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.jspecify.annotations.NullMarked; @@ -13,10 +12,13 @@ import java.util.concurrent.CompletableFuture; @NullMarked -@RequiredArgsConstructor public class LevelSuggestionProvider implements SuggestionProvider { private final WorldsPlugin plugin; + public LevelSuggestionProvider(WorldsPlugin plugin) { + this.plugin = plugin; + } + @Override public CompletableFuture getSuggestions(CommandContext context, SuggestionsBuilder builder) { plugin.levelView().listLevels() diff --git a/src/main/java/net/thenextlvl/worlds/command/suggestion/RelativeSuggestionProvider.java b/src/main/java/net/thenextlvl/worlds/command/suggestion/RelativeSuggestionProvider.java index c035fa3..2e80320 100644 --- a/src/main/java/net/thenextlvl/worlds/command/suggestion/RelativeSuggestionProvider.java +++ b/src/main/java/net/thenextlvl/worlds/command/suggestion/RelativeSuggestionProvider.java @@ -4,7 +4,6 @@ import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import core.paper.command.SuggestionProvider; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.api.link.Relative; import org.jspecify.annotations.NullMarked; @@ -13,10 +12,13 @@ import java.util.function.Predicate; @NullMarked -@RequiredArgsConstructor public class RelativeSuggestionProvider implements SuggestionProvider { private final Predicate filter; + public RelativeSuggestionProvider(Predicate filter) { + this.filter = filter; + } + @Override public CompletableFuture suggest(CommandContext context, SuggestionsBuilder builder) { Arrays.stream(Relative.values()) diff --git a/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldPresetSuggestionProvider.java b/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldPresetSuggestionProvider.java index 06cb069..04cf3d7 100644 --- a/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldPresetSuggestionProvider.java +++ b/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldPresetSuggestionProvider.java @@ -5,7 +5,6 @@ import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import core.paper.command.SuggestionProvider; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.jspecify.annotations.NullMarked; @@ -14,10 +13,13 @@ import java.util.concurrent.CompletableFuture; @NullMarked -@RequiredArgsConstructor public class WorldPresetSuggestionProvider implements SuggestionProvider { private final WorldsPlugin plugin; + public WorldPresetSuggestionProvider(WorldsPlugin plugin) { + this.plugin = plugin; + } + @Override public CompletableFuture suggest(CommandContext context, SuggestionsBuilder builder) { var files = plugin.presetsFolder().listFiles((file, name) -> diff --git a/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldSuggestionProvider.java b/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldSuggestionProvider.java index 30813de..aa47964 100644 --- a/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldSuggestionProvider.java +++ b/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldSuggestionProvider.java @@ -4,8 +4,6 @@ import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import lombok.AllArgsConstructor; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.key.Key; import org.bukkit.Keyed; import org.bukkit.World; @@ -16,11 +14,18 @@ import java.util.function.BiPredicate; @NullMarked -@AllArgsConstructor -@RequiredArgsConstructor public class WorldSuggestionProvider implements SuggestionProvider { private final Plugin plugin; - private BiPredicate, World> filter = (context, world) -> true; + private final BiPredicate, World> filter; + + public WorldSuggestionProvider(Plugin plugin) { + this(plugin, (context, world) -> true); + } + + public WorldSuggestionProvider(Plugin plugin, BiPredicate, World> filter) { + this.plugin = plugin; + this.filter = filter; + } @Override public CompletableFuture getSuggestions(CommandContext context, SuggestionsBuilder builder) { diff --git a/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldTypeSuggestionProvider.java b/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldTypeSuggestionProvider.java index 363c1d5..391338d 100644 --- a/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldTypeSuggestionProvider.java +++ b/src/main/java/net/thenextlvl/worlds/command/suggestion/WorldTypeSuggestionProvider.java @@ -5,7 +5,6 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import core.paper.command.SuggestionProvider; import io.papermc.paper.command.brigadier.CommandSourceStack; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import org.jspecify.annotations.NullMarked; @@ -13,10 +12,13 @@ import java.util.concurrent.CompletableFuture; @NullMarked -@RequiredArgsConstructor public class WorldTypeSuggestionProvider implements SuggestionProvider { private final WorldsPlugin plugin; + public WorldTypeSuggestionProvider(WorldsPlugin plugin) { + this.plugin = plugin; + } + private final Map dimensions = Map.of( "minecraft:amplified", "world.type.amplified", "minecraft:checkerboard", "world.type.checkerboard", diff --git a/src/main/java/net/thenextlvl/worlds/controller/WorldLinkController.java b/src/main/java/net/thenextlvl/worlds/controller/WorldLinkController.java index 3891bb2..8525003 100644 --- a/src/main/java/net/thenextlvl/worlds/controller/WorldLinkController.java +++ b/src/main/java/net/thenextlvl/worlds/controller/WorldLinkController.java @@ -1,6 +1,5 @@ package net.thenextlvl.worlds.controller; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.link.LinkController; import net.thenextlvl.worlds.api.link.Relative; @@ -14,10 +13,12 @@ import static org.bukkit.persistence.PersistentDataType.STRING; @NullMarked -@RequiredArgsConstructor public class WorldLinkController implements LinkController { private final WorldsPlugin plugin; + public WorldLinkController(WorldsPlugin plugin) { + this.plugin = plugin; + } @Override public Optional getTarget(World world, Relative relative) { return Optional.ofNullable(world.getPersistentDataContainer() diff --git a/src/main/java/net/thenextlvl/worlds/listener/PortalListener.java b/src/main/java/net/thenextlvl/worlds/listener/PortalListener.java index 9fc4085..7344b7d 100644 --- a/src/main/java/net/thenextlvl/worlds/listener/PortalListener.java +++ b/src/main/java/net/thenextlvl/worlds/listener/PortalListener.java @@ -1,7 +1,6 @@ package net.thenextlvl.worlds.listener; import io.papermc.paper.event.entity.EntityPortalReadyEvent; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.model.PortalCooldown; import org.bukkit.Bukkit; @@ -22,11 +21,14 @@ import static org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL; @NullMarked -@RequiredArgsConstructor public class PortalListener implements Listener { private final PortalCooldown cooldown = new PortalCooldown(); private final WorldsPlugin plugin; + public PortalListener(WorldsPlugin plugin) { + this.plugin = plugin; + } + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityPortal(EntityPortalReadyEvent event) { if (event.getPortalType().equals(PortalType.CUSTOM)) return; diff --git a/src/main/java/net/thenextlvl/worlds/listener/ServerListener.java b/src/main/java/net/thenextlvl/worlds/listener/ServerListener.java index fc8bdd5..ab8a834 100644 --- a/src/main/java/net/thenextlvl/worlds/listener/ServerListener.java +++ b/src/main/java/net/thenextlvl/worlds/listener/ServerListener.java @@ -1,6 +1,5 @@ package net.thenextlvl.worlds.listener; -import lombok.RequiredArgsConstructor; import net.minecraft.util.DirectoryLock; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.exception.GeneratorException; @@ -11,10 +10,13 @@ import org.jspecify.annotations.NullMarked; @NullMarked -@RequiredArgsConstructor public class ServerListener implements Listener { private final WorldsPlugin plugin; + public ServerListener(WorldsPlugin plugin) { + this.plugin = plugin; + } + @EventHandler(priority = EventPriority.MONITOR) public void onWorldLoad(WorldLoadEvent event) { if (!event.getWorld().key().asString().equals("minecraft:overworld")) return; diff --git a/src/main/java/net/thenextlvl/worlds/model/PaperLevel.java b/src/main/java/net/thenextlvl/worlds/model/PaperLevel.java index 39d22c7..bcee9bd 100644 --- a/src/main/java/net/thenextlvl/worlds/model/PaperLevel.java +++ b/src/main/java/net/thenextlvl/worlds/model/PaperLevel.java @@ -5,8 +5,6 @@ import core.nbt.tag.ByteTag; import core.nbt.tag.CompoundTag; import core.nbt.tag.LongTag; -import lombok.Getter; -import lombok.experimental.Accessors; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.model.Generator; import net.thenextlvl.worlds.api.model.Level; @@ -24,9 +22,7 @@ import java.util.Optional; import java.util.concurrent.ThreadLocalRandom; -@Getter @NullMarked -@Accessors(fluent = true) public class PaperLevel implements Level { private final NBTFile levelData; private final WorldsPlugin plugin; @@ -115,6 +111,26 @@ private WorldType typeOf(WorldPreset worldPreset) { return WorldType.NORMAL; } + @Override + public @Nullable Generator generator() { + return generator; + } + + @Override + public @Nullable Preset preset() { + return preset; + } + + @Override + public NBTFile levelData() { + return levelData; + } + + @Override + public NamespacedKey key() { + return key; + } + @Override public Optional create() { var generatorSettings = Optional.ofNullable(preset()) @@ -130,9 +146,49 @@ public Optional create() { .seed(seed()) .type(typeOf(type())); - if (generator() != null) creator.generator(generator().generator(creator.name())); - if (generator() != null) creator.biomeProvider(generator().biomeProvider(creator.name())); + if (generator != null) creator.generator(generator.generator(creator.name())); + if (generator != null) creator.biomeProvider(generator.biomeProvider(creator.name())); return Optional.ofNullable(creator.createWorld()); } + + @Override + public String name() { + return name; + } + + @Override + public World.Environment environment() { + return environment; + } + + @Override + public WorldPreset type() { + return type; + } + + @Override + public boolean enabled() { + return enabled; + } + + @Override + public boolean hardcore() { + return hardcore; + } + + @Override + public boolean importedBefore() { + return importedBefore; + } + + @Override + public boolean structures() { + return structures; + } + + @Override + public long seed() { + return seed; + } } diff --git a/src/main/java/net/thenextlvl/worlds/model/PaperLevelBuilder.java b/src/main/java/net/thenextlvl/worlds/model/PaperLevelBuilder.java index 7667ef1..8c6b468 100644 --- a/src/main/java/net/thenextlvl/worlds/model/PaperLevelBuilder.java +++ b/src/main/java/net/thenextlvl/worlds/model/PaperLevelBuilder.java @@ -1,9 +1,5 @@ package net.thenextlvl.worlds.model; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; -import lombok.experimental.Accessors; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.model.Generator; import net.thenextlvl.worlds.api.model.Level; @@ -17,11 +13,7 @@ import java.io.File; -@Getter -@Setter @NullMarked -@RequiredArgsConstructor -@Accessors(fluent = true) public class PaperLevelBuilder implements LevelBuilder { private final WorldsPlugin plugin; private final File level; @@ -36,6 +28,115 @@ public class PaperLevelBuilder implements LevelBuilder { private World.@Nullable Environment environment; private @Nullable WorldPreset type; + public PaperLevelBuilder(WorldsPlugin plugin, File level) { + this.plugin = plugin; + this.level = level; + } + + @Override + public @Nullable Boolean hardcore() { + return hardcore; + } + + @Override + public @Nullable Boolean structures() { + return structures; + } + + @Override + public @Nullable Generator generator() { + return generator; + } + + @Override + public @Nullable Long seed() { + return seed; + } + + @Override + public @Nullable NamespacedKey key() { + return key; + } + + @Override + public @Nullable Preset preset() { + return preset; + } + + @Override + public @Nullable String name() { + return name; + } + + @Override + public World.@Nullable Environment environment() { + return environment; + } + + @Override + public @Nullable WorldPreset type() { + return type; + } + + @Override + public File level() { + return level; + } + + @Override + public LevelBuilder environment(World.@Nullable Environment environment) { + this.environment = environment; + return this; + } + + @Override + public LevelBuilder generator(@Nullable Generator generator) { + this.generator = generator; + return this; + } + + @Override + public LevelBuilder hardcore(@Nullable Boolean hardcore) { + this.hardcore = hardcore; + return this; + } + + @Override + public LevelBuilder key(@Nullable NamespacedKey key) { + this.key = key; + return this; + } + + @Override + public LevelBuilder name(@Nullable String name) { + this.name = name; + return this; + } + + @Override + public LevelBuilder preset(@Nullable Preset preset) { + this.preset = preset; + return this; + } + + @Override + public LevelBuilder seed(@Nullable Long seed) { + this.seed = seed; + return this; + } + + @Override + public LevelBuilder structures(@Nullable Boolean structures) { + this.structures = structures; + return this; + } + + @Override + public LevelBuilder type(@Nullable WorldPreset type) { + this.type = type; + return this; + } + @Override public Level build() { return new PaperLevel(plugin, this); diff --git a/src/main/java/net/thenextlvl/worlds/view/PaperLevelView.java b/src/main/java/net/thenextlvl/worlds/view/PaperLevelView.java index 1f0e955..8108648 100644 --- a/src/main/java/net/thenextlvl/worlds/view/PaperLevelView.java +++ b/src/main/java/net/thenextlvl/worlds/view/PaperLevelView.java @@ -8,7 +8,6 @@ import core.nbt.tag.StringTag; import core.nbt.tag.Tag; import io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader; -import lombok.RequiredArgsConstructor; import net.thenextlvl.worlds.WorldsPlugin; import net.thenextlvl.worlds.api.model.Generator; import net.thenextlvl.worlds.api.model.LevelExtras; @@ -31,10 +30,13 @@ import java.util.stream.Stream; @NullMarked -@RequiredArgsConstructor public class PaperLevelView implements LevelView { private final WorldsPlugin plugin; + public PaperLevelView(WorldsPlugin plugin) { + this.plugin = plugin; + } + @Override public Stream listLevels() { return Optional.ofNullable(plugin.getServer().getWorldContainer()