Some more updates

This commit is contained in:
Paul Reilly 2023-06-09 14:15:53 -05:00
parent 6631aebaa0
commit f459842eaf
19 changed files with 264 additions and 25 deletions

View File

@ -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<Location> 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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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.
* <p>
* For example, the note G is represented as 1/24, or 0.042. The note C is represented as 6/24, or 0.25.
* <p>
* 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);
}
}

View File

@ -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),

View File

@ -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;

View File

@ -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;

View File

@ -1,4 +1,4 @@
package me.totalfreedom.utils;
package me.totalfreedom.utils.container;
import java.util.UUID;

View File

@ -1,4 +1,4 @@
package me.totalfreedom.utils;
package me.totalfreedom.utils.container;
public record Pair<K, V>(K key, V value)
{

View File

@ -0,0 +1,30 @@
package me.totalfreedom.utils.container;
public final class Tuple<A, B, C>
{
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;
}
}

View File

@ -0,0 +1,30 @@
package me.totalfreedom.utils.container;
public class UnaryTuple<T>
{
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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -1,4 +1,4 @@
package me.totalfreedom.utils;
package me.totalfreedom.utils.kyori;
import me.totalfreedom.base.CommonsBase;
import net.kyori.adventure.chat.ChatType;

View File

@ -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;