Skip to content

Commit

Permalink
added lombok
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSwag committed Jun 15, 2024
1 parent 845690d commit dc2f68c
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 226 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ repositories {
}

dependencies {
compileOnly("org.projectlombok:lombok:1.18.32")
// Paper / Spigot
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
// Fawe / WorldEdit
Expand All @@ -36,6 +37,7 @@ dependencies {
implementation("org.incendo:cloud-paper:2.0.0-beta.8")
implementation("org.incendo:cloud-annotations:2.0.0-rc.2")
annotationProcessor("org.incendo:cloud-annotations:2.0.0-rc.2")
annotationProcessor("org.projectlombok:lombok:1.18.32")
}

paper {
Expand Down
89 changes: 6 additions & 83 deletions src/main/java/net/thenextlvl/gopaint/brush/PlayerBrush.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package net.thenextlvl.gopaint.brush;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
Expand Down Expand Up @@ -52,6 +55,9 @@
/**
* The PlayerBrush class represents the brush settings of a player.
*/
@Getter
@Setter
@Accessors(fluent = true)
public final class PlayerBrush implements BrushSettings {

private final @NotNull PlayerBrushManager brushManager;
Expand Down Expand Up @@ -101,89 +107,6 @@ public PlayerBrush(@NotNull PlayerBrushManager brushManager) {
return blocks().get(random.nextInt(blocks().size()));
}

@Override
public @NotNull Brush brush() {
return brush;
}

public void setBrush(@NotNull Brush brush) {
this.brush = brush;
}

@Override
public @NotNull Random random() {
return random;
}

@Override
public int falloffStrength() {
return falloffStrength;
}

@Override
public int mixingStrength() {
return mixingStrength;
}

@Override
public double angleHeightDifference() {
return this.angleHeightDifference;
}

@Override
public int angleDistance() {
return this.angleDistance;
}

@Override
public int fractureDistance() {
return this.fractureDistance;
}

@Override
public @NotNull Material mask() {
return mask;
}

@Override
public @NotNull List<Material> blocks() {
return blocks;
}

@Override
public int size() {
return size;
}

public boolean enabled() {
return enabled;
}

@Override
public boolean maskEnabled() {
return maskEnabled;
}

@Override
public int chance() {
return chance;
}

@Override
public SurfaceMode surfaceMode() {
return surfaceMode;
}

@Override
public int thickness() {
return thickness;
}

@Override
public @NotNull Axis axis() {
return axis;
}

public void updateInventory() {
GUI.update(gui, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@
*/
package net.thenextlvl.gopaint.command;

import lombok.RequiredArgsConstructor;
import net.thenextlvl.gopaint.GoPaintPlugin;
import org.bukkit.entity.Player;
import org.incendo.cloud.annotations.Command;
import org.incendo.cloud.annotations.Permission;

@RequiredArgsConstructor
public final class ReloadCommand {

private final GoPaintPlugin plugin;

public ReloadCommand(final GoPaintPlugin plugin) {
this.plugin = plugin;
}

@Command("bgp|gp reload")
@Permission(GoPaintPlugin.RELOAD_PERMISSION)
public void onReload(Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,19 @@
*/
package net.thenextlvl.gopaint.listeners;

import lombok.RequiredArgsConstructor;
import net.thenextlvl.gopaint.brush.PlayerBrushManager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;

@RequiredArgsConstructor
public class ConnectListener implements Listener {

private final PlayerBrushManager brushManager;

public ConnectListener(PlayerBrushManager brushManager) {
this.brushManager = brushManager;
}

@EventHandler(priority = EventPriority.LOWEST)
public void onQuit(PlayerQuitEvent event) {
brushManager.removeBrush(event.getPlayer());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package net.thenextlvl.gopaint.listeners;

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.TextComponent;
import net.thenextlvl.gopaint.GoPaintPlugin;
import net.thenextlvl.gopaint.brush.BrushSettings;
Expand All @@ -40,14 +41,10 @@

import java.util.Optional;

@RequiredArgsConstructor
public final class InteractListener implements Listener {

private final GoPaintPlugin plugin;

public InteractListener(GoPaintPlugin plugin) {
this.plugin = plugin;
}

@EventHandler(priority = EventPriority.LOWEST)
public void onClick(PlayerInteractEvent event) {
Player player = event.getPlayer();
Expand Down Expand Up @@ -120,5 +117,4 @@ public void onClick(PlayerInteractEvent event) {
plugin.bundle().sendMessage(player, "brush.disabled");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package net.thenextlvl.gopaint.listeners;

import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.TextComponent;
import net.thenextlvl.gopaint.brush.PlayerBrush;
import net.thenextlvl.gopaint.brush.PlayerBrushManager;
Expand All @@ -43,14 +44,10 @@
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.ItemMeta;

@RequiredArgsConstructor
public final class InventoryListener implements Listener {

private final PlayerBrushManager brushManager;

public InventoryListener(PlayerBrushManager brushManager) {
this.brushManager = brushManager;
}

@EventHandler(priority = EventPriority.LOWEST)
public void menuClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player player)) {
Expand Down Expand Up @@ -221,10 +218,9 @@ public void menuBrushClick(InventoryClickEvent event) {
//noinspection deprecation
String name = itemMeta.getDisplayName().replace("§6", "");
brushManager.getBrushHandler(name).ifPresent(brush -> {
playerBrush.setBrush(brush);
playerBrush.brush(brush);
playerBrush.updateInventory();
player.openInventory(playerBrush.getInventory());
});
}

}
37 changes: 4 additions & 33 deletions src/main/java/net/thenextlvl/gopaint/objects/brush/Brush.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.math.BlockVector3;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.thenextlvl.gopaint.brush.BrushSettings;
import net.thenextlvl.gopaint.utils.Surface;
import org.bukkit.Location;
Expand All @@ -35,43 +37,12 @@

import java.util.function.Consumer;

@Getter
@RequiredArgsConstructor
public abstract class Brush {

private final @NotNull String name, description, head;

protected Brush(@NotNull String name, @NotNull String description, @NotNull String head) {
this.description = description;
this.name = name;
this.head = head;
}

/**
* Retrieves the description of the brush.
*
* @return The description of the brush.
*/
public @NotNull String getDescription() {
return description;
}

/**
* Retrieves the head of the brush.
*
* @return The head of the brush.
*/
public @NotNull String getHead() {
return head;
}

/**
* Retrieves the name of the brush.
*
* @return The name of the brush.
*/
public @NotNull String getName() {
return name;
}

/**
* Performs a painting action using the provided location, player, and brush settings.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package net.thenextlvl.gopaint.objects.other;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.thenextlvl.gopaint.utils.Surface;
import org.bukkit.Location;
import org.bukkit.block.Block;
Expand All @@ -26,6 +28,8 @@
import java.util.Arrays;
import java.util.Optional;

@Getter
@RequiredArgsConstructor
public enum SurfaceMode {
/**
* This enumeration represents a more intuitive check.
Expand All @@ -48,14 +52,6 @@ public enum SurfaceMode {

private final @NotNull String name;

SurfaceMode(@NotNull String name) {
this.name = name;
}

public @NotNull String getName() {
return name;
}

public static @NotNull Optional<SurfaceMode> byName(@NotNull String name) {
return Arrays.stream(values())
.filter(surfaceMode -> surfaceMode.getName().equals(name))
Expand Down
Loading

0 comments on commit dc2f68c

Please sign in to comment.