diff --git a/build.gradle.kts b/build.gradle.kts index 37a10860..1a6cf4b2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 diff --git a/src/main/java/net/thenextlvl/gopaint/GoPaintPlugin.java b/src/main/java/net/thenextlvl/gopaint/GoPaintPlugin.java index ee4f3b6d..f2dbc658 100644 --- a/src/main/java/net/thenextlvl/gopaint/GoPaintPlugin.java +++ b/src/main/java/net/thenextlvl/gopaint/GoPaintPlugin.java @@ -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; @@ -43,7 +45,6 @@ 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; @@ -51,17 +52,19 @@ 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) @@ -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() { @@ -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() { @@ -158,12 +161,4 @@ private boolean hasOriginalGoPaint() { } } - public @NotNull PlayerBrushManager getBrushManager() { - return brushManager; - } - - public ComponentBundle bundle() { - return bundle; - } - } diff --git a/src/main/java/net/thenextlvl/gopaint/brush/ExportedPlayerBrush.java b/src/main/java/net/thenextlvl/gopaint/brush/ExportedPlayerBrush.java index 49c6a7db..4c7a7168 100644 --- a/src/main/java/net/thenextlvl/gopaint/brush/ExportedPlayerBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/brush/ExportedPlayerBrush.java @@ -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 blocks, - @NotNull Axis axis, + List blocks, + Axis axis, SurfaceMode surfaceMode, int size, int chance, @@ -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, @@ -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; } @@ -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 blocks = Collections.emptyList(); - private @NotNull Axis axis = Settings.settings().GENERIC.DEFAULT_AXIS; - private @NotNull SurfaceMode surfaceMode = SurfaceMode.DISABLED; + private List blocks = Collections.emptyList(); + private Axis axis = Settings.settings().GENERIC.DEFAULT_AXIS; + private SurfaceMode surfaceMode = SurfaceMode.DISABLED; private @Nullable Material mask; @@ -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 blocks) { + public Builder blocks(List 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", "")) diff --git a/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrush.java b/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrush.java index 74fac7d8..7418d882 100644 --- a/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrush.java @@ -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; @@ -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; @@ -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; @@ -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 blocks = new ArrayList<>(); + private Brush brush; + private Material mask; + private final List 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; @@ -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())); } diff --git a/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrushManager.java b/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrushManager.java index 87ab14f1..0950f634 100644 --- a/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrushManager.java +++ b/src/main/java/net/thenextlvl/gopaint/brush/PlayerBrushManager.java @@ -20,20 +20,9 @@ import com.google.common.collect.ImmutableList; import core.i18n.file.ComponentBundle; -import net.thenextlvl.gopaint.objects.brush.AngleBrush; -import net.thenextlvl.gopaint.objects.brush.Brush; -import net.thenextlvl.gopaint.objects.brush.BucketBrush; -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.PaintBrush; -import net.thenextlvl.gopaint.objects.brush.SphereBrush; -import net.thenextlvl.gopaint.objects.brush.SplatterBrush; -import net.thenextlvl.gopaint.objects.brush.SprayBrush; -import net.thenextlvl.gopaint.objects.brush.UnderlayBrush; +import lombok.Getter; +import net.thenextlvl.gopaint.objects.brush.*; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashMap; @@ -46,9 +35,8 @@ * The PlayerBrushManager class manages the brush selection for each player. */ public class PlayerBrushManager { - - private final @NotNull HashMap playerBrushes = new HashMap<>(); - private final @NotNull List brushes; + private final HashMap playerBrushes = new HashMap<>(); + private final @Getter List brushes; public PlayerBrushManager(ComponentBundle bundle) { brushes = ImmutableList.of( @@ -72,7 +60,7 @@ public PlayerBrushManager(ComponentBundle bundle) { * @param player The player for which to retrieve the brush. * @return The brush for the specified player. */ - public @NotNull PlayerBrush getBrush(@NotNull Player player) { + public PlayerBrush getBrush(Player player) { return playerBrushes.computeIfAbsent(player.getUniqueId(), ignored -> new PlayerBrush(this)); } @@ -83,7 +71,7 @@ public PlayerBrushManager(ComponentBundle bundle) { * @param brush The brush for which to retrieve the lore. * @return The lore for the specified brush. */ - public @NotNull String getBrushLore(@NotNull Brush brush) { + public String getBrushLore(Brush brush) { return brushes.stream().map(current -> { if (current.equals(brush)) { return "§e" + current.getName() + "\n"; @@ -99,27 +87,18 @@ public PlayerBrushManager(ComponentBundle bundle) { * @param name The name of the brush to look for. * @return An optional containing the brush handler, or empty if not found. */ - public @NotNull Optional getBrushHandler(String name) { + public Optional getBrushHandler(String name) { return brushes.stream() .filter(brush -> name.contains(brush.getName())) .findAny(); } - /** - * Retrieves the list of available brushes. - * - * @return The list of available brushes. - */ - public @NotNull List getBrushes() { - return brushes; - } - /** * Removes the player from the {@link #playerBrushes} map. * * @param player The player who should be removed. */ - public void removeBrush(@NotNull Player player) { + public void removeBrush(Player player) { playerBrushes.remove(player.getUniqueId()); } @@ -129,7 +108,7 @@ public void removeBrush(@NotNull Player player) { * @param brush The current brush, if null returns the first brush in the list. * @return The next brush in the list, or the first brush if the current brush is null. */ - public @NotNull Brush cycleForward(@Nullable Brush brush) { + public Brush cycleForward(@Nullable Brush brush) { if (brush == null) { return brushes.getFirst(); } @@ -146,7 +125,7 @@ public void removeBrush(@NotNull Player player) { * @param brush The current brush. * @return The previous brush in the list, or the first brush if the current brush is null. */ - public @NotNull Brush cycleBack(@Nullable Brush brush) { + public Brush cycleBack(@Nullable Brush brush) { if (brush == null) { return brushes.getFirst(); } diff --git a/src/main/java/net/thenextlvl/gopaint/brush/package-info.java b/src/main/java/net/thenextlvl/gopaint/brush/package-info.java new file mode 100644 index 00000000..3377417b --- /dev/null +++ b/src/main/java/net/thenextlvl/gopaint/brush/package-info.java @@ -0,0 +1,10 @@ +@TypesAreNotNullByDefault +@FieldsAreNotNullByDefault +@MethodsReturnNotNullByDefault +@ParametersAreNotNullByDefault +package net.thenextlvl.gopaint.brush; + +import core.annotation.FieldsAreNotNullByDefault; +import core.annotation.MethodsReturnNotNullByDefault; +import core.annotation.ParametersAreNotNullByDefault; +import core.annotation.TypesAreNotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/thenextlvl/gopaint/command/GoPaintCommand.java b/src/main/java/net/thenextlvl/gopaint/command/GoPaintCommand.java index c7c72dbf..fba8dddc 100644 --- a/src/main/java/net/thenextlvl/gopaint/command/GoPaintCommand.java +++ b/src/main/java/net/thenextlvl/gopaint/command/GoPaintCommand.java @@ -18,6 +18,7 @@ */ package net.thenextlvl.gopaint.command; +import lombok.Getter; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.thenextlvl.gopaint.GoPaintPlugin; import net.thenextlvl.gopaint.brush.PlayerBrush; @@ -25,13 +26,11 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.PluginIdentifiableCommand; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; import java.util.List; +@Getter public class GoPaintCommand extends Command implements PluginIdentifiableCommand { - private final GoPaintPlugin plugin; public GoPaintCommand(GoPaintPlugin main) { @@ -40,15 +39,11 @@ public GoPaintCommand(GoPaintPlugin main) { } @Override - public boolean execute( - @NotNull final CommandSender sender, - @NotNull final String commandLabel, - final @NotNull String[] args - ) { + public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!(sender instanceof final Player p)) { return false; } - PlayerBrush pb = plugin.getBrushManager().getBrush(p); + PlayerBrush pb = plugin.brushManager().getBrush(p); if (!p.hasPermission(GoPaintPlugin.USE_PERMISSION)) { plugin.bundle().sendMessage(p, "command.gopaint.permission"); return true; @@ -113,9 +108,4 @@ public boolean execute( return false; } - @Override - public @NotNull Plugin getPlugin() { - return plugin; - } - } diff --git a/src/main/java/net/thenextlvl/gopaint/command/package-info.java b/src/main/java/net/thenextlvl/gopaint/command/package-info.java new file mode 100644 index 00000000..f602b2b3 --- /dev/null +++ b/src/main/java/net/thenextlvl/gopaint/command/package-info.java @@ -0,0 +1,11 @@ + +@TypesAreNotNullByDefault +@FieldsAreNotNullByDefault +@MethodsReturnNotNullByDefault +@ParametersAreNotNullByDefault +package net.thenextlvl.gopaint.command; + +import core.annotation.FieldsAreNotNullByDefault; +import core.annotation.MethodsReturnNotNullByDefault; +import core.annotation.ParametersAreNotNullByDefault; +import core.annotation.TypesAreNotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/thenextlvl/gopaint/listeners/InteractListener.java b/src/main/java/net/thenextlvl/gopaint/listeners/InteractListener.java index 2c04a8e6..b58c01b9 100644 --- a/src/main/java/net/thenextlvl/gopaint/listeners/InteractListener.java +++ b/src/main/java/net/thenextlvl/gopaint/listeners/InteractListener.java @@ -59,7 +59,7 @@ public void onClick(PlayerInteractEvent event) { } if (event.getAction().isLeftClick() && item.getType() == Settings.settings().GENERIC.DEFAULT_BRUSH) { - PlayerBrush brush = plugin.getBrushManager().getBrush(player); + PlayerBrush brush = plugin.brushManager().getBrush(player); player.openInventory(brush.getInventory()); event.setCancelled(true); return; @@ -95,12 +95,12 @@ public void onClick(PlayerInteractEvent event) { if (itemMeta != null && itemMeta.hasLore() && itemMeta.displayName() instanceof TextComponent name) { - Optional brush = plugin.getBrushManager().getBrushHandler(name.content()); + Optional brush = plugin.brushManager().getBrushHandler(name.content()); //noinspection removal brushSettings = brush.map(current -> ExportedPlayerBrush.parse(current, itemMeta)).orElse(null); } else if (item.getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) { - brushSettings = plugin.getBrushManager().getBrush(player); + brushSettings = plugin.brushManager().getBrush(player); } else { return; } diff --git a/src/main/java/net/thenextlvl/gopaint/listeners/package-info.java b/src/main/java/net/thenextlvl/gopaint/listeners/package-info.java new file mode 100644 index 00000000..d540a4a1 --- /dev/null +++ b/src/main/java/net/thenextlvl/gopaint/listeners/package-info.java @@ -0,0 +1,10 @@ +@TypesAreNotNullByDefault +@FieldsAreNotNullByDefault +@MethodsReturnNotNullByDefault +@ParametersAreNotNullByDefault +package net.thenextlvl.gopaint.listeners; + +import core.annotation.FieldsAreNotNullByDefault; +import core.annotation.MethodsReturnNotNullByDefault; +import core.annotation.ParametersAreNotNullByDefault; +import core.annotation.TypesAreNotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/AngleBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/AngleBrush.java index e509d093..df95260e 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/AngleBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/AngleBrush.java @@ -24,26 +24,21 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class AngleBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Only works on cliffs"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRlNDQ4ZjBkYmU3NmJiOGE4MzJjOGYzYjJhMDNkMzViZDRlMjc4NWZhNWU4Mjk4YzI2MTU1MDNmNDdmZmEyIn19fQ=="; - private static final @NotNull String NAME = "Angle Brush"; + private static final String DESCRIPTION = "Only works on cliffs"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRlNDQ4ZjBkYmU3NmJiOGE4MzJjOGYzYjJhMDNkMzViZDRlMjc4NWZhNWU4Mjk4YzI2MTU1MDNmNDdmZmEyIn19fQ=="; + private static final String NAME = "Angle Brush"; public AngleBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); blocks.filter(block -> passesDefaultChecks(brushSettings, player, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/Brush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/Brush.java index a44e3c99..21d07d62 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/Brush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/Brush.java @@ -33,7 +33,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -41,7 +40,7 @@ @RequiredArgsConstructor public abstract class Brush { - private final @NotNull String name, description, head; + private final String name, description, head; /** * Performs a painting action using the provided location, player, and brush settings. @@ -50,11 +49,7 @@ public abstract class Brush { * @param player The player who is performing the paint action. * @param brushSettings The brush settings to be applied while painting. */ - public abstract void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ); + public abstract void paint(Location location, Player player, BrushSettings brushSettings); /** * Sets the material of a block in an EditSession. @@ -64,11 +59,7 @@ public abstract void paint( * @param material The material to set the block to. * @throws MaxChangedBlocksException If the maximum number of changed blocks is exceeded. */ - protected void setBlock( - @NotNull EditSession session, - @NotNull Block block, - @NotNull Material material - ) throws MaxChangedBlocksException { + protected void setBlock(EditSession session, Block block, Material material) throws MaxChangedBlocksException { BlockVector3 vector = BlockVector3.at(block.getX(), block.getY(), block.getZ()); if (session.getMask() == null || session.getMask().test(vector)) { session.setBlock(vector, BukkitAdapter.asBlockType(material)); @@ -102,7 +93,7 @@ protected void performEdit(Player player, Consumer edit) { * @param block The block being checked. * @return true if the block passes all the default checks, false otherwise. */ - protected boolean passesDefaultChecks(@NotNull BrushSettings brushSettings, @NotNull Player player, @NotNull Block block) { + protected boolean passesDefaultChecks(BrushSettings brushSettings, Player player, Block block) { return passesMaskCheck(brushSettings, block) && passesSurfaceCheck(brushSettings, player, block); } @@ -114,7 +105,7 @@ protected boolean passesDefaultChecks(@NotNull BrushSettings brushSettings, @Not * @param block The block being checked. * @return true if the block passes the surface check, false otherwise. */ - protected boolean passesSurfaceCheck(@NotNull BrushSettings brushSettings, @NotNull Player player, @NotNull Block block) { + protected boolean passesSurfaceCheck(BrushSettings brushSettings, Player player, Block block) { return Surface.isOnSurface(block, brushSettings.surfaceMode(), player.getLocation()); } @@ -125,7 +116,7 @@ protected boolean passesSurfaceCheck(@NotNull BrushSettings brushSettings, @NotN * @param block The block being checked. * @return true if the block passes the mask check, false otherwise. */ - protected boolean passesMaskCheck(@NotNull BrushSettings brushSettings, @NotNull Block block) { + protected boolean passesMaskCheck(BrushSettings brushSettings, Block block) { return !brushSettings.maskEnabled() || block.getType().equals(brushSettings.mask()); } diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/BucketBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/BucketBrush.java index e94323ec..8c2398b8 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/BucketBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/BucketBrush.java @@ -24,27 +24,22 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.stream.Stream; public class BucketBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Paints connected blocks\n§8with the same block type"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTAxOGI0NTc0OTM5Nzg4YTJhZDU1NTJiOTEyZDY3ODEwNjk4ODhjNTEyMzRhNGExM2VhZGI3ZDRjOTc5YzkzIn19fQ=="; - private static final @NotNull String NAME = "Bucket Brush"; + private static final String DESCRIPTION = "Paints connected blocks\n§8with the same block type"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTAxOGI0NTc0OTM5Nzg4YTJhZDU1NTJiOTEyZDY3ODEwNjk4ODhjNTEyMzRhNGExM2VhZGI3ZDRjOTc5YzkzIn19fQ=="; + private static final String NAME = "Bucket Brush"; public BucketBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { List blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false).toList(); Stream connectedBlocks = ConnectedBlocks.getConnectedBlocks(location, blocks); diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/DiscBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/DiscBrush.java index c78a2771..baa0c5ca 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/DiscBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/DiscBrush.java @@ -23,26 +23,21 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class DiscBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Paints blocks in the\n§8same selected axis\n§8from the block you clicked"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjFmMjgyNTBkMWU0MjBhNjUxMWIwMzk2NDg2OGZjYTJmNTYzN2UzYWJhNzlmNGExNjNmNGE4ZDYxM2JlIn19fQ=="; - private static final @NotNull String NAME = "Disc Brush"; + private static final String DESCRIPTION = "Paints blocks in the\n§8same selected axis\n§8from the block you clicked"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjFmMjgyNTBkMWU0MjBhNjUxMWIwMzk2NDg2OGZjYTJmNTYzN2UzYWJhNzlmNGExNjNmNGE4ZDYxM2JlIn19fQ=="; + private static final String NAME = "Disc Brush"; public DiscBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), brushSettings.axis(), false); blocks.filter(block -> passesDefaultChecks(brushSettings, player, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/FractureBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/FractureBrush.java index d453e16e..7a4522c7 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/FractureBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/FractureBrush.java @@ -24,26 +24,21 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class FractureBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Places blocks in cracks/fisures"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjNkZjczZWVlNjIyNGM1YzVkOTQ4ZDJhMzQ1ZGUyNWYyMDhjYmQ5YWY3MTA4Y2UxZTFiNjFhNTg2ZGU5OGIyIn19fQ=="; - private static final @NotNull String NAME = "Fracture Brush"; + private static final String DESCRIPTION = "Places blocks in cracks/fisures"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjNkZjczZWVlNjIyNGM1YzVkOTQ4ZDJhMzQ1ZGUyNWYyMDhjYmQ5YWY3MTA4Y2UxZTFiNjFhNTg2ZGU5OGIyIn19fQ=="; + private static final String NAME = "Fracture Brush"; public FractureBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); blocks.filter(block -> passesMaskCheck(brushSettings, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/GradientBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/GradientBrush.java index fbeb6f37..fc0bab7b 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/GradientBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/GradientBrush.java @@ -23,26 +23,21 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class GradientBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Creates gradients"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjA2MmRhM2QzYjhmMWZkMzUzNDNjYzI3OWZiMGZlNWNmNGE1N2I1YWJjNDMxZmJiNzhhNzNiZjJhZjY3NGYifX19"; - private static final @NotNull String NAME = "Gradient Brush"; + private static final String DESCRIPTION = "Creates gradients"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjA2MmRhM2QzYjhmMWZkMzUzNDNjYzI3OWZiMGZlNWNmNGE1N2I1YWJjNDMxZmJiNzhhNzNiZjJhZjY3NGYifX19"; + private static final String NAME = "Gradient Brush"; public GradientBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { double y = location.getBlockY() - (brushSettings.size() / 2d); Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/OverlayBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/OverlayBrush.java index 8eb3c352..35022d87 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/OverlayBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/OverlayBrush.java @@ -24,26 +24,21 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class OverlayBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Only paints blocks\n§8that have air above it"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGYzMWQ2Zjk2NTRmODc0ZWE5MDk3YWRlZWEwYzk2OTk2ZTc4ZTNmZDM3NTRmYmY5ZWJlOTYzYWRhZDliZTRjIn19fQ=="; - private static final @NotNull String NAME = "Overlay Brush"; + private static final String DESCRIPTION = "Only paints blocks\n§8that have air above it"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGYzMWQ2Zjk2NTRmODc0ZWE5MDk3YWRlZWEwYzk2OTk2ZTc4ZTNmZDM3NTRmYmY5ZWJlOTYzYWRhZDliZTRjIn19fQ=="; + private static final String NAME = "Overlay Brush"; public OverlayBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); blocks.filter(block -> passesMaskCheck(brushSettings, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/PaintBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/PaintBrush.java index 33a15bc9..1aecb8e3 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/PaintBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/PaintBrush.java @@ -27,24 +27,19 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.stream.Stream; public class PaintBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Paints strokes\n§8hold shift to end"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBiM2E5ZGZhYmVmYmRkOTQ5YjIxN2JiZDRmYTlhNDg2YmQwYzNmMGNhYjBkMGI5ZGZhMjRjMzMyZGQzZTM0MiJ9fX0="; - private static final @NotNull String NAME = "Paint Brush"; + private static final String DESCRIPTION = "Paints strokes\n§8hold shift to end"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBiM2E5ZGZhYmVmYmRkOTQ5YjIxN2JiZDRmYTlhNDg2YmQwYzNmMGNhYjBkMGI5ZGZhMjRjMzMyZGQzZTM0MiJ9fX0="; + private static final String NAME = "Paint Brush"; - private final @NotNull ComponentBundle bundle; + private final ComponentBundle bundle; - public PaintBrush(@NotNull ComponentBundle bundle) { + public PaintBrush(ComponentBundle bundle) { super(NAME, DESCRIPTION, HEAD); this.bundle = bundle; } @@ -52,11 +47,7 @@ public PaintBrush(@NotNull ComponentBundle bundle) { private static final HashMap> selectedPoints = new HashMap<>(); @Override - public void paint( - @NotNull Location target, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location target, Player player, BrushSettings brushSettings) { List locations = selectedPoints.computeIfAbsent(player.getUniqueId(), ignored -> new ArrayList<>()); locations.add(target); diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/SphereBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/SphereBrush.java index 3e7739a8..d2b72e41 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/SphereBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/SphereBrush.java @@ -23,26 +23,21 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class SphereBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Regular sphere brush"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmU5OGY0ODU2MDE0N2MwYTJkNGVkYzE3ZjZkOTg1ZThlYjVkOTRiZDcyZmM2MDc0NGE1YThmMmQ5MDVhMTgifX19"; - private static final @NotNull String NAME = "Sphere Brush"; + private static final String DESCRIPTION = "Regular sphere brush"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmU5OGY0ODU2MDE0N2MwYTJkNGVkYzE3ZjZkOTg1ZThlYjVkOTRiZDcyZmM2MDc0NGE1YThmMmQ5MDVhMTgifX19"; + private static final String NAME = "Sphere Brush"; public SphereBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); blocks.filter(block -> passesDefaultChecks(brushSettings, player, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/SplatterBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/SplatterBrush.java index 78dad64d..9fb4cf41 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/SplatterBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/SplatterBrush.java @@ -23,26 +23,21 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class SplatterBrush extends Brush { - private static final @NotNull String DESCRIPTION = "More chance when closer\n§8to the clicked point\n§8and configurable chance"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzMzODI5MmUyZTY5ZjA5MDY5NGNlZjY3MmJiNzZmMWQ4Mzc1OGQxMjc0NGJiNmZmYzY4MzRmZGJjMWE5ODMifX19"; - private static final @NotNull String NAME = "Splatter Brush"; + private static final String DESCRIPTION = "More chance when closer\n§8to the clicked point\n§8and configurable chance"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzMzODI5MmUyZTY5ZjA5MDY5NGNlZjY3MmJiNzZmMWQ4Mzc1OGQxMjc0NGJiNmZmYzY4MzRmZGJjMWE5ODMifX19"; + private static final String NAME = "Splatter Brush"; public SplatterBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); blocks.filter(block -> passesDefaultChecks(brushSettings, player, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/SprayBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/SprayBrush.java index 36fdcb49..2ac63bec 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/SprayBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/SprayBrush.java @@ -23,26 +23,21 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class SprayBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Configurable random chance brush"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjg4MGY3NjVlYTgwZGVlMzcwODJkY2RmZDk4MTJlZTM2ZmRhODg0ODY5MmE4NDFiZWMxYmJkOWVkNTFiYTIyIn19fQ=="; - private static final @NotNull String NAME = "Spray Brush"; + private static final String DESCRIPTION = "Configurable random chance brush"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjg4MGY3NjVlYTgwZGVlMzcwODJkY2RmZDk4MTJlZTM2ZmRhODg0ODY5MmE4NDFiZWMxYmJkOWVkNTFiYTIyIn19fQ=="; + private static final String NAME = "Spray Brush"; public SprayBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); blocks.filter(block -> passesDefaultChecks(brushSettings, player, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/UnderlayBrush.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/UnderlayBrush.java index d6876a77..1df216d3 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/brush/UnderlayBrush.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/UnderlayBrush.java @@ -24,26 +24,21 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.stream.Stream; public class UnderlayBrush extends Brush { - private static final @NotNull String DESCRIPTION = "Only paints blocks\n§8that have no air above it"; - private static final @NotNull String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzIzNDQ2OTkwZjU4YjY1M2FiNWYwZTdhZjNmZGM3NTYwOTEyNzVmNGMzYzJkZDQxYzdkODYyZGQzZjkyZTg0YSJ9fX0="; - private static final @NotNull String NAME = "Underlay Brush"; + private static final String DESCRIPTION = "Only paints blocks\n§8that have no air above it"; + private static final String HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzIzNDQ2OTkwZjU4YjY1M2FiNWYwZTdhZjNmZGM3NTYwOTEyNzVmNGMzYzJkZDQxYzdkODYyZGQzZjkyZTg0YSJ9fX0="; + private static final String NAME = "Underlay Brush"; public UnderlayBrush() { super(NAME, DESCRIPTION, HEAD); } @Override - public void paint( - @NotNull Location location, - @NotNull Player player, - @NotNull BrushSettings brushSettings - ) { + public void paint(Location location, Player player, BrushSettings brushSettings) { performEdit(player, session -> { Stream blocks = Sphere.getBlocksInRadius(location, brushSettings.size(), null, false); blocks.filter(block -> passesMaskCheck(brushSettings, block)) diff --git a/src/main/java/net/thenextlvl/gopaint/objects/brush/package-info.java b/src/main/java/net/thenextlvl/gopaint/objects/brush/package-info.java new file mode 100644 index 00000000..11cc5935 --- /dev/null +++ b/src/main/java/net/thenextlvl/gopaint/objects/brush/package-info.java @@ -0,0 +1,10 @@ +@TypesAreNotNullByDefault +@FieldsAreNotNullByDefault +@MethodsReturnNotNullByDefault +@ParametersAreNotNullByDefault +package net.thenextlvl.gopaint.objects.brush; + +import core.annotation.FieldsAreNotNullByDefault; +import core.annotation.MethodsReturnNotNullByDefault; +import core.annotation.ParametersAreNotNullByDefault; +import core.annotation.TypesAreNotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/thenextlvl/gopaint/objects/other/SurfaceMode.java b/src/main/java/net/thenextlvl/gopaint/objects/other/SurfaceMode.java index 8c552fce..35d9b4fc 100644 --- a/src/main/java/net/thenextlvl/gopaint/objects/other/SurfaceMode.java +++ b/src/main/java/net/thenextlvl/gopaint/objects/other/SurfaceMode.java @@ -23,7 +23,6 @@ import net.thenextlvl.gopaint.utils.Surface; import org.bukkit.Location; import org.bukkit.block.Block; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.Optional; @@ -50,9 +49,9 @@ public enum SurfaceMode { */ RELATIVE("Relative"); - private final @NotNull String name; + private final String name; - public static @NotNull Optional byName(@NotNull String name) { + public static Optional byName(String name) { return Arrays.stream(values()) .filter(surfaceMode -> surfaceMode.getName().equals(name)) .findAny(); diff --git a/src/main/java/net/thenextlvl/gopaint/objects/other/package-info.java b/src/main/java/net/thenextlvl/gopaint/objects/other/package-info.java new file mode 100644 index 00000000..c79226a8 --- /dev/null +++ b/src/main/java/net/thenextlvl/gopaint/objects/other/package-info.java @@ -0,0 +1,10 @@ +@TypesAreNotNullByDefault +@FieldsAreNotNullByDefault +@MethodsReturnNotNullByDefault +@ParametersAreNotNullByDefault +package net.thenextlvl.gopaint.objects.other; + +import core.annotation.FieldsAreNotNullByDefault; +import core.annotation.MethodsReturnNotNullByDefault; +import core.annotation.ParametersAreNotNullByDefault; +import core.annotation.TypesAreNotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/thenextlvl/gopaint/package-info.java b/src/main/java/net/thenextlvl/gopaint/package-info.java new file mode 100644 index 00000000..5bc7c22e --- /dev/null +++ b/src/main/java/net/thenextlvl/gopaint/package-info.java @@ -0,0 +1,10 @@ +@TypesAreNotNullByDefault +@FieldsAreNotNullByDefault +@MethodsReturnNotNullByDefault +@ParametersAreNotNullByDefault +package net.thenextlvl.gopaint; + +import core.annotation.FieldsAreNotNullByDefault; +import core.annotation.MethodsReturnNotNullByDefault; +import core.annotation.ParametersAreNotNullByDefault; +import core.annotation.TypesAreNotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/thenextlvl/gopaint/utils/GUI.java b/src/main/java/net/thenextlvl/gopaint/utils/GUI.java index e3aa9f5e..fa69bc77 100644 --- a/src/main/java/net/thenextlvl/gopaint/utils/GUI.java +++ b/src/main/java/net/thenextlvl/gopaint/utils/GUI.java @@ -22,39 +22,29 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.thenextlvl.gopaint.GoPaintPlugin; import net.thenextlvl.gopaint.brush.PlayerBrush; -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.PaintBrush; -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 org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.inventory.Inventory; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; public class GUI { private static final GoPaintPlugin plugin = JavaPlugin.getPlugin(GoPaintPlugin.class); - public static @NotNull Inventory create(PlayerBrush pb) { + public static Inventory create(PlayerBrush pb) { Inventory inv = Bukkit.createInventory(null, 54, Component.text("goPaint Menu", NamedTextColor.DARK_BLUE)); update(inv, pb); return inv; } - public static @NotNull Inventory generateBrushes() { + public static Inventory generateBrushes() { Inventory inv = Bukkit.createInventory(null, 27, Component.text("goPaint Brushes", NamedTextColor.DARK_BLUE)); // FILLER formatDefault(inv); - for (int index = 0; index < plugin.getBrushManager().getBrushes().size(); index++) { - Brush brush = plugin.getBrushManager().getBrushes().get(index); + for (int index = 0; index < plugin.brushManager().getBrushes().size(); index++) { + Brush brush = plugin.brushManager().getBrushes().get(index); inv.setItem(index, Items.createHead(brush.getHead(), 1, "§6" + brush.getName(), "\n§7Click to select\n\n§8" + brush.getDescription() )); @@ -62,13 +52,13 @@ public class GUI { return inv; } - private static void formatDefault(@NotNull Inventory inventory) { + private static void formatDefault(Inventory inventory) { for (int slot = 0; slot < inventory.getSize(); slot++) { inventory.setItem(slot, Items.create(Material.GRAY_STAINED_GLASS_PANE, 1, "§7", "")); } } - public static void update(@NotNull Inventory inventory, @NotNull PlayerBrush playerBrush) { + public static void update(Inventory inventory, PlayerBrush playerBrush) { Brush brush = playerBrush.brush(); // FILLER @@ -96,7 +86,7 @@ public static void update(@NotNull Inventory inventory, @NotNull PlayerBrush pla String clicks = "\n§7Shift click to select\n§7Click to cycle brush\n\n"; inventory.setItem(11, Items.createHead(brush.getHead(), 1, "§6Selected Brush type", - clicks + plugin.getBrushManager().getBrushLore(brush) + clicks + plugin.brushManager().getBrushLore(brush) )); inventory.setItem(20, Items.create(Material.ORANGE_STAINED_GLASS_PANE, 1, "§7", "")); diff --git a/src/main/java/net/thenextlvl/gopaint/utils/Height.java b/src/main/java/net/thenextlvl/gopaint/utils/Height.java index ba6331f7..b1ea1a22 100644 --- a/src/main/java/net/thenextlvl/gopaint/utils/Height.java +++ b/src/main/java/net/thenextlvl/gopaint/utils/Height.java @@ -20,7 +20,6 @@ import org.bukkit.Location; import org.bukkit.block.Block; -import org.jetbrains.annotations.NotNull; public class Height { @@ -30,7 +29,7 @@ public class Height { * @param location the location to check * @return the height of the nearest non-empty block at the location */ - public static int getNearestNonEmptyBlock(@NotNull Location location) { + public static int getNearestNonEmptyBlock(Location location) { if (location.getBlock().getType().isEmpty()) { for (int y = location.getBlockY(); y >= location.getWorld().getMinHeight(); y--) { Block block = location.getWorld().getBlockAt(location.getBlockX(), y, location.getBlockZ()); @@ -58,7 +57,7 @@ public static int getNearestNonEmptyBlock(@NotNull Location location) { * @param distance the distance at which to calculate the average height difference * @return the average height difference of the surrounding blocks within the specified distance */ - public static double getAverageHeightDiffFracture(@NotNull Location location, int height, int distance) { + public static double getAverageHeightDiffFracture(Location location, int height, int distance) { double totalHeight = 0; totalHeight += Math.abs(getNearestNonEmptyBlock(location.clone().add(distance, 0, -distance))) - height; totalHeight += Math.abs(getNearestNonEmptyBlock(location.clone().add(distance, 0, distance))) - height; @@ -78,7 +77,7 @@ public static double getAverageHeightDiffFracture(@NotNull Location location, in * @param distance the distance at which to calculate the average height difference angle * @return the average height difference angle of the surrounding blocks within the specified distance */ - public static double getAverageHeightDiffAngle(@NotNull Location location, int distance) { + public static double getAverageHeightDiffAngle(Location location, int distance) { double maxHeightDiff = 0; double maxHeightDiff2 = 0; double diff = Math.abs(getNearestNonEmptyBlock(location.clone().add(distance, 0, -distance)) diff --git a/src/main/java/net/thenextlvl/gopaint/utils/Items.java b/src/main/java/net/thenextlvl/gopaint/utils/Items.java index b19e1e5b..a9942464 100644 --- a/src/main/java/net/thenextlvl/gopaint/utils/Items.java +++ b/src/main/java/net/thenextlvl/gopaint/utils/Items.java @@ -24,7 +24,6 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -32,12 +31,7 @@ public final class Items { - public static @NotNull ItemStack create( - @NotNull Material material, - int amount, - @NotNull String name, - @NotNull String lore - ) { + public static ItemStack create(Material material, int amount, String name, String lore) { ItemStack itemStack = new ItemStack(material); itemStack.setAmount(amount); itemStack.editMeta(itemMeta -> { @@ -56,12 +50,7 @@ public final class Items { return itemStack; } - public static @NotNull ItemStack createHead( - @NotNull String texture, - int amount, - @NotNull String name, - @NotNull String lore - ) { + public static ItemStack createHead(String texture, int amount, String name, String lore) { ItemStack head = create(Material.PLAYER_HEAD, amount, name, lore); head.editMeta(SkullMeta.class, skullMeta -> { var profile = Bukkit.createProfile(UUID.randomUUID()); diff --git a/src/main/java/net/thenextlvl/gopaint/utils/Sphere.java b/src/main/java/net/thenextlvl/gopaint/utils/Sphere.java index 987e5925..9d0f80f0 100644 --- a/src/main/java/net/thenextlvl/gopaint/utils/Sphere.java +++ b/src/main/java/net/thenextlvl/gopaint/utils/Sphere.java @@ -21,7 +21,6 @@ import org.bukkit.Axis; import org.bukkit.Location; import org.bukkit.block.Block; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -39,7 +38,7 @@ public class Sphere { * @param air Whether air blocks should be included. * @return A stream of blocks within the specified radius. */ - public static Stream getBlocksInRadius(@NotNull Location middlePoint, int radius, @Nullable Axis axis, boolean air) { + public static Stream getBlocksInRadius(Location middlePoint, int radius, @Nullable Axis axis, boolean air) { List blocks = new ArrayList<>(); Location loc1 = middlePoint.clone().add(-radius / 2d, -radius / 2d, -radius / 2d).getBlock().getLocation(); Location loc2 = middlePoint.clone().add(radius / 2d, radius / 2d, radius / 2d).getBlock().getLocation(); @@ -92,7 +91,7 @@ public static Stream getBlocksInRadius(@NotNull Location middlePoint, int return blocks.stream().filter(block -> !block.isEmpty()); } - private static boolean passesDefaultChecks(@NotNull Location location, @NotNull Location middlePoint, int radius) { + private static boolean passesDefaultChecks(Location location, Location middlePoint, int radius) { return location.distance(middlePoint) < radius / 2d; } diff --git a/src/main/java/net/thenextlvl/gopaint/utils/Surface.java b/src/main/java/net/thenextlvl/gopaint/utils/Surface.java index ebf15a10..14d17953 100644 --- a/src/main/java/net/thenextlvl/gopaint/utils/Surface.java +++ b/src/main/java/net/thenextlvl/gopaint/utils/Surface.java @@ -22,7 +22,6 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.jetbrains.annotations.NotNull; public class Surface { @@ -32,7 +31,7 @@ public class Surface { * @param block the block to check * @return true if the block is on the surface, false otherwise */ - public static boolean isDirectlyOnSurface(@NotNull Block block) { + public static boolean isDirectlyOnSurface(Block block) { return block.isSolid() && !block.getRelative(BlockFace.UP).isSolid(); } @@ -43,7 +42,7 @@ public static boolean isDirectlyOnSurface(@NotNull Block block) { * @param playerLoc the player's location * @return true if the block is on the surface from the player's location, false otherwise */ - public static boolean isRelativelyOnSurface(@NotNull Block block, @NotNull Location playerLoc) { + public static boolean isRelativelyOnSurface(Block block, Location playerLoc) { Location location = block.getLocation(); playerLoc.add(0, 1.5, 0); @@ -87,7 +86,7 @@ public static boolean isRelativelyOnSurface(@NotNull Block block, @NotNull Locat * @param location the location to use for the check * @return true if the block is on the surface based on the surface mode and location, false otherwise */ - public static boolean isOnSurface(@NotNull Block block, @NotNull SurfaceMode surfaceMode, @NotNull Location location) { + public static boolean isOnSurface(Block block, SurfaceMode surfaceMode, Location location) { return switch (surfaceMode) { case RELATIVE -> isRelativelyOnSurface(block, location); case DIRECT -> isDirectlyOnSurface(block); diff --git a/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSpline.java b/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSpline.java index 891bf0d9..6c068efc 100644 --- a/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSpline.java +++ b/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSpline.java @@ -22,16 +22,15 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.util.Vector; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.LinkedList; public class BezierSpline { - private final @NotNull LinkedList knotsList; + private final LinkedList knotsList; private Location[] knots; - private @NotNull BezierSplineSegment[] segments; + private BezierSplineSegment[] segments; private double length = 0; private Location anchorPoint; @@ -40,7 +39,7 @@ public BezierSpline() { segments = new BezierSplineSegment[0]; } - public BezierSpline(@NotNull LinkedList knotsList) { + public BezierSpline(LinkedList knotsList) { this.knotsList = knotsList; recalculate(); } @@ -55,7 +54,7 @@ private void recalculate() { calculateLength(); } - public void addKnot(@NotNull Location location) { + public void addKnot(Location location) { knotsList.add(location); recalculate(); } @@ -117,7 +116,7 @@ public double getT(double blocks) { return i + segments[i].getT(blocks - current); } - public @NotNull Location getPoint(double point) { + public Location getPoint(double point) { if (point >= segments.length) { return getPoint(segments.length - 1, 1); } else { @@ -125,7 +124,7 @@ public double getT(double blocks) { } } - public @NotNull Location getPoint(int n, double f) { + public Location getPoint(int n, double f) { assert (n < segments.length); assert (0 <= f && f <= 1); BezierSplineSegment segment = segments[n]; @@ -286,7 +285,7 @@ public void calculateControlPoints() { } } - public void shift(@NotNull Vector vector) { + public void shift(Vector vector) { for (Location location : knotsList) { location.add(vector); } @@ -302,7 +301,7 @@ public void scale(double d) { recalculate(); } - public void scale(@NotNull Vector vector) { + public void scale(Vector vector) { for (Location l : knotsList) { l.subtract(anchorPoint); l.setX(l.getX() * vector.getX()); @@ -331,15 +330,15 @@ public String toString() { return knots.length + " points."; } - public @NotNull String toName() { + public String toName() { return "Curve"; } - public @NotNull BezierSpline emptySystem() { + public BezierSpline emptySystem() { return new BezierSpline(); } - public @NotNull String toShorthand() { + public String toShorthand() { return "curve"; } diff --git a/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSplineSegment.java b/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSplineSegment.java index 8c2b42b8..3a35cc9d 100644 --- a/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSplineSegment.java +++ b/src/main/java/net/thenextlvl/gopaint/utils/curve/BezierSplineSegment.java @@ -21,7 +21,6 @@ import lombok.Getter; import lombok.Setter; import org.bukkit.Location; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Objects; @@ -31,13 +30,13 @@ public class BezierSplineSegment { private final double[] lengths = new double[20]; - private @NotNull Location p0, p1, p2, p3; + private Location p0, p1, p2, p3; private float a, b, c; private @Nullable Double xFlat, yFlat, zFlat; - private @NotNull Location r; + private Location r; private double curveLength; - public BezierSplineSegment(@NotNull Location p0, @NotNull Location p3) { + public BezierSplineSegment(Location p0, Location p3) { this.p0 = p0; this.p3 = p3; p1 = new Location(p0.getWorld(), 0, 0, 0); diff --git a/src/main/java/net/thenextlvl/gopaint/utils/package-info.java b/src/main/java/net/thenextlvl/gopaint/utils/package-info.java new file mode 100644 index 00000000..e1414ce4 --- /dev/null +++ b/src/main/java/net/thenextlvl/gopaint/utils/package-info.java @@ -0,0 +1,10 @@ +@TypesAreNotNullByDefault +@FieldsAreNotNullByDefault +@MethodsReturnNotNullByDefault +@ParametersAreNotNullByDefault +package net.thenextlvl.gopaint.utils; + +import core.annotation.FieldsAreNotNullByDefault; +import core.annotation.MethodsReturnNotNullByDefault; +import core.annotation.ParametersAreNotNullByDefault; +import core.annotation.TypesAreNotNullByDefault; \ No newline at end of file