Skip to content

Commit

Permalink
Remove Lombok and refactor constructors.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NonSwag committed Dec 26, 2024
1 parent eeff319 commit b17edbe
Show file tree
Hide file tree
Showing 41 changed files with 504 additions and 126 deletions.
3 changes: 0 additions & 3 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package net.thenextlvl.worlds.api.event;

import lombok.Getter;
import org.bukkit.World;
import org.bukkit.event.HandlerList;
import org.bukkit.event.world.WorldEvent;
import org.jspecify.annotations.NullMarked;

@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);
}

@Override
public HandlerList getHandlers() {
return getHandlerList();
return handlerList;
}

public static HandlerList getHandlerList() {
return handlerList;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
package net.thenextlvl.worlds.api.exception;

import lombok.Getter;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* 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;
}
}
15 changes: 9 additions & 6 deletions api/src/main/java/net/thenextlvl/worlds/api/link/Relative.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,17 +9,23 @@
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")),
THE_END(new NamespacedKey("relative", "the_end"));

private final NamespacedKey key;

Relative(NamespacedKey key) {
this.key = key;
}

@Override
public NamespacedKey key() {
return key;
}

public static Optional<Relative> valueOf(Key key) {
return Arrays.stream(values())
.filter(value -> value.key().equals(key))
Expand Down
130 changes: 122 additions & 8 deletions api/src/main/java/net/thenextlvl/worlds/api/preset/Preset.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -33,6 +27,126 @@ public class Preset {
@SerializedName("structure_overrides")
private LinkedHashSet<Structure> 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<Layer> 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<Layer> 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<Structure> 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<Structure> structures) {
this.structures = structures;
return this;
}

/**
* Add a layer to the preset
*
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit b17edbe

Please sign in to comment.