Skip to content

Commit

Permalink
Remove Lombok dependency and migrate to explicit methods
Browse files Browse the repository at this point in the history
Replaced Lombok-generated annotations and methods with manually defined equivalents across multiple classes. Updated the build script to eliminate the Lombok dependency and its annotation processor.
  • Loading branch information
NonSwag committed Dec 29, 2024
1 parent cd28ed9 commit 971ea25
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 33 deletions.
3 changes: 0 additions & 3 deletions paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ repositories {
}

dependencies {
compileOnly("org.projectlombok:lombok:1.18.36")
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT") {
exclude("org.jetbrains", "annotations")
}

api(project(":version-checker")) {
exclude("com.google.code.gson", "gson")
}

annotationProcessor("org.projectlombok:lombok:1.18.36")
}

publishing {
Expand Down
16 changes: 11 additions & 5 deletions paper/src/main/java/core/paper/command/WrappedArgumentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import io.papermc.paper.command.brigadier.argument.CustomArgumentType;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.jspecify.annotations.NullMarked;

import java.util.concurrent.CompletableFuture;
Expand All @@ -20,15 +18,18 @@
* @param <T> the type of the native ArgumentType
* @param <V> the type of the parsed value after conversion
*/
@Getter
@NullMarked
@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
public class WrappedArgumentType<T, V> implements CustomArgumentType<V, T> {
private final ArgumentType<T> nativeType;
private final ResultConverter<T, V> converter;
private final SuggestionProvider suggestionProvider;

public WrappedArgumentType(ArgumentType<T> nativeType, ResultConverter<T, V> converter, SuggestionProvider suggestionProvider) {
this.nativeType = nativeType;
this.converter = converter;
this.suggestionProvider = suggestionProvider;
}

/**
* Constructs a WrappedArgumentType object.
* This class wraps an existing ArgumentType and provides additional functionality.
Expand All @@ -49,4 +50,9 @@ public final V parse(StringReader reader) throws CommandSyntaxException {
public final <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return suggestionProvider.suggest(context, builder);
}

@Override
public ArgumentType<T> getNativeType() {
return nativeType;
}
}
18 changes: 12 additions & 6 deletions paper/src/main/java/core/paper/gui/AbstractGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import core.paper.item.ActionItem;
import core.paper.item.ItemBuilder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.experimental.Accessors;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
Expand All @@ -17,12 +14,10 @@
/**
* Represents an abstract GUI that can be used as a base class for creating GUIs.
*/
@Getter
@NullMarked
@EqualsAndHashCode
public abstract class AbstractGUI implements InventoryHolder {
private final Map<Integer, ActionItem.Action> actions = new HashMap<>();
private @Accessors(fluent = true) Component title;
private Component title;
protected final Player owner;

/**
Expand Down Expand Up @@ -149,4 +144,15 @@ public void close() {
getInventory().close();
}

public Map<Integer, ActionItem.Action> getActions() {
return actions;
}

public Component title() {
return title;
}

public Player getOwner() {
return owner;
}
}
25 changes: 19 additions & 6 deletions paper/src/main/java/core/paper/gui/GUI.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package core.paper.gui;

import core.paper.item.ItemBuilder;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand All @@ -27,13 +24,12 @@
*
* @param <P> the type of the plugin that owns this GUI
*/
@Getter
@NullMarked
public class GUI<P extends Plugin> extends AbstractGUI implements Listener {
protected final @Getter(AccessLevel.NONE) P plugin;
protected final P plugin;
private final Inventory inventory;
private final int size;
private @Setter boolean passUnknownClickTypes;
private boolean passUnknownClickTypes;

/**
* Construct a new GUI
Expand Down Expand Up @@ -118,4 +114,21 @@ public final void onInventoryClose(InventoryCloseEvent event) {
HandlerList.unregisterAll(this);
onClose();
}

@Override
public Inventory getInventory() {
return inventory;
}

public boolean isPassUnknownClickTypes() {
return passUnknownClickTypes;
}

public void setPassUnknownClickTypes(boolean passUnknownClickTypes) {
this.passUnknownClickTypes = passUnknownClickTypes;
}

public int getSize() {
return size;
}
}
6 changes: 4 additions & 2 deletions paper/src/main/java/core/paper/gui/PaginatedGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import core.paper.item.ActionItem;
import core.paper.item.ItemBuilder;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand All @@ -20,7 +19,6 @@
* @param <P> the type of plugin that owns this GUI
* @param <T> the type of elements rendered in this GUI
*/
@Getter
@NullMarked
public abstract class PaginatedGUI<P extends Plugin, T> extends GUI<P> {
private int currentPage;
Expand Down Expand Up @@ -183,4 +181,8 @@ public record Pagination(
int buttonSlotNext
) {
}

public int getCurrentPage() {
return currentPage;
}
}
26 changes: 19 additions & 7 deletions paper/src/main/java/core/paper/scoreboard/Sidebar.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package core.paper.scoreboard;

import io.papermc.paper.scoreboard.numbers.NumberFormat;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.*;
import org.bukkit.scoreboard.Criteria;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -135,9 +137,6 @@ private Team getTeam(int line) {
return team;
}

@Getter
@Accessors(fluent = true)
@RequiredArgsConstructor
private enum Line {
SCORE_1("§1", 1),
SCORE_2("§2", 2),
Expand All @@ -164,5 +163,18 @@ private static Line valueOf(int line) {
.findAny()
.orElseThrow();
}

Line(String color, int score) {
this.color = color;
this.score = score;
}

public int score() {
return score;
}

public String color() {
return color;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import core.version.github.GitHubVersionChecker;
import core.version.github.Release;
import io.papermc.paper.ServerBuildInfo;
import lombok.Getter;
import org.bukkit.plugin.Plugin;
import org.jspecify.annotations.NullMarked;

import java.util.Objects;

@Getter
@NullMarked
public abstract class PaperGitHubVersionChecker<V extends Version> extends GitHubVersionChecker<V> implements PluginVersionChecker {
private final V versionRunning;
Expand Down Expand Up @@ -80,4 +78,14 @@ private void printVersionInfo(V version) {
public boolean isSupported(Release version) {
return true;
}

@Override
public Plugin getPlugin() {
return plugin;
}

@Override
public V getVersionRunning() {
return versionRunning;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import core.version.hangar.HangarVersionChecker;
import core.version.hangar.Platform;
import io.papermc.paper.ServerBuildInfo;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.jspecify.annotations.NullMarked;
Expand All @@ -18,7 +17,6 @@
*
* @param <V> the type parameter for the version
*/
@Getter
@NullMarked
public abstract class PaperHangarVersionChecker<V extends Version> extends HangarVersionChecker<V> implements PluginVersionChecker {
private final V versionRunning;
Expand Down Expand Up @@ -91,4 +89,18 @@ public boolean isSupported(HangarVersion version) {
return version.platformDependencies().get(Platform.PAPER)
.contains(Bukkit.getMinecraftVersion());
}

@Override
public V getVersionRunning() {
return versionRunning;
}

@Override
public Plugin getPlugin() {
return plugin;
}

public String getAuthor() {
return author;
}
}

0 comments on commit 971ea25

Please sign in to comment.