diff --git a/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java b/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java index 5c767e8..ffe12f8 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java +++ b/Datura/src/main/java/me/totalfreedom/datura/punishment/Cager.java @@ -2,7 +2,7 @@ package me.totalfreedom.datura.punishment; import me.totalfreedom.base.CommonsBase; import me.totalfreedom.service.Service; -import me.totalfreedom.utils.Shaper; +import me.totalfreedom.utils.ShapeUtils; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -53,25 +53,25 @@ public class Cager extends Service /** * This method generates a cube centered around the passed location, * made of the provided material. This method returns the passed location object. - * We use the {@link Shaper} class to generate the cube, which allows us to define + * We use the {@link ShapeUtils} class to generate the cube, which allows us to define * custom shapes using {@link DoubleUnaryOperator}s. * * @param location The location to center the cube around. * @param material The material to use for the cube. * @return The center location of the cube (the passed location). - * @see Shaper + * @see ShapeUtils * @see DoubleUnaryOperator */ public Location createCage(final Location location, final Material material) { - final Shaper shaper = new Shaper(location.getWorld(), 0.0, 4.0); + final ShapeUtils shapeUtils = new ShapeUtils(location.getWorld(), 0.0, 4.0); final List cubed = new LinkedList<>(); - cubed.addAll(shaper.generate(5, t -> t, t -> 4.0, t -> t)); - cubed.addAll(shaper.generate(5, t -> t, t -> 0.0, t -> t)); - cubed.addAll(shaper.generate(5, t -> 0.0, t -> t, t -> t)); - cubed.addAll(shaper.generate(5, t -> 4.0, t -> t, t -> t)); - cubed.addAll(shaper.generate(5, t -> t, t -> t, t -> 0.0)); - cubed.addAll(shaper.generate(5, t -> t, t -> t, t -> 4.0)); + cubed.addAll(shapeUtils.generate(5, t -> t, t -> 4.0, t -> t)); + cubed.addAll(shapeUtils.generate(5, t -> t, t -> 0.0, t -> t)); + cubed.addAll(shapeUtils.generate(5, t -> 0.0, t -> t, t -> t)); + cubed.addAll(shapeUtils.generate(5, t -> 4.0, t -> t, t -> t)); + cubed.addAll(shapeUtils.generate(5, t -> t, t -> t, t -> 0.0)); + cubed.addAll(shapeUtils.generate(5, t -> t, t -> t, t -> 4.0)); for (final Location l : cubed) { diff --git a/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java b/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java index 5827a8e..9097fb3 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java +++ b/Datura/src/main/java/me/totalfreedom/datura/sql/MySQL.java @@ -2,7 +2,7 @@ package me.totalfreedom.datura.sql; import me.totalfreedom.base.CommonsBase; import me.totalfreedom.sql.SQL; -import me.totalfreedom.utils.Identity; +import me.totalfreedom.utils.container.Identity; import java.sql.Connection; import java.sql.DriverManager; diff --git a/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java b/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java index 65df6a1..1b6f9ef 100644 --- a/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java +++ b/Datura/src/main/java/me/totalfreedom/datura/user/SimpleUserData.java @@ -7,7 +7,7 @@ import me.totalfreedom.security.Group; import me.totalfreedom.sql.SQL; import me.totalfreedom.user.User; import me.totalfreedom.user.UserData; -import me.totalfreedom.utils.FreedomLogger; +import me.totalfreedom.utils.logging.FreedomLogger; import org.apache.commons.lang3.exception.ExceptionUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java b/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java index 6c7c364..304cc4c 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/cmd/CakeCommand.java @@ -25,7 +25,7 @@ import me.totalfreedom.command.Commander; import me.totalfreedom.command.annotation.Base; import me.totalfreedom.command.annotation.Info; import me.totalfreedom.command.annotation.Permissive; -import me.totalfreedom.utils.FreedomMiniMessage; +import me.totalfreedom.utils.kyori.FreedomMiniMessage; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.CommandSender; diff --git a/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionLogger.java b/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionLogger.java index 7ebb9cc..80ba2d2 100644 --- a/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionLogger.java +++ b/Fossil/src/main/java/me/totalfreedom/fossil/economy/SimpleTransactionLogger.java @@ -5,7 +5,7 @@ import me.totalfreedom.economy.CompletedTransaction; import me.totalfreedom.economy.EconomicEntity; import me.totalfreedom.economy.TransactionLogger; import me.totalfreedom.economy.TransactionResult; -import me.totalfreedom.utils.FreedomLogger; +import me.totalfreedom.utils.logging.FreedomLogger; import net.kyori.adventure.text.Component; public class SimpleTransactionLogger implements TransactionLogger diff --git a/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegate.java b/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegate.java index b6d6276..99c7464 100644 --- a/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegate.java +++ b/Patchwork/src/main/java/me/totalfreedom/command/BukkitDelegate.java @@ -4,7 +4,7 @@ import me.totalfreedom.api.Context; import me.totalfreedom.command.annotation.Completion; import me.totalfreedom.command.annotation.Subcommand; import me.totalfreedom.provider.ContextProvider; -import me.totalfreedom.utils.FreedomLogger; +import me.totalfreedom.utils.logging.FreedomLogger; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.World; diff --git a/Patchwork/src/main/java/me/totalfreedom/display/DisplayableView.java b/Patchwork/src/main/java/me/totalfreedom/display/DisplayableView.java index 2a923b1..26c5138 100644 --- a/Patchwork/src/main/java/me/totalfreedom/display/DisplayableView.java +++ b/Patchwork/src/main/java/me/totalfreedom/display/DisplayableView.java @@ -1,6 +1,6 @@ package me.totalfreedom.display; -import me.totalfreedom.utils.FreedomAdventure; +import me.totalfreedom.utils.kyori.FreedomAdventure; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; diff --git a/Patchwork/src/main/java/me/totalfreedom/particle/NoteWrapper.java b/Patchwork/src/main/java/me/totalfreedom/particle/NoteWrapper.java new file mode 100644 index 0000000..ef656ce --- /dev/null +++ b/Patchwork/src/main/java/me/totalfreedom/particle/NoteWrapper.java @@ -0,0 +1,157 @@ +package me.totalfreedom.particle; + +import org.bukkit.Particle; +import org.bukkit.World; + +import java.math.RoundingMode; +import java.text.DecimalFormat; + +/** + * A utility class for the 24 different note colors available in Minecraft. Each note is represented as a double value + * between 0 and 1. Furthermore, each note is a multiple of 1/24 within that range of 0 to 1. + *

+ * For example, the note G is represented as 1/24, or 0.042. The note C is represented as 6/24, or 0.25. + *

+ * When spawning particles, the count must be set to 0 and the extra value set between 0 and 1. The extra value is the + * size of the note particle. To add a color, use one of the provided methods in this class for the xOffset value in + * {@link World#spawnParticle(Particle, double, double, double, int, double, double, double, double)}. The xOffset value + * is the note color, with the yOffset and zOffset values set to 0. + */ +public final class NoteWrapper +{ + public static final double CYAN_NOTE_F_SHARP_LOW = 0; + public static final double CYAN_NOTE_F_SHARP_HIGH = 1; + + private static final DecimalFormat FORMAT; + + static + { + FORMAT = new DecimalFormat("#.###"); + FORMAT.setRoundingMode(RoundingMode.HALF_UP); + } + + private NoteWrapper() + { + throw new AssertionError(); + } + + private static double round(final double value) + { + return Double.parseDouble(FORMAT.format(value)); + } + + public static double cyanNoteG() + { + return round(1 / 24D); + } + + public static double grayNoteGSharp() + { + return round(2 / 24D); + } + + public static double grayNoteA() + { + return round(3 / 24D); + } + + public static double grayNoteASharp() + { + return round(4 / 24D); + } + + public static double magentaNoteB() + { + return round(5 / 24D); + } + + public static double redNoteC() + { + return round(6 / 24D); + } + + public static double yellowNoteCSharp() + { + return round(7 / 24D); + } + + public static double yellowNoteD() + { + return round(8 / 24D); + } + + public static double yellowNoteDSharpLow() + { + return round(9 / 24D); + } + + public static double grayNoteE() + { + return round(10 / 24D); + } + + public static double grayNoteF() + { + return round(11 / 24D); + } + + public static double grayNoteFSharp() + { + return round(12 / 24D); + } + + public static double lightBlueNoteG() + { + return round(13 / 24D); + } + + public static double blueNoteGSharp() + { + return round(14 / 24D); + } + + public static double purpleNoteA() + { + return round(15 / 24D); + } + + public static double purpleNoteASharp() + { + return round(16 / 24D); + } + + public static double purpleNoteB() + { + return round(17 / 24D); + } + + public static double grayNoteC() + { + return round(18 / 24D); + } + + public static double grayNoteCSharp() + { + return round(19 / 24D); + } + + public static double grayNoteD() + { + return round(20 / 24D); + } + + public static double yellowNoteDSharpHigh() + { + return round(21 / 24D); + } + + public static double greenNoteE() + { + return round(22 / 24D); + } + + public static double lightBlueNoteF() + { + return round(23 / 24D); + } +} diff --git a/Patchwork/src/main/java/me/totalfreedom/particle/TrailType.java b/Patchwork/src/main/java/me/totalfreedom/particle/TrailType.java index e37fae4..c0a5001 100644 --- a/Patchwork/src/main/java/me/totalfreedom/particle/TrailType.java +++ b/Patchwork/src/main/java/me/totalfreedom/particle/TrailType.java @@ -1,13 +1,34 @@ package me.totalfreedom.particle; +import org.bukkit.Note; import org.bukkit.Particle; public enum TrailType { + /** + * Default trail type. Uses {@link Particle#REDSTONE}. This trail is colorable. Use {@link Particle.DustOptions} to + * set the particle properties. + */ DEFAULT(Particle.REDSTONE), + /** + * A trail that uses {@link Particle#HEART}. This is not modifiable and will always have the same size shape and + * color. + */ HEART(Particle.HEART), + /** + * A trail that uses {@link Particle#FLAME}. This is not modifiable and will always have the same size shape and + * color. + */ FLAME(Particle.FLAME), + /** + * A trail that uses {@link Particle#REDSTONE}. This particle however is rainbow-colored by default and cannot have + * additional options set. + */ RAINBOW(Particle.REDSTONE), + /** + * A trail that uses {@link Particle#NOTE}. This is colorable, however you are limited to the 24 different note + * colors available in Minecraft. + */ MUSIC(Particle.NOTE), SNOW(Particle.SNOWBALL), SPELL(Particle.SPELL_MOB), diff --git a/Patchwork/src/main/java/me/totalfreedom/service/TaskSubscription.java b/Patchwork/src/main/java/me/totalfreedom/service/TaskSubscription.java index 5d2b5e2..f7b7c0b 100644 --- a/Patchwork/src/main/java/me/totalfreedom/service/TaskSubscription.java +++ b/Patchwork/src/main/java/me/totalfreedom/service/TaskSubscription.java @@ -1,6 +1,6 @@ package me.totalfreedom.service; -import me.totalfreedom.utils.Pair; +import me.totalfreedom.utils.container.Pair; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/Shaper.java b/Patchwork/src/main/java/me/totalfreedom/utils/ShapeUtils.java similarity index 90% rename from Patchwork/src/main/java/me/totalfreedom/utils/Shaper.java rename to Patchwork/src/main/java/me/totalfreedom/utils/ShapeUtils.java index 7f3dfdc..5a142a0 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/Shaper.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/ShapeUtils.java @@ -7,13 +7,13 @@ import java.util.LinkedList; import java.util.List; import java.util.function.DoubleUnaryOperator; -public class Shaper +public class ShapeUtils { private final double start; private final double end; private final World world; - public Shaper(final World world, final double start, final double end) + public ShapeUtils(final World world, final double start, final double end) { this.start = start; this.end = end; diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/Identity.java b/Patchwork/src/main/java/me/totalfreedom/utils/container/Identity.java similarity index 89% rename from Patchwork/src/main/java/me/totalfreedom/utils/Identity.java rename to Patchwork/src/main/java/me/totalfreedom/utils/container/Identity.java index d186093..0770962 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/Identity.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/container/Identity.java @@ -1,4 +1,4 @@ -package me.totalfreedom.utils; +package me.totalfreedom.utils.container; import java.util.UUID; diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/Pair.java b/Patchwork/src/main/java/me/totalfreedom/utils/container/Pair.java similarity index 52% rename from Patchwork/src/main/java/me/totalfreedom/utils/Pair.java rename to Patchwork/src/main/java/me/totalfreedom/utils/container/Pair.java index 9ab5e2f..0cf4e76 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/Pair.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/container/Pair.java @@ -1,4 +1,4 @@ -package me.totalfreedom.utils; +package me.totalfreedom.utils.container; public record Pair(K key, V value) { diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/container/Tuple.java b/Patchwork/src/main/java/me/totalfreedom/utils/container/Tuple.java new file mode 100644 index 0000000..794637d --- /dev/null +++ b/Patchwork/src/main/java/me/totalfreedom/utils/container/Tuple.java @@ -0,0 +1,30 @@ +package me.totalfreedom.utils.container; + +public final class Tuple +{ + private final A a; + private final B b; + private final C c; + + public Tuple(final A a, final B b, final C c) + { + this.a = a; + this.b = b; + this.c = c; + } + + public A getPrimary() + { + return a; + } + + public B getSecondary() + { + return b; + } + + public C getTertiary() + { + return c; + } +} diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/container/UnaryTuple.java b/Patchwork/src/main/java/me/totalfreedom/utils/container/UnaryTuple.java new file mode 100644 index 0000000..85bdee3 --- /dev/null +++ b/Patchwork/src/main/java/me/totalfreedom/utils/container/UnaryTuple.java @@ -0,0 +1,30 @@ +package me.totalfreedom.utils.container; + +public class UnaryTuple +{ + private final T primary; + private final T secondary; + private final T tertiary; + + public UnaryTuple(final T primary, final T secondary, final T tertiary) + { + this.primary = primary; + this.secondary = secondary; + this.tertiary = tertiary; + } + + public T getPrimary() + { + return primary; + } + + public T getSecondary() + { + return secondary; + } + + public T getTertiary() + { + return tertiary; + } +} diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomAdventure.java b/Patchwork/src/main/java/me/totalfreedom/utils/kyori/FreedomAdventure.java similarity index 97% rename from Patchwork/src/main/java/me/totalfreedom/utils/FreedomAdventure.java rename to Patchwork/src/main/java/me/totalfreedom/utils/kyori/FreedomAdventure.java index 727869f..f24cbc7 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomAdventure.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/kyori/FreedomAdventure.java @@ -1,4 +1,4 @@ -package me.totalfreedom.utils; +package me.totalfreedom.utils.kyori; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomMiniMessage.java b/Patchwork/src/main/java/me/totalfreedom/utils/kyori/FreedomMiniMessage.java similarity index 99% rename from Patchwork/src/main/java/me/totalfreedom/utils/FreedomMiniMessage.java rename to Patchwork/src/main/java/me/totalfreedom/utils/kyori/FreedomMiniMessage.java index a3c1e34..e39552c 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomMiniMessage.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/kyori/FreedomMiniMessage.java @@ -19,7 +19,7 @@ * THE SOFTWARE. */ -package me.totalfreedom.utils; +package me.totalfreedom.utils.kyori; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/KyoriConstants.java b/Patchwork/src/main/java/me/totalfreedom/utils/kyori/KyoriConstants.java similarity index 98% rename from Patchwork/src/main/java/me/totalfreedom/utils/KyoriConstants.java rename to Patchwork/src/main/java/me/totalfreedom/utils/kyori/KyoriConstants.java index 46bb8d8..5ba62d5 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/KyoriConstants.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/kyori/KyoriConstants.java @@ -1,4 +1,4 @@ -package me.totalfreedom.utils; +package me.totalfreedom.utils.kyori; import me.totalfreedom.base.CommonsBase; import net.kyori.adventure.chat.ChatType; diff --git a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java b/Patchwork/src/main/java/me/totalfreedom/utils/logging/FreedomLogger.java similarity index 98% rename from Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java rename to Patchwork/src/main/java/me/totalfreedom/utils/logging/FreedomLogger.java index 9fd27ad..2a093c4 100644 --- a/Patchwork/src/main/java/me/totalfreedom/utils/FreedomLogger.java +++ b/Patchwork/src/main/java/me/totalfreedom/utils/logging/FreedomLogger.java @@ -1,5 +1,6 @@ -package me.totalfreedom.utils; +package me.totalfreedom.utils.logging; +import me.totalfreedom.utils.kyori.FreedomAdventure; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.chat.ChatType; import net.kyori.adventure.chat.SignedMessage;