Skip to content

Commit

Permalink
added package level annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSwag committed Jun 15, 2024
1 parent a88f9b8 commit 5b8666e
Show file tree
Hide file tree
Showing 34 changed files with 229 additions and 303 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ repositories {

dependencies {
compileOnly("org.projectlombok:lombok:1.18.32")
compileOnly("net.thenextlvl.core:annotations:2.0.1")
// Paper / Spigot
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
// Fawe / WorldEdit
Expand Down
35 changes: 15 additions & 20 deletions src/main/java/net/thenextlvl/gopaint/GoPaintPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.fastasyncworldedit.core.Fawe;
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;
Expand All @@ -43,25 +45,26 @@
import org.incendo.cloud.bukkit.CloudBukkitCapabilities;
import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.paper.LegacyPaperCommandManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.Locale;
import java.util.Objects;
import java.util.logging.Level;

@Getter
@Accessors(fluent = true)
public class GoPaintPlugin extends JavaPlugin implements Listener {

public static final @NotNull String PAPER_DOCS = "https://jd.papermc.io/paper/1.20.6/org/bukkit/Material.html#enum-constant-summary";
public static final String PAPER_DOCS = "https://jd.papermc.io/paper/1.20.6/org/bukkit/Material.html#enum-constant-summary";

public static final @NotNull String USE_PERMISSION = "bettergopaint.use";
public static final @NotNull String ADMIN_PERMISSION = "bettergopaint.admin";
public static final @NotNull String RELOAD_PERMISSION = "bettergopaint.command.admin.reload";
public static final @NotNull String WORLD_BYPASS_PERMISSION = "bettergopaint.world.bypass";
public static final String USE_PERMISSION = "bettergopaint.use";
public static final String ADMIN_PERMISSION = "bettergopaint.admin";
public static final String RELOAD_PERMISSION = "bettergopaint.command.admin.reload";
public static final String WORLD_BYPASS_PERMISSION = "bettergopaint.world.bypass";

private final @NotNull File translations = new File(getDataFolder(), "translations");
private final @NotNull ComponentBundle bundle = new ComponentBundle(translations, audience ->
private final File translations = new File(getDataFolder(), "translations");
private final ComponentBundle bundle = new ComponentBundle(translations, audience ->
audience instanceof Player player ? player.locale() : Locale.US)
.register("messages", Locale.US)
.register("messages_german", Locale.GERMANY)
Expand All @@ -70,8 +73,8 @@ public class GoPaintPlugin extends JavaPlugin implements Listener {
Placeholder.component("prefix", bundle.component(Locale.US, "prefix"))
)).build());

private final @NotNull PlayerBrushManager brushManager = new PlayerBrushManager(bundle);
private final @NotNull Metrics metrics = new Metrics(this, 22279);
private final PlayerBrushManager brushManager = new PlayerBrushManager(bundle);
private final Metrics metrics = new Metrics(this, 22279);

@Override
public void onLoad() {
Expand Down Expand Up @@ -131,9 +134,9 @@ private void registerCommands() {

private void registerListeners() {
PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new InventoryListener(getBrushManager()), this);
pm.registerEvents(new InventoryListener(brushManager()), this);
pm.registerEvents(new InteractListener(this), this);
pm.registerEvents(new ConnectListener(getBrushManager()), this);
pm.registerEvents(new ConnectListener(brushManager()), this);
}

private boolean hasOriginalGoPaint() {
Expand All @@ -158,12 +161,4 @@ private boolean hasOriginalGoPaint() {
}
}

public @NotNull PlayerBrushManager getBrushManager() {
return brushManager;
}

public ComponentBundle bundle() {
return bundle;
}

}
60 changes: 27 additions & 33 deletions src/main/java/net/thenextlvl/gopaint/brush/ExportedPlayerBrush.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,16 @@
import org.bukkit.Axis;
import org.bukkit.Material;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import java.util.*;

public record ExportedPlayerBrush(
@NotNull Brush brush,
Brush brush,
@Nullable Material mask,
@NotNull List<Material> blocks,
@NotNull Axis axis,
List<Material> blocks,
Axis axis,
SurfaceMode surfaceMode,
int size,
int chance,
Expand All @@ -51,9 +45,9 @@ public record ExportedPlayerBrush(
double angleHeightDifference
) implements BrushSettings {

private static final @NotNull Random RANDOM = new SecureRandom();
private static final Random RANDOM = new SecureRandom();

public ExportedPlayerBrush(@NotNull Builder builder) {
public ExportedPlayerBrush(Builder builder) {
this(
builder.brush,
builder.mask,
Expand Down Expand Up @@ -82,12 +76,12 @@ public boolean maskEnabled() {
}

@Override
public @NotNull Material randomBlock() {
public Material randomBlock() {
return blocks().get(random().nextInt(blocks().size()));
}

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

Expand All @@ -97,11 +91,11 @@ public static Builder builder(Brush brush) {

public static final class Builder {

private final @NotNull Brush brush;
private final Brush brush;

private @NotNull List<Material> blocks = Collections.emptyList();
private @NotNull Axis axis = Settings.settings().GENERIC.DEFAULT_AXIS;
private @NotNull SurfaceMode surfaceMode = SurfaceMode.DISABLED;
private List<Material> blocks = Collections.emptyList();
private Axis axis = Settings.settings().GENERIC.DEFAULT_AXIS;
private SurfaceMode surfaceMode = SurfaceMode.DISABLED;

private @Nullable Material mask;

Expand All @@ -114,78 +108,78 @@ public static final class Builder {
private int mixingStrength;
private double angleHeightDifference;

private Builder(@NotNull Brush brush) {
private Builder(Brush brush) {
this.brush = brush;
}

public @NotNull Builder surfaceMode(SurfaceMode surfaceMode) {
public Builder surfaceMode(SurfaceMode surfaceMode) {
this.surfaceMode = surfaceMode;
return this;
}

public @NotNull Builder blocks(@NotNull List<Material> blocks) {
public Builder blocks(List<Material> blocks) {
this.blocks = blocks;
return this;
}

public @NotNull Builder mask(@Nullable Material mask) {
public Builder mask(@Nullable Material mask) {
this.mask = mask;
return this;
}

public @NotNull Builder size(int size) {
public Builder size(int size) {
this.size = size;
return this;
}

public @NotNull Builder chance(int chance) {
public Builder chance(int chance) {
this.chance = chance;
return this;
}

public @NotNull Builder thickness(int thickness) {
public Builder thickness(int thickness) {
this.thickness = thickness;
return this;
}

public @NotNull Builder angleDistance(int angleDistance) {
public Builder angleDistance(int angleDistance) {
this.angleDistance = angleDistance;
return this;
}

public @NotNull Builder fractureDistance(int fractureDistance) {
public Builder fractureDistance(int fractureDistance) {
this.fractureDistance = fractureDistance;
return this;
}

public @NotNull Builder falloffStrength(int falloffStrength) {
public Builder falloffStrength(int falloffStrength) {
this.falloffStrength = falloffStrength;
return this;
}

public @NotNull Builder mixingStrength(int mixingStrength) {
public Builder mixingStrength(int mixingStrength) {
this.mixingStrength = mixingStrength;
return this;
}

public @NotNull Builder angleHeightDifference(double angleHeightDifference) {
public Builder angleHeightDifference(double angleHeightDifference) {
this.angleHeightDifference = angleHeightDifference;
return this;
}

public @NotNull Builder axis(@NotNull Axis axis) {
public Builder axis(Axis axis) {
this.axis = axis;
return this;
}

public @NotNull ExportedPlayerBrush build() {
public ExportedPlayerBrush build() {
return new ExportedPlayerBrush(this);
}

}

@Deprecated(forRemoval = true)
public static ExportedPlayerBrush parse(@NotNull Brush brush, @NotNull ItemMeta itemMeta) {
public static ExportedPlayerBrush parse(Brush brush, ItemMeta itemMeta) {
ExportedPlayerBrush.Builder builder = ExportedPlayerBrush.builder(brush);
Optional.ofNullable(itemMeta.getLore()).ifPresent(lore -> lore.stream()
.map(line -> line.replace("§8", ""))
Expand Down
31 changes: 11 additions & 20 deletions src/main/java/net/thenextlvl/gopaint/brush/PlayerBrush.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextDecoration;
import net.thenextlvl.gopaint.objects.brush.AngleBrush;
import net.thenextlvl.gopaint.objects.brush.Brush;
import net.thenextlvl.gopaint.objects.brush.DiscBrush;
import net.thenextlvl.gopaint.objects.brush.FractureBrush;
import net.thenextlvl.gopaint.objects.brush.GradientBrush;
import net.thenextlvl.gopaint.objects.brush.OverlayBrush;
import net.thenextlvl.gopaint.objects.brush.SplatterBrush;
import net.thenextlvl.gopaint.objects.brush.SprayBrush;
import net.thenextlvl.gopaint.objects.brush.UnderlayBrush;
import net.thenextlvl.gopaint.objects.brush.*;
import net.thenextlvl.gopaint.objects.other.Settings;
import net.thenextlvl.gopaint.objects.other.SurfaceMode;
import net.thenextlvl.gopaint.utils.GUI;
Expand All @@ -44,7 +36,6 @@
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.security.SecureRandom;
import java.util.ArrayList;
Expand All @@ -60,8 +51,8 @@
@Accessors(fluent = true)
public final class PlayerBrush implements BrushSettings {

private final @NotNull PlayerBrushManager brushManager;
private final @NotNull Random random = new SecureRandom();
private final PlayerBrushManager brushManager;
private final Random random = new SecureRandom();

private boolean maskEnabled;
private boolean enabled;
Expand All @@ -73,16 +64,16 @@ public final class PlayerBrush implements BrushSettings {
private int falloffStrength;
private int mixingStrength;
private double angleHeightDifference;
private @NotNull Axis axis;
private @NotNull SurfaceMode surfaceMode;
private Axis axis;
private SurfaceMode surfaceMode;

private @NotNull Brush brush;
private @NotNull Material mask;
private final @NotNull List<Material> blocks = new ArrayList<>();
private Brush brush;
private Material mask;
private final List<Material> blocks = new ArrayList<>();

private final @NotNull Inventory gui;
private final Inventory gui;

public PlayerBrush(@NotNull PlayerBrushManager brushManager) {
public PlayerBrush(PlayerBrushManager brushManager) {
this.brushManager = brushManager;

surfaceMode = Settings.settings().GENERIC.SURFACE_MODE;
Expand All @@ -103,7 +94,7 @@ public PlayerBrush(@NotNull PlayerBrushManager brushManager) {
gui = GUI.create(this);
}

public @NotNull Material randomBlock() {
public Material randomBlock() {
return blocks().get(random.nextInt(blocks().size()));
}

Expand Down
Loading

0 comments on commit 5b8666e

Please sign in to comment.