diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 00000000..b9d18bf5
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 082257d4..d5467869 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -71,5 +71,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cc57d5fd..367f7d2a 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -9,7 +9,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules/HMCCosmetics.iml b/.idea/modules/HMCCosmetics.iml
index 85578b10..a1e06243 100644
--- a/.idea/modules/HMCCosmetics.iml
+++ b/.idea/modules/HMCCosmetics.iml
@@ -4,7 +4,6 @@
- MCP
ADVENTURE
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 1def41c1..00000000
--- a/build.gradle
+++ /dev/null
@@ -1,62 +0,0 @@
-plugins {
- id 'java'
- id 'com.github.johnrengelman.shadow' version '6.1.0'
-}
-
-group 'io.github.fisher2911'
-version '1.6.1'
-
-repositories {
- mavenCentral()
- mavenLocal()
- maven { url = 'https://repo.mattstudios.me/artifactory/public/' }
- maven { url = 'https://jitpack.io' }
- maven { url = 'https://repo.dmulloy2.net/repository/public/' }
- maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
- maven { url = 'https://mvnrepository.com/artifact/com.zaxxer/HikariCP' }
- maven { url = 'https://repo.jeff-media.de/maven2/' }
- maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
-}
-
-dependencies {
- testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
- testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
- compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
- compileOnly 'org.jetbrains:annotations:22.0.0'
- compileOnly 'com.comphenix.protocol:ProtocolLib:4.7.0'
- compileOnly 'me.clip:placeholderapi:2.11.1'
- compileOnly 'com.github.oraxen:oraxen:-SNAPSHOT'
- compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.5.4'
- implementation 'net.kyori:adventure-api:4.9.3'
- implementation 'net.kyori:adventure-text-minimessage:4.2.0-SNAPSHOT'
- implementation 'net.kyori:adventure-platform-bukkit:4.0.0'
- implementation 'dev.triumphteam:triumph-gui:3.0.3'
- implementation 'me.mattstudios.utils:matt-framework:1.4.6'
- implementation 'org.spongepowered:configurate-yaml:4.1.2'
- implementation 'org.bstats:bstats-bukkit:2.2.1'
- implementation 'com.zaxxer:HikariCP:5.0.0'
- implementation 'com.j256.ormlite:ormlite-jdbc:6.1'
- implementation 'com.j256.ormlite:ormlite-core:6.1'
-}
-
-test {
- useJUnitPlatform()
-}
-
-shadowJar {
- relocate 'dev.triumphteam.gui', 'io.github.fisher2911.hmccosmetics.gui'
- relocate 'me.mattstudios.mf', 'io.github.fisher2911.hmccosmetics.mf'
- relocate 'net.kyori.adventure.api', 'io.github.fisher2911.hmccosmetics.adventure.api'
- relocate 'net.kyori.adventure.text.minimessage', 'io.github.fisher2911.hmccosmetics.adventure.minimessage'
- relocate 'net.kyori.adventure.platform', 'io.github.fisher2911.hmccosmetics.adventure.platform'
- relocate 'org.spongepowered.configurate', 'io.github.fisher2911.hmccosmetics.configurate'
- relocate 'org.bstats', 'io.github.fisher2911.hmccosmetics.bstats'
- relocate 'com.zaxxer.hikaricp', 'io.github.fisher2911.hmccosmetics.hikaricp'
- relocate 'com.j256.ormlite', 'io.github.fisher2911.hmccosmetics.ormlite'
-}
-
-shadowJar {
- archiveBaseName.set('HMCCosmetics')
- archiveClassifier.set('')
- archiveVersion.set('')
-}
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 00000000..1154352d
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,106 @@
+import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
+
+plugins {
+ id("java")
+ id("com.github.johnrengelman.shadow") version "7.1.1"
+ id("net.minecrell.plugin-yml.bukkit") version "0.5.1"
+}
+
+group = "io.github.fisher2911"
+version = "1.6.1"
+description = "The ultimate cosmetic plugin for your server."
+
+repositories {
+ mavenCentral()
+ maven("https://papermc.io/repo/repository/maven-public/")
+ maven("https://repo.mattstudios.me/artifactory/public/")
+ maven("https://jitpack.io")
+ maven("https://repo.dmulloy2.net/repository/public/")
+ maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
+ maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
+ maven("https://repo.jeff-media.de/maven2/")
+ maven("https://oss.sonatype.org/content/repositories/snapshots")
+}
+
+dependencies {
+ compileOnly("com.mojang:authlib:1.5.25")
+ compileOnly("org.spigotmc:spigot:1.17-R0.1-SNAPSHOT")
+ compileOnly("org.jetbrains:annotations:22.0.0")
+ compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0")
+ compileOnly("me.clip:placeholderapi:2.11.1")
+ compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
+ compileOnly("com.github.LoneDev6:API-ItemsAdder:2.5.4")
+ implementation("net.kyori:adventure-api:4.9.3")
+ implementation("net.kyori:adventure-text-minimessage:4.10.0-SNAPSHOT")
+ implementation("net.kyori:adventure-platform-bukkit:4.0.1")
+ implementation("dev.triumphteam:triumph-gui:3.0.3")
+ implementation("me.mattstudios.utils:matt-framework:1.4.6")
+ implementation("org.spongepowered:configurate-yaml:4.1.2")
+ implementation("org.bstats:bstats-bukkit:2.2.1")
+ implementation("com.zaxxer:HikariCP:5.0.0")
+ implementation("com.j256.ormlite:ormlite-jdbc:6.1")
+ implementation("com.j256.ormlite:ormlite-core:6.1")
+}
+
+tasks {
+ build {
+ dependsOn(shadowJar)
+ }
+
+ compileJava {
+ options.encoding = Charsets.UTF_8.name()
+ options.release.set(16)
+ }
+
+ shadowJar {
+ relocate("dev.triumphteam.gui", "io.github.fisher2911.hmccosmetics.gui")
+ relocate("me.mattstudios.mf", "io.github.fisher2911.hmccosmetics.mf")
+ relocate("net.kyori.adventure.text.minimessage", "io.github.fisher2911.hmccosmetics.adventure.minimessage")
+ relocate("net.kyori.adventure.platform", "io.github.fisher2911.hmccosmetics.adventure.platform")
+ relocate("org.spongepowered.configurate", "io.github.fisher2911.hmccosmetics.configurate")
+ relocate("org.bstats", "io.github.fisher2911.hmccosmetics.bstats")
+ relocate("com.zaxxer.hikaricp", "io.github.fisher2911.hmccosmetics.hikaricp")
+ relocate("com.j256.ormlite", "io.github.fisher2911.hmccosmetics.ormlite")
+ archiveFileName.set("HMCCosmetics.jar")
+ }
+
+ javadoc {
+ options.encoding = Charsets.UTF_8.name()
+ }
+
+ processResources {
+ filteringCharset = Charsets.UTF_8.name()
+ }
+}
+
+java {
+ toolchain.languageVersion.set(JavaLanguageVersion.of(16))
+}
+
+bukkit {
+ load = BukkitPluginDescription.PluginLoadOrder.STARTUP
+ main = "io.github.fisher2911.hmccosmetics.HMCCosmetics"
+ apiVersion = "1.17"
+ name = "HMCCosmetics"
+ authors = listOf("MasterOfTheFish")
+ softDepend = listOf("Multiverse", "PlaceholderAPI", "Oraxen", "ItemsAdder")
+ depend = listOf("ProtocolLib")
+ permissions {
+ register("hmccosmetics.cmd.default") {
+ default = BukkitPluginDescription.Permission.Default.OP
+ description = "Permission to execute the default command."
+ }
+ register("hmccosmetics.cmd.dye") {
+ default = BukkitPluginDescription.Permission.Default.OP
+ description = "Permission to dye armor."
+ }
+ register("hmccosmetics.cmd.reload") {
+ default = BukkitPluginDescription.Permission.Default.OP
+ description = "Permission to use the reload command."
+ }
+ register("hmccosmetics.cmd.set") {
+ default = BukkitPluginDescription.Permission.Default.OP
+ description = "Permission to set other users' cosmetics."
+ }
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index f7e048dd..00000000
--- a/settings.gradle
+++ /dev/null
@@ -1,2 +0,0 @@
-rootProject.name = 'HMCCosmetics'
-
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 00000000..47f1ba50
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1 @@
+rootProject.name = "HMCCosmetics"
\ No newline at end of file
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/HMCCosmetics.java b/src/main/java/io/github/fisher2911/hmccosmetics/HMCCosmetics.java
index 830d3030..b1e00dbe 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/HMCCosmetics.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/HMCCosmetics.java
@@ -2,7 +2,6 @@ package io.github.fisher2911.hmccosmetics;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
-
import io.github.fisher2911.hmccosmetics.command.CosmeticsCommand;
import io.github.fisher2911.hmccosmetics.concurrent.Threads;
import io.github.fisher2911.hmccosmetics.config.Settings;
@@ -13,28 +12,32 @@ import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.gui.CosmeticsMenu;
import io.github.fisher2911.hmccosmetics.hook.HookManager;
import io.github.fisher2911.hmccosmetics.hook.item.ItemsAdderHook;
-import io.github.fisher2911.hmccosmetics.listener.*;
+import io.github.fisher2911.hmccosmetics.listener.ClickListener;
+import io.github.fisher2911.hmccosmetics.listener.CosmeticFixListener;
+import io.github.fisher2911.hmccosmetics.listener.JoinListener;
+import io.github.fisher2911.hmccosmetics.listener.RespawnListener;
+import io.github.fisher2911.hmccosmetics.listener.TeleportListener;
import io.github.fisher2911.hmccosmetics.message.MessageHandler;
import io.github.fisher2911.hmccosmetics.message.Messages;
import io.github.fisher2911.hmccosmetics.message.Translation;
import io.github.fisher2911.hmccosmetics.user.UserManager;
-import me.mattstudios.mf.base.CommandManager;
-import org.bstats.bukkit.Metrics;
-import org.bukkit.Bukkit;
-import org.bukkit.Color;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitTask;
-
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.Set;
import java.util.stream.Collectors;
+import me.mattstudios.mf.base.CommandManager;
+import org.bstats.bukkit.Metrics;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitTask;
public class HMCCosmetics extends JavaPlugin {
+ public static final Path PLUGIN_FOLDER = Paths.get("plugins", "HMCCosmetics");
+
private ProtocolManager protocolManager;
private Settings settings;
private UserManager userManager;
@@ -105,7 +108,8 @@ public class HMCCosmetics extends JavaPlugin {
new CosmeticFixListener(this)
).
forEach(
- listener -> this.getServer().getPluginManager().registerEvents(listener, this)
+ listener -> this.getServer().getPluginManager()
+ .registerEvents(listener, this)
);
}
@@ -117,7 +121,6 @@ public class HMCCosmetics extends JavaPlugin {
player,
Messages.MUST_BE_PLAYER
)
-
);
this.commandManager.getCompletionHandler().register("#types",
resolver ->
@@ -128,7 +131,8 @@ public class HMCCosmetics extends JavaPlugin {
);
this.commandManager.getCompletionHandler().register("#ids",
resolver ->
- this.cosmeticManager.getAll().stream().map(ArmorItem::getId).collect(Collectors.toList()));
+ this.cosmeticManager.getAll().stream().map(ArmorItem::getId)
+ .collect(Collectors.toList()));
this.commandManager.register(new CosmeticsCommand(this));
}
@@ -180,5 +184,6 @@ public class HMCCosmetics extends JavaPlugin {
public Database getDatabase() {
return database;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java b/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java
index 60663748..c2a4dd83 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java
@@ -1,12 +1,11 @@
package io.github.fisher2911.hmccosmetics.api;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
+import java.util.ArrayList;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
-import java.util.ArrayList;
-
/**
* Wrapper for ArmorItem used internally for convenience and safety
*/
@@ -19,7 +18,6 @@ public class CosmeticItem {
}
/**
- *
* @param itemStack the {@link org.bukkit.inventory.ItemStack} display item
* @param id the id of the item
* @param type the cosmetic item type
@@ -27,12 +25,12 @@ public class CosmeticItem {
* @param rgb from Bukkit's {@link Color#asRGB()}
*/
- public CosmeticItem(final ItemStack itemStack, final String id, final ArmorItem.Type type, final boolean dyeable, final int rgb) {
+ public CosmeticItem(final ItemStack itemStack, final String id, final ArmorItem.Type type,
+ final boolean dyeable, final int rgb) {
this.armorItem = new ArmorItem(itemStack, id, new ArrayList<>(), "", type, dyeable, rgb);
}
/**
- *
* @param material the {@link org.bukkit.Material} display item
* @param id the id of the item
* @param type the cosmetic item type
@@ -40,12 +38,12 @@ public class CosmeticItem {
* @param rgb from Bukkit's {@link Color#asRGB()}
*/
- public CosmeticItem(final Material material, final String id, final ArmorItem.Type type, final boolean dyeable, final int rgb) {
+ public CosmeticItem(final Material material, final String id, final ArmorItem.Type type,
+ final boolean dyeable, final int rgb) {
this.armorItem = new ArmorItem(material, id, new ArrayList<>(), "", type, dyeable, rgb);
}
/**
- *
* @param itemStack the {@link org.bukkit.inventory.ItemStack} display item
* @param id the id of the item
* @param type the cosmetic item type
@@ -56,7 +54,6 @@ public class CosmeticItem {
}
/**
- *
* @param material the {@link org.bukkit.Material} display item
* @param id the id of the item
* @param type the cosmetic item type
@@ -93,4 +90,5 @@ public class CosmeticItem {
public ArmorItem getArmorItem() {
return this.armorItem;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/api/HMCCosmeticsAPI.java b/src/main/java/io/github/fisher2911/hmccosmetics/api/HMCCosmeticsAPI.java
index 195ab73d..9f8cb0ba 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/api/HMCCosmeticsAPI.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/api/HMCCosmeticsAPI.java
@@ -4,10 +4,9 @@ import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.user.User;
import io.github.fisher2911.hmccosmetics.user.UserManager;
-import org.jetbrains.annotations.Nullable;
-
import java.util.Optional;
import java.util.UUID;
+import org.jetbrains.annotations.Nullable;
public class HMCCosmeticsAPI {
@@ -18,22 +17,23 @@ public class HMCCosmeticsAPI {
}
/**
+ * This will attempt to get the {@link io.github.fisher2911.hmccosmetics.api.CosmeticItem} that
+ * the user is wearing. It returns an empty {@link io.github.fisher2911.hmccosmetics.api.CosmeticItem}
+ * if the user is not found, or if the user is not wearing a cosmetic
*
- * This will attempt to get the {@link io.github.fisher2911.hmccosmetics.api.CosmeticItem} that the
- * user is wearing. It returns an empty {@link io.github.fisher2911.hmccosmetics.api.CosmeticItem} if the user
- * is not found, or if the user is not wearing a cosmetic
* @param uuid the uuid of the user
* @param type the type of cosmetic being retrieved
* @return the current cosmetic of the player
*/
public static CosmeticItem getUserCurrentItem(final UUID uuid, final ArmorItem.Type type) {
final Optional userOptional = plugin.getUserManager().get(uuid);
- if (userOptional.isEmpty()) return new CosmeticItem(ArmorItem.empty(type));
+ if (userOptional.isEmpty()) {
+ return new CosmeticItem(ArmorItem.empty(type));
+ }
return new CosmeticItem(userOptional.get().getPlayerArmor().getItem(type));
}
/**
- *
* @param uuid the uuid of the user whose cosmetic is being set
* @param cosmeticItem the cosmetic being set
* @return true if the cosmetic was set, or else false
@@ -41,14 +41,15 @@ public class HMCCosmeticsAPI {
public static boolean setCosmeticItem(final UUID uuid, final CosmeticItem cosmeticItem) {
final UserManager userManager = plugin.getUserManager();
final Optional userOptional = userManager.get(uuid);
- if (userOptional.isEmpty()) return false;
+ if (userOptional.isEmpty()) {
+ return false;
+ }
userManager.setItem(userOptional.get(), cosmeticItem.getArmorItem());
return true;
}
/**
- *
* @param id the id of the cosmetic item being retrieved
* @return null if the cosmetic was not found, or a copy of the cosmetic item
*/
@@ -56,19 +57,23 @@ public class HMCCosmeticsAPI {
@Nullable
public static CosmeticItem getCosmeticFromId(final String id) {
final ArmorItem armorItem = plugin.getCosmeticManager().getArmorItem(id);
- if (armorItem == null) return null;
+ if (armorItem == null) {
+ return null;
+ }
return new CosmeticItem(new ArmorItem(armorItem));
}
/**
- *
* @param uuid the uuid of the user whose armor stand id is being retrieved
* @return the armor stand id, or -1 if the user is not found
*/
public static int getUserArmorStandId(final UUID uuid) {
final Optional userOptional = plugin.getUserManager().get(uuid);
- if (userOptional.isEmpty()) return -1;
+ if (userOptional.isEmpty()) {
+ return -1;
+ }
return userOptional.get().getArmorStandId();
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticChangeEvent.java b/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticChangeEvent.java
index 8f06b9db..f3012eb1 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticChangeEvent.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticChangeEvent.java
@@ -8,10 +8,11 @@ import io.github.fisher2911.hmccosmetics.user.User;
*/
public class CosmeticChangeEvent extends CosmeticItemEvent {
- private CosmeticItem removed;
private final User user;
+ private CosmeticItem removed;
- public CosmeticChangeEvent(final CosmeticItem cosmeticItem, final CosmeticItem removed, final User user) {
+ public CosmeticChangeEvent(final CosmeticItem cosmeticItem, final CosmeticItem removed,
+ final User user) {
super(cosmeticItem);
this.removed = removed;
this.user = user;
@@ -28,4 +29,5 @@ public class CosmeticChangeEvent extends CosmeticItemEvent {
public void setRemoved(final CosmeticItem removed) {
this.removed = removed;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticItemEvent.java b/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticItemEvent.java
index 55589e87..f635bce6 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticItemEvent.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/api/event/CosmeticItemEvent.java
@@ -17,6 +17,10 @@ public abstract class CosmeticItemEvent extends Event implements Cancellable {
this.cancelled = false;
}
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+
public CosmeticItem getCosmeticItem() {
return this.cosmeticItem;
}
@@ -35,12 +39,9 @@ public abstract class CosmeticItemEvent extends Event implements Cancellable {
this.cancelled = cancelled;
}
- public static HandlerList getHandlerList() {
- return HANDLERS;
- }
-
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java b/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java
index d119c0b3..6c35e5b0 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java
@@ -10,6 +10,8 @@ import io.github.fisher2911.hmccosmetics.message.Placeholder;
import io.github.fisher2911.hmccosmetics.user.User;
import io.github.fisher2911.hmccosmetics.user.UserManager;
import io.github.fisher2911.hmccosmetics.util.StringUtils;
+import java.util.Map;
+import java.util.Optional;
import me.mattstudios.mf.annotations.Command;
import me.mattstudios.mf.annotations.Completion;
import me.mattstudios.mf.annotations.Default;
@@ -21,9 +23,6 @@ import org.bukkit.Color;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.util.Map;
-import java.util.Optional;
-
@Command("cosmetics")
public class CosmeticsCommand extends CommandBase {
@@ -62,7 +61,8 @@ public class CosmeticsCommand extends CommandBase {
@SubCommand("dye")
@Permission(io.github.fisher2911.hmccosmetics.message.Permission.DYE_COMMAND)
- public void dyeArmor(final Player player, @Completion("#types") String typeString, final @me.mattstudios.mf.annotations.Optional String dyeColor) {
+ public void dyeArmor(final Player player, @Completion("#types") String typeString,
+ final @me.mattstudios.mf.annotations.Optional String dyeColor) {
final Optional optionalUser = this.userManager.get(player.getUniqueId());
@@ -113,7 +113,8 @@ public class CosmeticsCommand extends CommandBase {
@SubCommand("add")
@Permission(io.github.fisher2911.hmccosmetics.message.Permission.SET_COSMETIC_COMMAND)
- public void setCommand(final CommandSender sender, @Completion("#players") final Player player, @Completion("#ids") final String id) {
+ public void setCommand(final CommandSender sender, @Completion("#players") final Player player,
+ @Completion("#ids") final String id) {
final Optional userOptional = this.userManager.get(player.getUniqueId());
if (userOptional.isEmpty()) {
@@ -153,7 +154,8 @@ public class CosmeticsCommand extends CommandBase {
@SubCommand("remove")
@Permission(io.github.fisher2911.hmccosmetics.message.Permission.SET_COSMETIC_COMMAND)
- public void removeCommand(final CommandSender sender, @Completion("#players") final Player player, @Completion("#types") String typeString) {
+ public void removeCommand(final CommandSender sender,
+ @Completion("#players") final Player player, @Completion("#types") String typeString) {
final Optional userOptional = this.userManager.get(player.getUniqueId());
if (userOptional.isEmpty()) {
@@ -169,13 +171,8 @@ public class CosmeticsCommand extends CommandBase {
try {
final ArmorItem.Type type = ArmorItem.Type.valueOf(typeString.toUpperCase());
- final Message setMessage = Messages.getRemovedMessage(type);
final Message setOtherMessage = Messages.getSetOtherMessage(type);
this.userManager.removeItem(user, type);
- this.messageHandler.sendMessage(
- player,
- setMessage
- );
this.messageHandler.sendMessage(
sender,
setOtherMessage,
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/concurrent/Threads.java b/src/main/java/io/github/fisher2911/hmccosmetics/concurrent/Threads.java
index 07b8a8f4..7a531e62 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/concurrent/Threads.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/concurrent/Threads.java
@@ -11,16 +11,16 @@ public class Threads {
INSTANCE = new Threads();
}
- public static Threads getInstance() {
- return INSTANCE;
- }
-
private final ExecutorService service;
private Threads() {
this.service = Executors.newFixedThreadPool(1);
}
+ public static Threads getInstance() {
+ return INSTANCE;
+ }
+
public void execute(final Runnable runnable) {
this.service.execute(runnable);
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/config/CosmeticSettings.java b/src/main/java/io/github/fisher2911/hmccosmetics/config/CosmeticSettings.java
index c76741d9..9fd1f8bd 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/config/CosmeticSettings.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/config/CosmeticSettings.java
@@ -1,10 +1,8 @@
package io.github.fisher2911.hmccosmetics.config;
-import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.EquipmentSlot;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
-import org.spongepowered.configurate.objectmapping.meta.Setting;
@ConfigSerializable
public class CosmeticSettings {
@@ -17,22 +15,24 @@ public class CosmeticSettings {
private boolean requireEmptyOffHand;
public void load(final FileConfiguration config) {
- this.requireEmptyHelmet = config.getBoolean(COSMETIC_SETTINGS_PATH + "." + REQUIRE_EMPTY_HELMET_PATH);
- this.requireEmptyOffHand = config.getBoolean(COSMETIC_SETTINGS_PATH + "." + REQUIRE_EMPTY_OFF_HAND_PATH);
+ this.requireEmptyHelmet = config.getBoolean(
+ COSMETIC_SETTINGS_PATH + "." + REQUIRE_EMPTY_HELMET_PATH);
+ this.requireEmptyOffHand = config.getBoolean(
+ COSMETIC_SETTINGS_PATH + "." + REQUIRE_EMPTY_OFF_HAND_PATH);
}
public boolean isRequireEmptyHelmet() {
return requireEmptyHelmet;
}
- public boolean isRequireEmptyOffHand() {
- return requireEmptyOffHand;
- }
-
public void setRequireEmptyHelmet(final boolean requireEmptyHelmet) {
this.requireEmptyHelmet = requireEmptyHelmet;
}
+ public boolean isRequireEmptyOffHand() {
+ return requireEmptyOffHand;
+ }
+
public void setRequireEmptyOffHand(final boolean requireEmptyOffHand) {
this.requireEmptyOffHand = requireEmptyOffHand;
}
@@ -44,4 +44,5 @@ public class CosmeticSettings {
default -> false;
};
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.java b/src/main/java/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.java
index a34d3c94..fd42c790 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.java
@@ -8,34 +8,20 @@ import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.gui.ColorItem;
import io.github.fisher2911.hmccosmetics.gui.DyeSelectorGui;
import io.github.fisher2911.hmccosmetics.message.Adventure;
-import io.github.fisher2911.hmccosmetics.util.StringUtils;
-import io.th0rgal.oraxen.utils.armorequipevent.ArmorType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import org.bukkit.Color;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializer;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-
public class DyeGuiSerializer implements TypeSerializer {
- private static final HMCCosmetics plugin;
-
- static {
- plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
- }
-
public static final DyeGuiSerializer INSTANCE = new DyeGuiSerializer();
-
- private DyeGuiSerializer() {}
-
+ private static final HMCCosmetics plugin;
private static final String TITLE = "title";
private static final String ROWS = "rows";
private static final String ITEMS = "items";
@@ -45,21 +31,30 @@ public class DyeGuiSerializer implements TypeSerializer {
private static final String GREEN = "green";
private static final String BLUE = "blue";
- private ConfigurationNode nonVirtualNode(final ConfigurationNode source, final Object... path) throws SerializationException {
+ static {
+ plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
+ }
+
+ private DyeGuiSerializer() {
+ }
+
+ private ConfigurationNode nonVirtualNode(final ConfigurationNode source, final Object... path)
+ throws SerializationException {
if (!source.hasChild(path)) {
- throw new SerializationException("Required field " + Arrays.toString(path) + " was not present in node");
+ throw new SerializationException(
+ "Required field " + Arrays.toString(path) + " was not present in node");
}
return source.node(path);
}
@Override
- public DyeSelectorGui deserialize(final Type type, final ConfigurationNode source) throws SerializationException {
+ public DyeSelectorGui deserialize(final Type type, final ConfigurationNode source)
+ throws SerializationException {
final ConfigurationNode titleNode = this.nonVirtualNode(source, TITLE);
final ConfigurationNode rowsNode = this.nonVirtualNode(source, ROWS);
final ConfigurationNode itemsNode = source.node(ITEMS);
final ConfigurationNode cosmeticSlotsNode = source.node(COSMETICS_SLOTS);
-
final Map guiItemMap = new HashMap<>();
final var itemMap = itemsNode.childrenMap();
@@ -88,7 +83,8 @@ public class DyeGuiSerializer implements TypeSerializer {
final int green = colorNode.node(GREEN).getInt();
final int blue = colorNode.node(BLUE).getInt();
- guiItemMap.put(slot, new ColorItem(guiItem.getItemStack(), Color.fromRGB(red, green, blue)));
+ guiItemMap.put(slot,
+ new ColorItem(guiItem.getItemStack(), Color.fromRGB(red, green, blue)));
}
final BiMap cosmeticSlots = HashBiMap.create();
@@ -114,12 +110,14 @@ public class DyeGuiSerializer implements TypeSerializer {
String title = titleNode.getString();
- if (title == null) title = "";
+ if (title == null) {
+ title = "";
+ }
return new DyeSelectorGui(
plugin,
Adventure.SERIALIZER.serialize(
- Adventure.MINI_MESSAGE.parse(title)),
+ Adventure.MINI_MESSAGE.deserialize(title)),
rowsNode.getInt(),
guiItemMap,
cosmeticSlots,
@@ -127,7 +125,9 @@ public class DyeGuiSerializer implements TypeSerializer {
}
@Override
- public void serialize(final Type type, @Nullable final DyeSelectorGui obj, final ConfigurationNode node) throws SerializationException {
+ public void serialize(final Type type, @Nullable final DyeSelectorGui obj,
+ final ConfigurationNode node) throws SerializationException {
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/config/GuiSerializer.java b/src/main/java/io/github/fisher2911/hmccosmetics/config/GuiSerializer.java
index 34236187..0c10c5bc 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/config/GuiSerializer.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/config/GuiSerializer.java
@@ -4,43 +4,42 @@ import dev.triumphteam.gui.guis.GuiItem;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import io.github.fisher2911.hmccosmetics.gui.CosmeticGui;
import io.github.fisher2911.hmccosmetics.message.Adventure;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializer;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
public class GuiSerializer implements TypeSerializer {
+ public static final GuiSerializer INSTANCE = new GuiSerializer();
private static final HMCCosmetics plugin;
+ private static final String TITLE = "title";
+ private static final String ROWS = "rows";
+ private static final String ITEMS = "items";
static {
plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
}
- public static final GuiSerializer INSTANCE = new GuiSerializer();
+ private GuiSerializer() {
+ }
- private GuiSerializer() {}
-
- private static final String TITLE = "title";
- private static final String ROWS = "rows";
- private static final String ITEMS = "items";
-
- private ConfigurationNode nonVirtualNode(final ConfigurationNode source, final Object... path) throws SerializationException {
+ private ConfigurationNode nonVirtualNode(final ConfigurationNode source, final Object... path)
+ throws SerializationException {
if (!source.hasChild(path)) {
- throw new SerializationException("Required field " + Arrays.toString(path) + " was not present in node");
+ throw new SerializationException(
+ "Required field " + Arrays.toString(path) + " was not present in node");
}
return source.node(path);
}
@Override
- public CosmeticGui deserialize(final Type type, final ConfigurationNode source) throws SerializationException {
+ public CosmeticGui deserialize(final Type type, final ConfigurationNode source)
+ throws SerializationException {
final ConfigurationNode titleNode = this.nonVirtualNode(source, TITLE);
final ConfigurationNode rowsNode = this.nonVirtualNode(source, ROWS);
final ConfigurationNode itemsNode = source.node(ITEMS);
@@ -64,17 +63,21 @@ public class GuiSerializer implements TypeSerializer {
String title = titleNode.getString();
- if (title == null) title = "";
+ if (title == null) {
+ title = "";
+ }
return new CosmeticGui(plugin,
Adventure.SERIALIZER.serialize(
- Adventure.MINI_MESSAGE.parse(title)),
+ Adventure.MINI_MESSAGE.deserialize(title)),
rowsNode.getInt(),
guiItemMap);
}
@Override
- public void serialize(final Type type, @Nullable final CosmeticGui obj, final ConfigurationNode node) throws SerializationException {
+ public void serialize(final Type type, @Nullable final CosmeticGui obj,
+ final ConfigurationNode node) throws SerializationException {
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/config/ItemSerializer.java b/src/main/java/io/github/fisher2911/hmccosmetics/config/ItemSerializer.java
index 1d5d0673..18875f57 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/config/ItemSerializer.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/config/ItemSerializer.java
@@ -10,7 +10,14 @@ import io.github.fisher2911.hmccosmetics.util.Utils;
import io.github.fisher2911.hmccosmetics.util.builder.ColorBuilder;
import io.github.fisher2911.hmccosmetics.util.builder.ItemBuilder;
import io.github.fisher2911.hmccosmetics.util.builder.SkullBuilder;
-import net.kyori.adventure.text.Component;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
@@ -25,25 +32,10 @@ import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializer;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
public class ItemSerializer implements TypeSerializer {
- private static final HMCCosmetics plugin;
-
- static {
- plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
- }
-
public static final ItemSerializer INSTANCE = new ItemSerializer();
-
+ private static final HMCCosmetics plugin;
private static final String MATERIAL = "material";
private static final String AMOUNT = "amount";
private static final String NAME = "name";
@@ -66,19 +58,26 @@ public class ItemSerializer implements TypeSerializer {
private static final String ID = "id";
private static final String DYEABLE = "dyeable";
+ static {
+ plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
+ }
+
private ItemSerializer() {
}
- private ConfigurationNode nonVirtualNode(final ConfigurationNode source, final Object... path) throws SerializationException {
+ private ConfigurationNode nonVirtualNode(final ConfigurationNode source, final Object... path)
+ throws SerializationException {
if (!source.hasChild(path)) {
- throw new SerializationException("Required field " + Arrays.toString(path) + " was not present in node");
+ throw new SerializationException(
+ "Required field " + Arrays.toString(path) + " was not present in node");
}
return source.node(path);
}
@Override
- public GuiItem deserialize(final Type type, final ConfigurationNode source) throws SerializationException {
+ public GuiItem deserialize(final Type type, final ConfigurationNode source)
+ throws SerializationException {
final ConfigurationNode materialNode = this.nonVirtualNode(source, MATERIAL);
final ConfigurationNode amountNode = source.node(AMOUNT);
final ConfigurationNode nameNode = source.node(NAME);
@@ -101,7 +100,6 @@ public class ItemSerializer implements TypeSerializer {
final ConfigurationNode idNode = source.node(ID);
final ConfigurationNode dyeableNode = source.node(DYEABLE);
-
final String materialString = Utils.replaceIfNull(materialNode.getString(), "");
final int amount = amountNode.getInt();
@@ -111,24 +109,28 @@ public class ItemSerializer implements TypeSerializer {
itemStack = new ItemStack(Material.valueOf(materialString), amount);
} catch (final IllegalArgumentException exception) {
itemStack = HookManager.getInstance().getItemHooks().getItemStack(materialString);
- if (itemStack == null) itemStack = new ItemStack(Material.AIR);
+ if (itemStack == null) {
+ itemStack = new ItemStack(Material.AIR);
+ }
}
-
final String name = StringUtils.parseStringToString(nameNode.getString());
final boolean unbreakable = unbreakableNode.getBoolean();
final boolean glowing = glowingNode.getBoolean();
- final List lore = Utils.replaceIfNull(loreNode.getList(String.class), new ArrayList()).
+ final List lore = Utils.replaceIfNull(loreNode.getList(String.class),
+ new ArrayList()).
stream().map(StringUtils::parseStringToString).collect(Collectors.toList());
- final List lockedLore = Utils.replaceIfNull(lockedLoreNode.getList(String.class), new ArrayList()).
+ final List lockedLore = Utils.replaceIfNull(lockedLoreNode.getList(String.class),
+ new ArrayList()).
stream().map(StringUtils::parseStringToString).collect(Collectors.toList());
final int modelData = modelDataNode.getInt();
- final Set itemFlags = Utils.replaceIfNull(itemFlagsNode.getList(String.class), new ArrayList()).
+ final Set itemFlags = Utils.replaceIfNull(itemFlagsNode.getList(String.class),
+ new ArrayList()).
stream().map(flag -> {
try {
return ItemFlag.valueOf(flag.toUpperCase());
@@ -159,9 +161,10 @@ public class ItemSerializer implements TypeSerializer {
return null;
}
- final NamespacedKey namespacedKey = NamespacedKey.minecraft(enchantmentString.
- split(":")[0].
- toLowerCase());
+ final NamespacedKey namespacedKey = NamespacedKey.minecraft(
+ enchantmentString.
+ split(":")[0].
+ toLowerCase());
return Registry.ENCHANTMENT.get(namespacedKey);
}, enchantmentString -> {
@@ -175,7 +178,6 @@ public class ItemSerializer implements TypeSerializer {
}
}));
-
final ItemBuilder itemBuilder;
if (itemStack.getType() == Material.PLAYER_HEAD) {
@@ -239,14 +241,14 @@ public class ItemSerializer implements TypeSerializer {
} catch (final IllegalArgumentException exception) {
return dev.triumphteam.gui.builder.item.ItemBuilder.from(
itemStack).
- asGuiItem(event -> {
- plugin.getCosmeticsMenu().openMenu(openMenu, event.getWhoClicked());
- });
+ asGuiItem(event -> plugin.getCosmeticsMenu().openMenu(openMenu, event.getWhoClicked()));
}
}
@Override
- public void serialize(final Type type, @Nullable final GuiItem obj, final ConfigurationNode node) throws SerializationException {
+ public void serialize(final Type type, @Nullable final GuiItem obj,
+ final ConfigurationNode node) throws SerializationException {
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/config/Settings.java b/src/main/java/io/github/fisher2911/hmccosmetics/config/Settings.java
index c9bd25bd..4aed225e 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/config/Settings.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/config/Settings.java
@@ -1,7 +1,6 @@
package io.github.fisher2911.hmccosmetics.config;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
-import org.bukkit.Bukkit;
public class Settings {
@@ -22,4 +21,5 @@ public class Settings {
public CosmeticSettings getCosmeticSettings() {
return settings;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.java b/src/main/java/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.java
index af2dfa52..95331b19 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.java
@@ -1,11 +1,9 @@
package io.github.fisher2911.hmccosmetics.cosmetic;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
-import org.jetbrains.annotations.Nullable;
-
import java.util.Collection;
import java.util.Map;
-import java.util.Set;
+import org.jetbrains.annotations.Nullable;
public class CosmeticManager {
@@ -31,4 +29,5 @@ public class CosmeticManager {
public Map getArmorItemMap() {
return armorItemMap;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/database/Database.java b/src/main/java/io/github/fisher2911/hmccosmetics/database/Database.java
index d55e4f3c..bf28b548 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/database/Database.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/database/Database.java
@@ -4,7 +4,6 @@ import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
-import com.sun.tools.jconsole.JConsoleContext;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import io.github.fisher2911.hmccosmetics.concurrent.Threads;
import io.github.fisher2911.hmccosmetics.database.dao.ArmorItemDAO;
@@ -12,19 +11,21 @@ import io.github.fisher2911.hmccosmetics.database.dao.UserDAO;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.inventory.PlayerArmor;
import io.github.fisher2911.hmccosmetics.user.User;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
+import org.bukkit.Bukkit;
public class Database {
+ protected final HMCCosmetics plugin;
+ final Dao userDao;
+ final Dao armorItemDao;
+ private final ConnectionSource dataSource;
+ private final DatabaseType databaseType;
AtomicInteger ARMOR_STAND_ID = new AtomicInteger(Integer.MAX_VALUE);
-
String TABLE_NAME = "user";
String PLAYER_UUID_COLUMN = "uuid";
String BACKPACK_COLUMN = "backpack";
@@ -40,14 +41,6 @@ public class Database {
PLAYER_UUID_COLUMN +
"))";
- protected final HMCCosmetics plugin;
- private final ConnectionSource dataSource;
-
- private final DatabaseType databaseType;
-
- final Dao userDao;
- final Dao armorItemDao;
-
public Database(
final HMCCosmetics plugin,
final ConnectionSource dataSource,
@@ -84,9 +77,11 @@ public class Database {
user = this.userDao.createIfNotExists(new UserDAO(uuid));
}
- final List armorItems = this.armorItemDao.queryForEq("uuid", uuid.toString());
+ final List armorItems = this.armorItemDao.queryForEq("uuid",
+ uuid.toString());
- final User actualUser = user.toUser(this.plugin.getCosmeticManager(), armorItems, armorStandId);
+ final User actualUser = user.toUser(this.plugin.getCosmeticManager(),
+ armorItems, armorStandId);
Bukkit.getScheduler().runTask(this.plugin,
() -> {
this.plugin.getUserManager().add(
@@ -153,4 +148,5 @@ public class Database {
public Dao getArmorItemDao() {
return armorItemDao;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseConverter.java b/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseConverter.java
index a99b4db0..fed19f51 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseConverter.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseConverter.java
@@ -1,14 +1,9 @@
package io.github.fisher2911.hmccosmetics.database;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
-import io.github.fisher2911.hmccosmetics.cosmetic.CosmeticManager;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.inventory.PlayerArmor;
import io.github.fisher2911.hmccosmetics.user.User;
-import org.bukkit.Bukkit;
-import org.bukkit.Color;
-import org.bukkit.configuration.file.YamlConfiguration;
-
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
@@ -21,20 +16,20 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
+import org.bukkit.configuration.file.YamlConfiguration;
public class DatabaseConverter {
+ private static final int CURRENT_VERSION = 2;
+ private static final String FILE_NAME = "info.yml";
private final HMCCosmetics plugin;
private final Database database;
- private static final int CURRENT_VERSION = 2;
public DatabaseConverter(final HMCCosmetics plugin, final Database database) {
this.database = database;
this.plugin = plugin;
}
- private static final String FILE_NAME = "info.yml";
-
public void convert() {
final File folder = new File(this.plugin.getDataFolder(), "database");
@@ -65,7 +60,9 @@ public class DatabaseConverter {
this.database.createTables();
- for (final User user : users) database.saveUser(user);
+ for (final User user : users) {
+ database.saveUser(user);
+ }
}
private void convert(final int version, final Consumer consumer) {
@@ -77,12 +74,14 @@ public class DatabaseConverter {
private void convertVersionOne(final Consumer consumer) {
final String query = "SELECT * from user";
- try (final PreparedStatement statement = this.database.getDataSource().getReadOnlyConnection("user").
+ try (final PreparedStatement statement = this.database.getDataSource()
+ .getReadOnlyConnection("user").
getUnderlyingConnection().prepareStatement(query)) {
final ResultSet results = statement.executeQuery();
try {
- final Map armorItems = new ConcurrentHashMap<>(this.plugin.getCosmeticManager().getArmorItemMap());
+ final Map armorItems = new ConcurrentHashMap<>(
+ this.plugin.getCosmeticManager().getArmorItemMap());
while (results.next()) {
final PlayerArmor playerArmor = PlayerArmor.empty();
@@ -97,7 +96,9 @@ public class DatabaseConverter {
final ArmorItem backpack = armorItems.get(backpackId);
final ArmorItem hat = armorItems.get(hatId);
- if (backpack != null) playerArmor.setItem(backpack);
+ if (backpack != null) {
+ playerArmor.setItem(backpack);
+ }
if (hat != null) {
hat.setDye(hatDye);
playerArmor.setItem(hat);
@@ -112,11 +113,13 @@ public class DatabaseConverter {
exception.printStackTrace();
}
- try (final PreparedStatement dropStatement = this.database.getDataSource().getReadWriteConnection("user").
+ try (final PreparedStatement dropStatement = this.database.getDataSource()
+ .getReadWriteConnection("user").
getUnderlyingConnection().prepareStatement("DROP TABLE user")) {
dropStatement.executeUpdate();
} catch (final SQLException exception) {
exception.printStackTrace();
}
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseFactory.java b/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseFactory.java
index 58f9a532..741228a8 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseFactory.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/database/DatabaseFactory.java
@@ -5,18 +5,18 @@ import com.j256.ormlite.jdbc.JdbcPooledConnectionSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.sql.SQLException;
+import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
-import java.io.File;
-import java.nio.file.Path;
-import java.sql.SQLException;
-import java.util.logging.Logger;
-
public class DatabaseFactory {
- private static final String FILE_NAME = "database.yml";
+ private static final Path FILE_PATH = HMCCosmetics.PLUGIN_FOLDER.resolve("database.yml");
private static final String TYPE_PATH = "type";
private static final String NAME_PATH = "name";
private static final String USERNAME_PATH = "username";
@@ -25,13 +25,11 @@ public class DatabaseFactory {
private static final String PORT_PATH = "port";
public static Database create(final HMCCosmetics plugin) throws SQLException {
- final File file = Path.of(plugin.getDataFolder().getPath(), FILE_NAME).toFile();
-
- if (!file.exists()) {
- plugin.saveResource(FILE_NAME, false);
+ if (!Files.exists(FILE_PATH)) {
+ plugin.saveResource(FILE_PATH.getFileName().toString(), false);
}
- final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
+ final FileConfiguration config = YamlConfiguration.loadConfiguration(FILE_PATH.toFile());
final String type = config.getString(TYPE_PATH);
@@ -82,7 +80,8 @@ public class DatabaseFactory {
};
if (database == null) {
- logger.severe("Error loading database, type " + type + " is invalid! Disabling plugin.");
+ logger.severe(
+ "Error loading database, type " + type + " is invalid! Disabling plugin.");
Bukkit.getPluginManager().disablePlugin(plugin);
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/ArmorItemDAO.java b/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/ArmorItemDAO.java
index 2d43de77..c5c0e98d 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/ArmorItemDAO.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/ArmorItemDAO.java
@@ -4,9 +4,8 @@ import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import io.github.fisher2911.hmccosmetics.cosmetic.CosmeticManager;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
-import org.jetbrains.annotations.Nullable;
-
import java.util.Objects;
+import org.jetbrains.annotations.Nullable;
@DatabaseTable(tableName = "armor_items")
public class ArmorItemDAO {
@@ -33,22 +32,25 @@ public class ArmorItemDAO {
this.rgbDye = rgbDye;
}
+ public ArmorItemDAO() {
+ }
+
public static ArmorItemDAO fromArmorItem(final ArmorItem armorItem) {
- return new ArmorItemDAO(armorItem.getId(), armorItem.getType().toString(), armorItem.getDye());
+ return new ArmorItemDAO(armorItem.getId(), armorItem.getType().toString(),
+ armorItem.getDye());
}
@Nullable
public ArmorItem toArmorItem(final CosmeticManager cosmeticManager) {
final ArmorItem armorItem = cosmeticManager.getArmorItem(this.id);
- if (armorItem == null) return null;
+ if (armorItem == null) {
+ return null;
+ }
final ArmorItem copy = new ArmorItem(armorItem);
copy.setDye(this.rgbDye);
return copy;
}
- public ArmorItemDAO() {
- }
-
public String getUuid() {
return uuid;
}
@@ -59,6 +61,7 @@ public class ArmorItemDAO {
/**
* ORMLite does not allow more than one primary key (WHYYYY???????????)
+ *
* @return
*/
public String getArtificialId() {
@@ -91,10 +94,15 @@ public class ArmorItemDAO {
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
final ArmorItemDAO that = (ArmorItemDAO) o;
- return Objects.equals(getUuid(), that.getUuid()) && Objects.equals(getType(), that.getType());
+ return Objects.equals(getUuid(), that.getUuid()) && Objects.equals(getType(),
+ that.getType());
}
@Override
@@ -111,4 +119,5 @@ public class ArmorItemDAO {
", rgbDye=" + rgbDye +
'}';
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/UserDAO.java b/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/UserDAO.java
index a1108416..d6535891 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/UserDAO.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/database/dao/UserDAO.java
@@ -1,16 +1,11 @@
package io.github.fisher2911.hmccosmetics.database.dao;
-import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
-import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;
import io.github.fisher2911.hmccosmetics.cosmetic.CosmeticManager;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.inventory.PlayerArmor;
import io.github.fisher2911.hmccosmetics.user.User;
-
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@@ -24,20 +19,23 @@ public class UserDAO {
public UserDAO() {
}
- public void setUuid(final UUID uuid) {
- this.uuid = uuid;
- }
-
public UserDAO(final UUID uuid) {
this.uuid = uuid;
}
- public User toUser(final CosmeticManager cosmeticManager, final List armorItems, final int armorStandId) {
+ public void setUuid(final UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ public User toUser(final CosmeticManager cosmeticManager, final List armorItems,
+ final int armorStandId) {
final PlayerArmor playerArmor = PlayerArmor.empty();
for (final ArmorItemDAO armorItemDao : armorItems) {
final ArmorItem armorItem = armorItemDao.toArmorItem(cosmeticManager);
- if (armorItem == null) continue;
+ if (armorItem == null) {
+ continue;
+ }
playerArmor.setItem(armorItem);
}
@@ -53,8 +51,12 @@ public class UserDAO {
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
final UserDAO userDAO = (UserDAO) o;
return Objects.equals(uuid, userDAO.uuid);
}
@@ -63,4 +65,5 @@ public class UserDAO {
public int hashCode() {
return Objects.hash(uuid);
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java b/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java
index 7ede3f39..7300d5e0 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java
@@ -4,6 +4,9 @@ import dev.triumphteam.gui.components.GuiAction;
import dev.triumphteam.gui.guis.GuiItem;
import io.github.fisher2911.hmccosmetics.util.builder.ColorBuilder;
import io.github.fisher2911.hmccosmetics.util.builder.ItemBuilder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
@@ -11,17 +14,13 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
public class ArmorItem extends GuiItem {
private final String id;
private final List lockedLore;
- private GuiAction action;
private final String permission;
private final Type type;
+ private GuiAction action;
private boolean dyeable;
private int dye;
@@ -166,17 +165,6 @@ public class ArmorItem extends GuiItem {
this.dye = dye;
}
- public static ArmorItem empty(final Type type) {
- return new ArmorItem(
- new ItemStack(Material.AIR),
- "",
- new ArrayList<>(),
- "",
- type,
- -1
- );
- }
-
public ArmorItem(final ArmorItem armorItem) {
super(armorItem.getItemStack(), armorItem.getAction());
this.id = armorItem.getId();
@@ -189,6 +177,17 @@ public class ArmorItem extends GuiItem {
this.dye = armorItem.getDye();
}
+ public static ArmorItem empty(final Type type) {
+ return new ArmorItem(
+ new ItemStack(Material.AIR),
+ "",
+ new ArrayList<>(),
+ "",
+ type,
+ -1
+ );
+ }
+
public String getId() {
return id;
}
@@ -201,6 +200,12 @@ public class ArmorItem extends GuiItem {
return this.action;
}
+ @Override
+ public void setAction(final GuiAction action) {
+ super.setAction(action);
+ this.action = action;
+ }
+
public String getPermission() {
return permission;
}
@@ -253,12 +258,6 @@ public class ArmorItem extends GuiItem {
return this.getItemStack().getType() == Material.AIR;
}
- @Override
- public void setAction(final GuiAction action) {
- super.setAction(action);
- this.action = action;
- }
-
public ArmorItem copy() {
return new ArmorItem(this);
}
@@ -272,4 +271,5 @@ public class ArmorItem extends GuiItem {
OFF_HAND
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/gui/ColorItem.java b/src/main/java/io/github/fisher2911/hmccosmetics/gui/ColorItem.java
index 6b8a60ef..744e5f29 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/gui/ColorItem.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/gui/ColorItem.java
@@ -13,7 +13,9 @@ public class ColorItem extends GuiItem {
private final Color color;
- public ColorItem(final @NotNull ItemStack itemStack, final GuiAction action, final Color color) {
+ public ColorItem(final @NotNull ItemStack itemStack,
+ final GuiAction action,
+ final Color color) {
super(itemStack, action);
this.color = color;
}
@@ -28,7 +30,8 @@ public class ColorItem extends GuiItem {
this.color = color;
}
- public ColorItem(final @NotNull Material material, final @Nullable GuiAction action, final Color color) {
+ public ColorItem(final @NotNull Material material,
+ final @Nullable GuiAction action, final Color color) {
super(material, action);
this.color = color;
}
@@ -36,4 +39,5 @@ public class ColorItem extends GuiItem {
public Color getColor() {
return color;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.java b/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.java
index 77827232..e4d4a6cb 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.java
@@ -1,6 +1,5 @@
package io.github.fisher2911.hmccosmetics.gui;
-import com.comphenix.net.bytebuddy.jar.asm.Type;
import dev.triumphteam.gui.components.GuiAction;
import dev.triumphteam.gui.guis.Gui;
import dev.triumphteam.gui.guis.GuiItem;
@@ -11,21 +10,20 @@ import io.github.fisher2911.hmccosmetics.message.MessageHandler;
import io.github.fisher2911.hmccosmetics.message.Messages;
import io.github.fisher2911.hmccosmetics.message.Placeholder;
import io.github.fisher2911.hmccosmetics.user.User;
-import io.github.fisher2911.hmccosmetics.util.StringUtils;
import io.github.fisher2911.hmccosmetics.util.builder.ItemBuilder;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-
public class CosmeticGui {
+ private static final float COOL_DOWN = 0.5f;
protected final HMCCosmetics plugin;
protected final MessageHandler messageHandler;
protected final String title;
@@ -33,11 +31,8 @@ public class CosmeticGui {
protected final Map itemStackMap;
protected final Map guiItemMap;
protected Gui gui;
-
private long lastClicked;
- private static final float COOL_DOWN = 0.5f;
-
public CosmeticGui(
final HMCCosmetics plugin,
final String title,
@@ -53,7 +48,6 @@ public class CosmeticGui {
}
private void setItems(final User user) {
-
final Player player = user.getPlayer();
if (player == null) {
@@ -64,7 +58,9 @@ public class CosmeticGui {
final int slot = entry.getKey();
final GuiItem guiItem = this.getGuiItem(user, player, slot);
- if (guiItem == null) continue;
+ if (guiItem == null) {
+ continue;
+ }
this.gui.setItem(slot, guiItem);
}
@@ -78,7 +74,9 @@ public class CosmeticGui {
final GuiAction actionIfSet) {
final long current = System.currentTimeMillis();
- if ((current - this.lastClicked) / 1000. < COOL_DOWN) return;
+ if ((current - this.lastClicked) / 1000. < COOL_DOWN) {
+ return;
+ }
this.lastClicked = current;
if (!(human instanceof final Player player)) {
@@ -102,13 +100,16 @@ public class CosmeticGui {
final GuiItem guiItem = this.getGuiItem(user, player, slot);
- if (guiItem == null) return;
+ if (guiItem == null) {
+ return;
+ }
this.gui.updateItem(slot, guiItem);
}
public void open(final HumanEntity humanEntity) {
- final Optional optionalUser = this.plugin.getUserManager().get(humanEntity.getUniqueId());
+ final Optional optionalUser = this.plugin.getUserManager()
+ .get(humanEntity.getUniqueId());
if (optionalUser.isEmpty()) {
return;
@@ -117,7 +118,8 @@ public class CosmeticGui {
final User user = optionalUser.get();
this.gui = Gui.gui().
- title(Adventure.MINI_MESSAGE.parse(Placeholder.applyPapiPlaceholders(user.getPlayer(), this.title))).
+ title(Adventure.MINI_MESSAGE.deserialize(
+ Placeholder.applyPapiPlaceholders(user.getPlayer(), this.title))).
rows(this.rows).
create();
@@ -132,15 +134,19 @@ public class CosmeticGui {
private GuiItem getGuiItem(final User user, final Player player, final int slot) {
final GuiItem guiItem = this.guiItemMap.get(slot);
- if (guiItem == null) return null;
+ if (guiItem == null) {
+ return null;
+ }
final ItemStack itemStack = this.itemStackMap.get(slot);
- if (itemStack == null) return null;
+ if (itemStack == null) {
+ return null;
+ }
if (guiItem instanceof final ArmorItem armorItem) {
-
- final String permission = armorItem.getPermission() == null ? "" : armorItem.getPermission();
+ final String permission =
+ armorItem.getPermission() == null ? "" : armorItem.getPermission();
final boolean hasPermission = permission.isBlank() || player.hasPermission(permission);
@@ -155,9 +161,12 @@ public class CosmeticGui {
return;
}
- final ArmorItem cosmeticItem = this.plugin.getCosmeticManager().getArmorItem(armorItem.getId());
+ final ArmorItem cosmeticItem = this.plugin.getCosmeticManager()
+ .getArmorItem(armorItem.getId());
- if (cosmeticItem == null) return;
+ if (cosmeticItem == null) {
+ return;
+ }
this.setUserArmor(player, user, cosmeticItem, event, armorItem.getAction());
}
@@ -171,7 +180,8 @@ public class CosmeticGui {
return guiItem;
}
- protected ItemStack applyPlaceholders(final User user, final Player player, final ArmorItem armorItem, final boolean hasPermission) {
+ protected ItemStack applyPlaceholders(final User user, final Player player,
+ final ArmorItem armorItem, final boolean hasPermission) {
final Map placeholders = new HashMap<>();
final PlayerArmor playerArmor = user.getPlayerArmor();
@@ -214,4 +224,5 @@ public class CosmeticGui {
new HashMap<>(this.guiItemMap)
);
}
+
}
\ No newline at end of file
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.java b/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.java
index bc8e3f94..735c16c1 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.java
@@ -7,6 +7,10 @@ import io.github.fisher2911.hmccosmetics.config.GuiSerializer;
import io.github.fisher2911.hmccosmetics.config.ItemSerializer;
import io.github.fisher2911.hmccosmetics.cosmetic.CosmeticManager;
import io.github.fisher2911.hmccosmetics.user.User;
+import java.io.File;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
@@ -16,12 +20,6 @@ import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
-import java.io.File;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Supplier;
-
public class CosmeticsMenu {
public static final String MAIN_MENU = "main";
@@ -76,7 +74,9 @@ public class CosmeticsMenu {
@Nullable
private CosmeticGui getGui(final String id) {
final CosmeticGui gui = this.guiMap.get(id);
- if (gui == null) return null;
+ if (gui == null) {
+ return null;
+ }
return gui.copy();
}
@@ -95,8 +95,8 @@ public class CosmeticsMenu {
}
if (!Path.of(this.plugin.getDataFolder().getPath(),
- "menus",
- DYE_MENU + ".yml").toFile().exists()) {
+ "menus",
+ DYE_MENU + ".yml").toFile().exists()) {
this.plugin.saveResource(
new File("menus", DYE_MENU + ".yml").getPath(),
false
@@ -134,22 +134,28 @@ public class CosmeticsMenu {
final ConfigurationNode source = loader.load();
if (id.equals(DYE_MENU)) {
- this.guiMap.put(id, DyeGuiSerializer.INSTANCE.deserialize(DyeSelectorGui.class, source));
+ this.guiMap.put(id,
+ DyeGuiSerializer.INSTANCE.deserialize(DyeSelectorGui.class, source));
this.plugin.getLogger().info("Loaded dye gui: " + id);
continue;
}
final CosmeticGui gui = source.get(CosmeticGui.class);
- if (gui == null) continue;
+ if (gui == null) {
+ continue;
+ }
for (final GuiItem guiItem : gui.guiItemMap.values()) {
if (guiItem instanceof final ArmorItem item) {
final ArmorItem copy = new ArmorItem(item);
copy.setAction(null);
this.cosmeticManager.addArmorItem(copy);
- if (copy.getPermission().isBlank()) continue;
- Bukkit.getPluginManager().addPermission(new Permission(copy.getPermission()));
+ if (copy.getPermission().isBlank()) {
+ continue;
+ }
+ Bukkit.getPluginManager()
+ .addPermission(new Permission(copy.getPermission()));
}
}
@@ -161,4 +167,5 @@ public class CosmeticsMenu {
}
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.java b/src/main/java/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.java
index 14855bc0..5acb0413 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.java
@@ -5,12 +5,13 @@ import com.google.common.collect.HashBiMap;
import dev.triumphteam.gui.guis.Gui;
import dev.triumphteam.gui.guis.GuiItem;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
-import io.github.fisher2911.hmccosmetics.database.dao.ArmorItemDAO;
import io.github.fisher2911.hmccosmetics.inventory.PlayerArmor;
import io.github.fisher2911.hmccosmetics.message.Placeholder;
import io.github.fisher2911.hmccosmetics.user.User;
-import io.github.fisher2911.hmccosmetics.util.StringUtils;
import io.github.fisher2911.hmccosmetics.util.builder.ItemBuilder;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
@@ -18,10 +19,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
public class DyeSelectorGui extends CosmeticGui {
private final BiMap cosmeticsSlots;
@@ -46,7 +43,8 @@ public class DyeSelectorGui extends CosmeticGui {
public Gui getGui(final User user, @Nullable final ArmorItem.Type type) {
this.gui = Gui.gui().
- title(Component.text(Placeholder.applyPapiPlaceholders(user.getPlayer(), this.title))).
+ title(Component.text(
+ Placeholder.applyPapiPlaceholders(user.getPlayer(), this.title))).
rows(rows).
create();
@@ -77,7 +75,9 @@ public class DyeSelectorGui extends CosmeticGui {
final ItemStack itemStack = this.itemStackMap.get(entry.getKey());
- if (itemStack == null) continue;
+ if (itemStack == null) {
+ continue;
+ }
guiItem.setItemStack(
ItemBuilder.from(itemStack.clone()).papiPlaceholders(player).build()
@@ -162,7 +162,9 @@ public class DyeSelectorGui extends CosmeticGui {
private void updateSelected(final User user, final Player player) {
final ArmorItem.Type type = this.cosmeticsSlots.get(this.selectedCosmetic);
- if (type == null) return;
+ if (type == null) {
+ return;
+ }
this.gui.updateItem(this.selectedCosmetic,
@@ -176,7 +178,8 @@ public class DyeSelectorGui extends CosmeticGui {
@Override
public void open(final HumanEntity player) {
final Optional optionalUser = this.plugin.getUserManager().get(player.getUniqueId());
- optionalUser.ifPresent(user -> this.getGui(user, user.getLastSetItem().getType()).open(player));
+ optionalUser.ifPresent(
+ user -> this.getGui(user, user.getLastSetItem().getType()).open(player));
}
@Override
@@ -194,4 +197,5 @@ public class DyeSelectorGui extends CosmeticGui {
this.selectedCosmetic
);
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/hook/HookManager.java b/src/main/java/io/github/fisher2911/hmccosmetics/hook/HookManager.java
index edf3453c..a72a86cf 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/hook/HookManager.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/hook/HookManager.java
@@ -5,15 +5,14 @@ import io.github.fisher2911.hmccosmetics.hook.item.ItemHook;
import io.github.fisher2911.hmccosmetics.hook.item.ItemHooks;
import io.github.fisher2911.hmccosmetics.hook.item.ItemsAdderHook;
import io.github.fisher2911.hmccosmetics.hook.item.OraxenHook;
-import org.bukkit.Bukkit;
-import org.bukkit.event.Listener;
-import org.bukkit.plugin.PluginManager;
-import org.jetbrains.annotations.Nullable;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.bukkit.Bukkit;
+import org.bukkit.event.Listener;
+import org.bukkit.plugin.PluginManager;
+import org.jetbrains.annotations.Nullable;
public class HookManager {
@@ -23,12 +22,7 @@ public class HookManager {
INSTANCE = new HookManager(HMCCosmetics.getPlugin(HMCCosmetics.class));
}
- public static HookManager getInstance() {
- return INSTANCE;
- }
-
private final HMCCosmetics plugin;
-
private final ItemHooks itemHooks;
private final PAPIHook papiHook;
private final Set> registeredHooks;
@@ -49,7 +43,9 @@ public class HookManager {
final Map itemHookMap = new HashMap<>();
final OraxenHook oraxenHook = new OraxenHook();
final ItemsAdderHook itemsAdderHook = new ItemsAdderHook();
- if (pluginManager.getPlugin("Oraxen") != null) itemHookMap.put(oraxenHook.getIdentifier(), oraxenHook);
+ if (pluginManager.getPlugin("Oraxen") != null) {
+ itemHookMap.put(oraxenHook.getIdentifier(), oraxenHook);
+ }
if (pluginManager.getPlugin("ItemsAdder") != null) {
itemHookMap.put(itemsAdderHook.getIdentifier(), itemsAdderHook);
this.listeners.add(itemsAdderHook);
@@ -59,6 +55,10 @@ public class HookManager {
itemHookMap.values().forEach(hook -> this.registerHook(hook.getClass()));
}
+ public static HookManager getInstance() {
+ return INSTANCE;
+ }
+
protected void registerHook(final Class extends Hook> hook) {
this.registeredHooks.add(hook);
}
@@ -81,4 +81,5 @@ public class HookManager {
public ItemHooks getItemHooks() {
return itemHooks;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemHooks.java b/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemHooks.java
index f7ed067d..423c7ffe 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemHooks.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemHooks.java
@@ -1,10 +1,9 @@
package io.github.fisher2911.hmccosmetics.hook.item;
+import java.util.Map;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
-import java.util.Map;
-
public class ItemHooks {
private final Map itemHookMap;
@@ -17,20 +16,27 @@ public class ItemHooks {
public ItemStack getItemStack(final String item) {
final String[] parts = item.split(":");
- if (parts.length < 2) return null;
+ if (parts.length < 2) {
+ return null;
+ }
final String identifier = parts[0];
final StringBuilder itemId = new StringBuilder();
for (int i = 1; i < parts.length; i++) {
itemId.append(parts[i]);
- if (i < parts.length - 1) itemId.append(":");
+ if (i < parts.length - 1) {
+ itemId.append(":");
+ }
}
final ItemHook hook = this.itemHookMap.get(identifier);
- if (hook == null) return null;
+ if (hook == null) {
+ return null;
+ }
return hook.getItem(itemId.toString());
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemsAdderHook.java b/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemsAdderHook.java
index 83407ceb..943ec3d9 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemsAdderHook.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/ItemsAdderHook.java
@@ -32,7 +32,10 @@ public class ItemsAdderHook implements ItemHook, Listener {
@Override
public ItemStack getItem(final String id) {
final CustomStack stack = CustomStack.getInstance(id);
- if (stack == null) return null;
+ if (stack == null) {
+ return null;
+ }
return stack.getItemStack().clone();
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/OraxenHook.java b/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/OraxenHook.java
index 6991311f..0f6df958 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/OraxenHook.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/hook/item/OraxenHook.java
@@ -1,6 +1,5 @@
package io.github.fisher2911.hmccosmetics.hook.item;
-import io.github.fisher2911.hmccosmetics.hook.Hook;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.items.OraxenItems;
import org.bukkit.inventory.ItemStack;
@@ -23,7 +22,10 @@ public class OraxenHook implements ItemHook {
@Override
public ItemStack getItem(final String id) {
final ItemBuilder itemBuilder = OraxenItems.getItemById(id);
- if (itemBuilder == null) return null;
+ if (itemBuilder == null) {
+ return null;
+ }
return itemBuilder.build();
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/inventory/PlayerArmor.java b/src/main/java/io/github/fisher2911/hmccosmetics/inventory/PlayerArmor.java
index 4d590cf5..7303993e 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/inventory/PlayerArmor.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/inventory/PlayerArmor.java
@@ -1,9 +1,7 @@
package io.github.fisher2911.hmccosmetics.inventory;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
-
import java.util.Collection;
-import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
@@ -19,6 +17,10 @@ public class PlayerArmor {
this.armorItems.put(offHand.getType(), offHand);
}
+ public PlayerArmor(final Map armorItems) {
+ this.armorItems = armorItems;
+ }
+
public static PlayerArmor empty() {
return new PlayerArmor(
ArmorItem.empty(ArmorItem.Type.HAT),
@@ -27,10 +29,6 @@ public class PlayerArmor {
);
}
- public PlayerArmor(final Map armorItems) {
- this.armorItems = armorItems;
- }
-
public ArmorItem getHat() {
return this.getItem(ArmorItem.Type.HAT);
}
@@ -63,4 +61,5 @@ public class PlayerArmor {
public PlayerArmor copy() {
return new PlayerArmor(new HashMap<>(this.armorItems));
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/listener/ClickListener.java b/src/main/java/io/github/fisher2911/hmccosmetics/listener/ClickListener.java
index 49e55f66..684df993 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/listener/ClickListener.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/listener/ClickListener.java
@@ -3,6 +3,8 @@ package io.github.fisher2911.hmccosmetics.listener;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import io.github.fisher2911.hmccosmetics.user.User;
import io.github.fisher2911.hmccosmetics.user.UserManager;
+import java.util.List;
+import java.util.Optional;
import org.bukkit.Bukkit;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
@@ -12,9 +14,6 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
-import java.util.List;
-import java.util.Optional;
-
public class ClickListener implements Listener {
private final HMCCosmetics plugin;
@@ -30,14 +29,18 @@ public class ClickListener implements Listener {
@EventHandler
public void onCosmeticClick(final InventoryClickEvent event) {
final HumanEntity player = event.getWhoClicked();
- if (!(player instanceof Player)) return;
+ if (!(player instanceof Player)) {
+ return;
+ }
this.fixInventory((Player) player);
}
@EventHandler
public void onCosmeticClick(final InventoryDragEvent event) {
final HumanEntity player = event.getWhoClicked();
- if (!(player instanceof Player)) return;
+ if (!(player instanceof Player)) {
+ return;
+ }
this.fixInventory((Player) player);
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/listener/CosmeticFixListener.java b/src/main/java/io/github/fisher2911/hmccosmetics/listener/CosmeticFixListener.java
index dccc5ad0..f9ef259b 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/listener/CosmeticFixListener.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/listener/CosmeticFixListener.java
@@ -1,6 +1,5 @@
package io.github.fisher2911.hmccosmetics.listener;
-import com.comphenix.protocol.wrappers.EnumWrappers;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import io.github.fisher2911.hmccosmetics.user.UserManager;
import org.bukkit.Bukkit;
@@ -10,13 +9,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.PlayerInventory;
import org.spigotmc.event.entity.EntityMountEvent;
public class CosmeticFixListener implements Listener {
@@ -31,34 +27,47 @@ public class CosmeticFixListener implements Listener {
@EventHandler
public void onEntityMount(final EntityMountEvent event) {
- if (!(event.getEntity() instanceof final Player player)) return;
+ if (!(event.getEntity() instanceof final Player player)) {
+ return;
+ }
this.fixCosmetics(player);
}
@EventHandler
public void onOffhandSwap(final PlayerSwapHandItemsEvent event) {
final ItemStack offHand = event.getOffHandItem();
- if (offHand != null && offHand.getType() != Material.AIR) return;
+ if (offHand != null && offHand.getType() != Material.AIR) {
+ return;
+ }
this.fixCosmetics(event.getPlayer());
}
@EventHandler
public void onRightClick(final PlayerInteractEvent event) {
- if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getHand() != EquipmentSlot.OFF_HAND) return;
+ if (event.getAction() != Action.RIGHT_CLICK_BLOCK
+ && event.getHand() != EquipmentSlot.OFF_HAND) {
+ return;
+ }
final Player player = event.getPlayer();
final ItemStack mainHand = event.getPlayer().getInventory().getItemInMainHand();
- if (mainHand.getType().isBlock() && mainHand.getAmount() > 0) return;
+ if (mainHand.getType().isBlock() && mainHand.getAmount() > 0) {
+ return;
+ }
this.userManager.updateCosmetics(player.getUniqueId(), true);
}
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event) {
- if (event.getHand() != EquipmentSlot.OFF_HAND) return;
+ if (event.getHand() != EquipmentSlot.OFF_HAND) {
+ return;
+ }
final ItemStack itemStack = event.getItemInHand();
- if (itemStack.getAmount() > 1) return;
+ if (itemStack.getAmount() > 1) {
+ return;
+ }
this.fixCosmetics(event.getPlayer());
}
@@ -67,4 +76,5 @@ public class CosmeticFixListener implements Listener {
Bukkit.getScheduler().runTaskLaterAsynchronously(this.plugin,
() -> this.userManager.updateCosmetics(player.getUniqueId(), true), 2);
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/listener/JoinListener.java b/src/main/java/io/github/fisher2911/hmccosmetics/listener/JoinListener.java
index 93f0105c..e9136e21 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/listener/JoinListener.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/listener/JoinListener.java
@@ -27,7 +27,7 @@ public class JoinListener implements Listener {
final Player player = event.getPlayer();
this.database.loadUser(player.getUniqueId(),
user -> Bukkit.getScheduler().runTaskAsynchronously(this.plugin,
- () -> this.userManager.resendCosmetics(player)));
+ () -> this.userManager.resendCosmetics(player)));
}
@EventHandler
@@ -35,4 +35,5 @@ public class JoinListener implements Listener {
final Player player = event.getPlayer();
this.userManager.remove(player.getUniqueId());
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/listener/RespawnListener.java b/src/main/java/io/github/fisher2911/hmccosmetics/listener/RespawnListener.java
index 4e122aa2..b9018030 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/listener/RespawnListener.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/listener/RespawnListener.java
@@ -3,14 +3,13 @@ package io.github.fisher2911.hmccosmetics.listener;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import io.github.fisher2911.hmccosmetics.user.User;
import io.github.fisher2911.hmccosmetics.user.UserManager;
+import java.util.Optional;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;
-import java.util.Optional;
-
public class RespawnListener implements Listener {
private final HMCCosmetics plugin;
@@ -33,4 +32,5 @@ public class RespawnListener implements Listener {
});
}, 1);
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/message/Message.java b/src/main/java/io/github/fisher2911/hmccosmetics/message/Message.java
index 6b4efc55..d5f149b8 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/message/Message.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/message/Message.java
@@ -34,8 +34,12 @@ public class Message {
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
final Message message = (Message) o;
return Objects.equals(key, message.key);
}
@@ -54,4 +58,5 @@ public class Message {
TITLE
}
+
}
\ No newline at end of file
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/message/MessageHandler.java b/src/main/java/io/github/fisher2911/hmccosmetics/message/MessageHandler.java
index cc2ec890..dd9b1655 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/message/MessageHandler.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/message/MessageHandler.java
@@ -1,21 +1,21 @@
package io.github.fisher2911.hmccosmetics.message;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
-import io.github.fisher2911.hmccosmetics.util.StringUtils;
import io.github.fisher2911.hmccosmetics.util.Utils;
-import net.kyori.adventure.platform.bukkit.BukkitAudiences;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.title.Title;
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
+import net.kyori.adventure.platform.bukkit.BukkitAudiences;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
+import net.kyori.adventure.title.Title;
+import net.md_5.bungee.api.ChatMessageType;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
public class MessageHandler {
@@ -40,23 +40,24 @@ public class MessageHandler {
}
/**
- * @param sender receiver of message
- * @param key message key
+ * @param sender receiver of message
+ * @param key message key
* @param placeholders placeholders
*/
- public void sendMessage(final CommandSender sender, final Message key, final Map placeholders) {
+ public void sendMessage(final CommandSender sender, final Message key,
+ final Map placeholders) {
final String message = this.getPapiPlaceholders(
sender,
Placeholder.applyPlaceholders(this.getMessage(key), placeholders)
);
- final Component component = Adventure.MINI_MESSAGE.parse(message);
- this.adventure.sender(sender).sendMessage(component);
+ final Component component = Adventure.MINI_MESSAGE.deserialize(message);
+ sender.spigot().sendMessage(BungeeComponentSerializer.get().serialize(component));
}
/**
* @param sender receiver of message
- * @param key message key
+ * @param key message key
*/
public void sendMessage(final CommandSender sender, final Message key) {
@@ -64,23 +65,24 @@ public class MessageHandler {
}
/**
- * @param player receiver of message
- * @param key message key
+ * @param player receiver of message
+ * @param key message key
* @param placeholders placeholders
*/
- public void sendActionBar(final Player player, final Message key, final Map placeholders) {
+ public void sendActionBar(final Player player, final Message key,
+ final Map placeholders) {
final String message = this.getPapiPlaceholders(
player,
Placeholder.applyPlaceholders(this.getMessage(key), placeholders)
);
- Component component = Adventure.MINI_MESSAGE.parse(message);
- this.adventure.player(player).sendActionBar(component);
+ Component component = Adventure.MINI_MESSAGE.deserialize(message);
+ player.spigot().sendMessage(ChatMessageType.ACTION_BAR, BungeeComponentSerializer.get().serialize(component));
}
/**
* @param player receiver of message
- * @param key message key
+ * @param key message key
*/
public void sendActionBar(final Player player, final Message key) {
@@ -88,23 +90,24 @@ public class MessageHandler {
}
/**
- * @param player receiver of message
- * @param key message key
+ * @param player receiver of message
+ * @param key message key
* @param placeholders placeholders
*/
- public void sendTitle(final Player player, final Message key, final Map placeholders) {
+ public void sendTitle(final Player player, final Message key,
+ final Map placeholders) {
final String message = this.getPapiPlaceholders(
player,
Placeholder.applyPlaceholders(this.getMessage(key), placeholders)
);
- Component component = Adventure.MINI_MESSAGE.parse(message);
+ Component component = Adventure.MINI_MESSAGE.deserialize(message);
this.adventure.player(player).showTitle(Title.title(component, Component.empty()));
}
/**
* @param player receiver of message
- * @param key message key
+ * @param key message key
*/
public void sendTitle(final Player player, final Message key) {
@@ -144,12 +147,14 @@ public class MessageHandler {
for (final String key : config.getKeys(false)) {
final String message = Utils.replaceIfNull(config.getString(key), "", value -> {
if (value == null) {
- this.logger.warning(String.format(ErrorMessages.ITEM_NOT_FOUND, "message", fileName));
+ this.logger.warning(
+ String.format(ErrorMessages.ITEM_NOT_FOUND, "message", fileName));
}
}).replace(Placeholder.PREFIX, prefix);
final Message.Type messageType = Utils.stringToEnum(
- Utils.replaceIfNull(config.getString("type"), ""), Message.Type.class, Message.Type.MESSAGE
+ Utils.replaceIfNull(config.getString("type"), ""), Message.Type.class,
+ Message.Type.MESSAGE
);
this.messageMap.put(key, new Message(key, message, messageType));
@@ -157,10 +162,10 @@ public class MessageHandler {
}
private String getPapiPlaceholders(final CommandSender sender, final String message) {
- if (sender instanceof final Player player) {
- return Placeholder.applyPapiPlaceholders(player, message);
- }
- return Placeholder.applyPapiPlaceholders(null, message);
+ if (sender instanceof final Player player) {
+ return Placeholder.applyPapiPlaceholders(player, message);
}
+ return Placeholder.applyPapiPlaceholders(null, message);
+ }
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/message/Messages.java b/src/main/java/io/github/fisher2911/hmccosmetics/message/Messages.java
index 2ecd335a..a5a67c60 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/message/Messages.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/message/Messages.java
@@ -34,17 +34,19 @@ public class Messages {
public static final Message ITEM_NOT_FOUND =
new Message("item-not-found", ChatColor.RED + "That item could not be found!");
public static final Message HELP_COMMAND =
- new Message("help-command", "<#6D9DC5> HMCCosmetics - Help<#6D9DC5> \n" +
- "\n" +
- "\n" +
- "<#5AE4B5>• <#40B7D6>/cosmetics - <#6D9DC5>Opens cosmetics GUI.\n" +
- "\n" +
- "<#5AE4B5>• <#40B7D6>/cosmetics dye - <#6D9DC5>Opens dye menu for specified cosmetic.\n" +
- "\n" +
- "<#5AE4B5>• <#40B7D6>/cosmetics help - <#6D9DC5>Opens this menu.\n" +
- "\n" +
- "\n" +
- " ");
+ new Message("help-command",
+ """
+ <#6D9DC5> HMCCosmetics - Help<#6D9DC5>
+
+
+ <#5AE4B5>• <#40B7D6>/cosmetics - <#6D9DC5>Opens cosmetics GUI.
+
+ <#5AE4B5>• <#40B7D6>/cosmetics dye - <#6D9DC5>Opens dye menu for specified cosmetic.
+
+ <#5AE4B5>• <#40B7D6>/cosmetics help - <#6D9DC5>Opens this menu.
+
+
+ """);
public static final Message SET_OTHER_BACKPACK = new Message(
"set-other-backpack", ChatColor.GREEN + "You have set the backpack of " +
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/message/Placeholder.java b/src/main/java/io/github/fisher2911/hmccosmetics/message/Placeholder.java
index d331ab81..4497bd24 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/message/Placeholder.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/message/Placeholder.java
@@ -2,11 +2,10 @@ package io.github.fisher2911.hmccosmetics.message;
import io.github.fisher2911.hmccosmetics.hook.HookManager;
import io.github.fisher2911.hmccosmetics.hook.PAPIHook;
+import java.util.Map;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
-import java.util.Map;
-
public class Placeholder {
public static final String PREFIX = "%prefix%";
@@ -19,7 +18,7 @@ public class Placeholder {
public static final String ALLOWED = "%allowed%";
/**
- * @param message message being translated
+ * @param message message being translated
* @param placeholders placeholders applied
* @return message with placeholders applied
*/
@@ -31,11 +30,13 @@ public class Placeholder {
return message;
}
- public static String applyPapiPlaceholders(@Nullable final Player player, final String message) {
+ public static String applyPapiPlaceholders(@Nullable final Player player,
+ final String message) {
if (HookManager.getInstance().isEnabled(PAPIHook.class)) {
return HookManager.getInstance().getPapiHook().parse(player, message);
}
return message;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/message/Translation.java b/src/main/java/io/github/fisher2911/hmccosmetics/message/Translation.java
index 53d2e25f..8f833c1f 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/message/Translation.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/message/Translation.java
@@ -1,26 +1,23 @@
package io.github.fisher2911.hmccosmetics.message;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
public class Translation {
private static final Translation INSTANCE;
+ private static final String FILE_NAME = "translations.yml";
+ private static final String TRANSLATION_PATH = "translations";
static {
INSTANCE = new Translation(HMCCosmetics.getPlugin(HMCCosmetics.class));
}
- public static Translation getInstance() {
- return INSTANCE;
- }
-
private final HMCCosmetics plugin;
private final Map translations;
@@ -29,8 +26,13 @@ public class Translation {
this.plugin = plugin;
}
- private static final String FILE_NAME = "translations.yml";
- private static final String TRANSLATION_PATH = "translations";
+ public static Translation getInstance() {
+ return INSTANCE;
+ }
+
+ public static String translate(final String key) {
+ return INSTANCE.translations.getOrDefault(key, key);
+ }
public void load() {
final File file = new File(this.plugin.getDataFolder(), FILE_NAME);
@@ -42,15 +44,13 @@ public class Translation {
final ConfigurationSection section = config.getConfigurationSection(TRANSLATION_PATH);
- if (section == null) return;
+ if (section == null) {
+ return;
+ }
for (final String key : section.getKeys(false)) {
this.translations.put(key, section.getString(key));
}
}
- public static String translate(final String key) {
- return INSTANCE.translations.getOrDefault(key, key);
- }
-
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java b/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java
index 66dc4ba3..2446efe0 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java
@@ -6,7 +6,9 @@ import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.Pair;
-
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntArrayList;
@@ -14,13 +16,10 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.UUID;
-
public class PacketManager {
- public static PacketContainer getEntitySpawnPacket(final Location location, final int entityId, final EntityType entityType) {
+ public static PacketContainer getEntitySpawnPacket(final Location location, final int entityId,
+ final EntityType entityType) {
final PacketContainer packet = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
// Entity ID
@@ -45,9 +44,10 @@ public class PacketManager {
public static PacketContainer getEquipmentPacket(
final List> equipmentList,
final int entityId
- ) {
+ ) {
- final PacketContainer armorPacket = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
+ final PacketContainer armorPacket = new PacketContainer(
+ PacketType.Play.Server.ENTITY_EQUIPMENT);
armorPacket.getIntegers().write(0, entityId);
armorPacket.getSlotStackPairLists().write(0, equipmentList);
@@ -55,7 +55,8 @@ public class PacketManager {
}
public static PacketContainer getRotationPacket(final int entityId, final Location location) {
- final PacketContainer rotationPacket = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
+ final PacketContainer rotationPacket = new PacketContainer(
+ PacketType.Play.Server.ENTITY_HEAD_ROTATION);
rotationPacket.getIntegers().write(0, entityId);
rotationPacket.getBytes().write(0, (byte) (location.getYaw() * 256 / 360));
@@ -74,7 +75,8 @@ public class PacketManager {
}
public static PacketContainer getEntityDestroyPacket(final int entityId) {
- final PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
+ final PacketContainer destroyPacket = new PacketContainer(
+ PacketType.Play.Server.ENTITY_DESTROY);
destroyPacket.getModifier().write(0, new IntArrayList(new int[]{entityId}));
return destroyPacket;
@@ -96,4 +98,5 @@ public class PacketManager {
sendPacket(player, packets);
}
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java b/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java
index ec1f8f4a..52bb6fbc 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java
@@ -6,10 +6,12 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.Pair;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
-import io.github.fisher2911.hmccosmetics.HMCCosmetics;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.inventory.PlayerArmor;
import io.github.fisher2911.hmccosmetics.packet.PacketManager;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
@@ -17,19 +19,13 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
public class User {
private final UUID uuid;
private final PlayerArmor playerArmor;
-
- private ArmorItem lastSetItem = ArmorItem.empty(ArmorItem.Type.HAT);
-
- private boolean hasArmorStand;
private final int armorStandId;
+ private ArmorItem lastSetItem = ArmorItem.empty(ArmorItem.Type.HAT);
+ private boolean hasArmorStand;
public User(final UUID uuid, final PlayerArmor playerArmor, final int armorStandId) {
this.uuid = uuid;
@@ -77,11 +73,15 @@ public class User {
public void spawnArmorStand(final Player other) {
final Player player = this.getPlayer();
- if (player == null) return;
+ if (player == null) {
+ return;
+ }
final Location location = player.getLocation();
- final PacketContainer packet = PacketManager.getEntitySpawnPacket(location, this.armorStandId, EntityType.ARMOR_STAND);
+ final PacketContainer packet = PacketManager.getEntitySpawnPacket(location,
+ this.armorStandId,
+ EntityType.ARMOR_STAND);
PacketManager.sendPacket(other, packet);
}
@@ -107,7 +107,9 @@ public class User {
final Player player = this.getPlayer();
- if (player == null) return;
+ if (player == null) {
+ return;
+ }
final List> equipmentList = new ArrayList<>();
equipmentList.add(new Pair<>(EnumWrappers.ItemSlot.HEAD,
@@ -116,18 +118,24 @@ public class User {
final Location location = player.getLocation();
- final PacketContainer armorPacket = PacketManager.getEquipmentPacket(equipmentList, this.armorStandId);
- final PacketContainer rotationPacket = PacketManager.getRotationPacket(this.armorStandId, location);
- final PacketContainer ridingPacket = PacketManager.getRidingPacket(player.getEntityId(), this.armorStandId);
+ final PacketContainer armorPacket = PacketManager.getEquipmentPacket(equipmentList,
+ this.armorStandId);
+ final PacketContainer rotationPacket = PacketManager.getRotationPacket(this.armorStandId,
+ location);
+ final PacketContainer ridingPacket = PacketManager.getRidingPacket(player.getEntityId(),
+ this.armorStandId);
- final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
+ final PacketContainer metaContainer = new PacketContainer(
+ PacketType.Play.Server.ENTITY_METADATA);
WrappedDataWatcher metaData = new WrappedDataWatcher();
final Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class);
- metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, byteSerializer), (byte) (0x20));
- metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, byteSerializer), (byte) (0x10));
+ metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, byteSerializer),
+ (byte) (0x20));
+ metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, byteSerializer),
+ (byte) (0x10));
metaContainer.getIntegers().write(0, this.armorStandId);
metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects());
@@ -147,4 +155,5 @@ public class User {
public ArmorItem getLastSetItem() {
return lastSetItem;
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/user/UserManager.java b/src/main/java/io/github/fisher2911/hmccosmetics/user/UserManager.java
index dc3c4cbb..7056f630 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/user/UserManager.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/user/UserManager.java
@@ -16,14 +16,6 @@ import io.github.fisher2911.hmccosmetics.message.MessageHandler;
import io.github.fisher2911.hmccosmetics.message.Placeholder;
import io.github.fisher2911.hmccosmetics.packet.PacketManager;
import io.github.fisher2911.hmccosmetics.util.builder.ItemBuilder;
-import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.EntityEquipment;
-import org.bukkit.inventory.EquipmentSlot;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitTask;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -31,6 +23,13 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.EntityEquipment;
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.scheduler.BukkitTask;
public class UserManager {
@@ -66,7 +65,9 @@ public class UserManager {
public void remove(final UUID uuid) {
final User user = this.userMap.remove(uuid);
- if (user == null) return;
+ if (user == null) {
+ return;
+ }
this.armorStandIdMap.remove(user.getArmorStandId());
@@ -105,7 +106,6 @@ public class UserManager {
public void updateCosmetics(final UUID uuid, final boolean ignoreRestrictions) {
this.get(uuid).ifPresent(user -> this.updateCosmetics(user, ignoreRestrictions));
-
}
public void updateCosmetics(final UUID uuid) {
@@ -122,7 +122,8 @@ public class UserManager {
}
}
- public void updateCosmetics(final User user, final boolean ignoreRestrictions, final Player other) {
+ public void updateCosmetics(final User user, final boolean ignoreRestrictions,
+ final Player other) {
final Player player = user.getPlayer();
if (player == null) {
@@ -134,10 +135,15 @@ public class UserManager {
final List> equipmentList = new ArrayList<>();
equipmentList.add(
- new Pair<>(EnumWrappers.ItemSlot.HEAD, this.getCosmeticItem(player, playerArmor.getHat(), EquipmentSlot.HEAD, ignoreRestrictions))
+ new Pair<>(EnumWrappers.ItemSlot.HEAD,
+ this.getCosmeticItem(player, playerArmor.getHat(), EquipmentSlot.HEAD,
+ ignoreRestrictions))
);
equipmentList.add(
- new Pair<>(EnumWrappers.ItemSlot.OFFHAND, this.getCosmeticItem(player, playerArmor.getOffHand(), EquipmentSlot.OFF_HAND, ignoreRestrictions))
+ new Pair<>(EnumWrappers.ItemSlot.OFFHAND,
+ this.getCosmeticItem(player, playerArmor.getOffHand(),
+ EquipmentSlot.OFF_HAND,
+ ignoreRestrictions))
);
PacketManager.sendPacket(
@@ -168,14 +174,19 @@ public class UserManager {
final boolean isAir = itemStack.getType().isAir();
final boolean requireEmpty = cosmeticSettings.requireEmpty(slot);
- if (!isAir && (!requireEmpty || ignoreRestrictions)) return itemStack;
+ if (!isAir && (!requireEmpty || ignoreRestrictions)) {
+ return itemStack;
+ }
-
- if (equipment == null) return itemStack;
+ if (equipment == null) {
+ return itemStack;
+ }
final ItemStack equipped = equipment.getItem(slot);
- if (equipped != null && equipped.getType() != Material.AIR) return equipped;
+ if (equipped != null && equipped.getType() != Material.AIR) {
+ return equipped;
+ }
return itemStack;
}
@@ -184,9 +195,12 @@ public class UserManager {
ArmorItem previous = user.getPlayerArmor().getItem(armorItem.getType());
final CosmeticChangeEvent event =
- new CosmeticChangeEvent(new CosmeticItem(armorItem.copy()), new CosmeticItem(previous.copy()), user);
+ new CosmeticChangeEvent(new CosmeticItem(armorItem.copy()),
+ new CosmeticItem(previous.copy()), user);
Bukkit.getPluginManager().callEvent(event);
- if (event.isCancelled()) return;
+ if (event.isCancelled()) {
+ return;
+ }
user.setItem(event.getCosmeticItem().getArmorItem());
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
@@ -254,4 +268,5 @@ public class UserManager {
public void cancelTeleportTask() {
this.teleportTask.cancel();
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/util/Keys.java b/src/main/java/io/github/fisher2911/hmccosmetics/util/Keys.java
index 89de2b91..401e2dba 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/util/Keys.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/util/Keys.java
@@ -8,12 +8,7 @@ import org.bukkit.persistence.PersistentDataType;
public class Keys {
- static HMCCosmetics plugin;
-
- static {
- plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
- }
-
+ static HMCCosmetics plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
public static final NamespacedKey ITEM_KEY = new NamespacedKey(plugin, "cosmetic");
public static final NamespacedKey ARMOR_STAND_KEY = new NamespacedKey(plugin, "armor-stand");
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/util/StringUtils.java b/src/main/java/io/github/fisher2911/hmccosmetics/util/StringUtils.java
index 4e33ea34..c2e52785 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/util/StringUtils.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/util/StringUtils.java
@@ -1,15 +1,8 @@
package io.github.fisher2911.hmccosmetics.util;
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
-import io.github.fisher2911.hmccosmetics.hook.HookManager;
import io.github.fisher2911.hmccosmetics.message.Adventure;
-import io.github.fisher2911.hmccosmetics.hook.PAPIHook;
import net.kyori.adventure.text.Component;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Locale;
-import java.util.Map;
public class StringUtils {
@@ -25,11 +18,11 @@ public class StringUtils {
*/
public static Component parse(final String parsed) {
- return Adventure.MINI_MESSAGE.parse(parsed);
+ return Adventure.MINI_MESSAGE.deserialize(parsed);
}
public static String parseStringToString(final String parsed) {
- return Adventure.SERIALIZER.serialize(Adventure.MINI_MESSAGE.parse(parsed));
+ return Adventure.SERIALIZER.serialize(Adventure.MINI_MESSAGE.deserialize(parsed));
}
public static String formatArmorItemType(String type) {
@@ -44,4 +37,5 @@ public class StringUtils {
return firstPart + parts[1].substring(0, 1).toUpperCase() + parts[1].substring(1);
}
+
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/util/Utils.java b/src/main/java/io/github/fisher2911/hmccosmetics/util/Utils.java
index 2aa29606..69c403cc 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/util/Utils.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/util/Utils.java
@@ -1,33 +1,33 @@
package io.github.fisher2911.hmccosmetics.util;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class Utils {
/**
- * @param original Object to be checked if null
+ * @param original Object to be checked if null
* @param replacement Object returned if original is null
* @return original if not null, otherwise replacement
*/
public static T replaceIfNull(final @Nullable T original, final @NotNull T replacement) {
- return replaceIfNull(original, replacement, t -> {});
+ return replaceIfNull(original, replacement, t -> {
+ });
}
/**
- *
- * @param original Object to be checked if null
+ * @param original Object to be checked if null
* @param replacement Object returned if original is null
* @param consumer accepts the original object, can be used for logging
* @return original if not null, otherwise replacement
*/
- public static T replaceIfNull(final @Nullable T original, final T replacement, final @NotNull Consumer consumer) {
+ public static T replaceIfNull(final @Nullable T original, final T replacement,
+ final @NotNull Consumer consumer) {
if (original == null) {
consumer.accept(replacement);
return replacement;
@@ -37,7 +37,6 @@ public class Utils {
}
/**
- *
* @param t object being checked
* @param consumer accepted if t is not null
* @param type
@@ -51,14 +50,14 @@ public class Utils {
}
/**
- *
* @param t object being checked
* @param function applied if t is not null
* @param type
* @return
*/
- public static Optional returnIfNotNull(final @Nullable T t, final @NotNull Function function) {
+ public static Optional returnIfNotNull(final @Nullable T t,
+ final @NotNull Function function) {
if (t == null) {
return Optional.empty();
}
@@ -66,7 +65,6 @@ public class Utils {
}
/**
- *
* @param enumAsString Enum value as a string to be parsed
* @param enumClass enum type enumAsString is to be converted to
* @param defaultEnum default value to be returned
@@ -74,13 +72,13 @@ public class Utils {
*/
public static > E stringToEnum(final @NotNull String enumAsString,
- final @NotNull Class enumClass,
- E defaultEnum) {
- return stringToEnum(enumAsString, enumClass, defaultEnum, e -> {});
+ final @NotNull Class enumClass,
+ E defaultEnum) {
+ return stringToEnum(enumAsString, enumClass, defaultEnum, e -> {
+ });
}
/**
- *
* @param enumAsString Enum value as a string to be parsed
* @param enumClass enum type enumAsString is to be converted to
* @param defaultEnum default value to be returned
@@ -89,9 +87,9 @@ public class Utils {
*/
public static > E stringToEnum(final @NotNull String enumAsString,
- @NotNull final Class enumClass,
- final E defaultEnum,
- final @NotNull Consumer consumer) {
+ @NotNull final Class enumClass,
+ final E defaultEnum,
+ final @NotNull Consumer consumer) {
try {
final E value = Enum.valueOf(enumClass, enumAsString);
consumer.accept(value);
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ColorBuilder.java b/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ColorBuilder.java
index 2d0a54c0..9285be0b 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ColorBuilder.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ColorBuilder.java
@@ -7,13 +7,9 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.PotionMeta;
-import java.util.EnumSet;
-import java.util.Set;
-
-public class ColorBuilder extends ItemBuilder{
+public class ColorBuilder extends ItemBuilder {
/**
- *
* @param material ItemStack material
*/
@@ -22,7 +18,6 @@ public class ColorBuilder extends ItemBuilder{
}
/**
- *
* @param itemStack ItemStack
*/
@@ -31,7 +26,6 @@ public class ColorBuilder extends ItemBuilder{
}
/**
- *
* @param material ItemStack material
* @return this
* @throws IllegalArgumentException thrown if itemStack's type can not change color
@@ -45,7 +39,6 @@ public class ColorBuilder extends ItemBuilder{
}
/**
- *
* @param itemStack ItemStack
* @return this
* @throws IllegalArgumentException thrown if itemStack's type can not change color
@@ -59,8 +52,18 @@ public class ColorBuilder extends ItemBuilder{
return new ColorBuilder(itemStack);
}
+ public static boolean canBeColored(final Material material) {
+ return canBeColored(new ItemStack(material));
+ }
+
+ public static boolean canBeColored(final ItemStack itemStack) {
+ final ItemMeta itemMeta = itemStack.getItemMeta();
+
+ return (itemMeta instanceof LeatherArmorMeta ||
+ itemMeta instanceof PotionMeta);
+ }
+
/**
- *
* @param color armor color
* @return this
*/
@@ -75,14 +78,4 @@ public class ColorBuilder extends ItemBuilder{
return this;
}
- public static boolean canBeColored(final Material material) {
- return canBeColored(new ItemStack(material));
- }
-
- public static boolean canBeColored(final ItemStack itemStack) {
- final ItemMeta itemMeta = itemStack.getItemMeta();
-
- return (itemMeta instanceof LeatherArmorMeta ||
- itemMeta instanceof PotionMeta);
- }
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ItemBuilder.java b/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ItemBuilder.java
index b28e378f..32a013dd 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ItemBuilder.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/ItemBuilder.java
@@ -1,7 +1,10 @@
package io.github.fisher2911.hmccosmetics.util.builder;
import io.github.fisher2911.hmccosmetics.message.Placeholder;
-import net.kyori.adventure.text.Component;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@@ -10,11 +13,6 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
public class ItemBuilder {
protected Material material;
@@ -36,7 +34,8 @@ public class ItemBuilder {
ItemBuilder(final ItemStack itemStack) {
this.material = itemStack.getType();
- this.itemMeta = itemStack.hasItemMeta() ? itemStack.getItemMeta() : Bukkit.getItemFactory().getItemMeta(this.material);
+ this.itemMeta = itemStack.hasItemMeta() ? itemStack.getItemMeta()
+ : Bukkit.getItemFactory().getItemMeta(this.material);
}
/**
@@ -146,12 +145,16 @@ public class ItemBuilder {
}
private void lorePapiPlaceholders(final Player player) {
- if (this.itemMeta == null) return;
+ if (this.itemMeta == null) {
+ return;
+ }
final List newLore = new ArrayList<>();
final List lore = this.itemMeta.getLore();
- if (lore == null) return;
+ if (lore == null) {
+ return;
+ }
for (final String line : this.itemMeta.getLore()) {
newLore.add(Placeholder.applyPapiPlaceholders(player, line));
@@ -161,7 +164,9 @@ public class ItemBuilder {
}
private void namePapiPlaceholders(final Player player) {
- if (this.itemMeta == null) return;
+ if (this.itemMeta == null) {
+ return;
+ }
this.itemMeta.setDisplayName(
Placeholder.applyPapiPlaceholders(
@@ -196,16 +201,18 @@ public class ItemBuilder {
}
/**
- * @param enchantments enchants to be added to the ItemStack
+ * @param enchantments enchants to be added to the ItemStack
* @param ignoreLeveLRestrictions whether to ignore enchantment level restrictions
* @return this
*/
- public ItemBuilder enchants(final Map enchantments, boolean ignoreLeveLRestrictions) {
+ public ItemBuilder enchants(final Map enchantments,
+ boolean ignoreLeveLRestrictions) {
if (this.itemMeta == null) {
return this;
}
- enchantments.forEach((enchantment, level) -> this.itemMeta.addEnchant(enchantment, level, ignoreLeveLRestrictions));
+ enchantments.forEach((enchantment, level) -> this.itemMeta.addEnchant(enchantment, level,
+ ignoreLeveLRestrictions));
return this;
}
diff --git a/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/SkullBuilder.java b/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/SkullBuilder.java
index 1745e346..131d884e 100644
--- a/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/SkullBuilder.java
+++ b/src/main/java/io/github/fisher2911/hmccosmetics/util/builder/SkullBuilder.java
@@ -2,15 +2,14 @@ package io.github.fisher2911.hmccosmetics.util.builder;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
+import java.lang.reflect.Field;
+import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
-import java.lang.reflect.Field;
-import java.util.UUID;
-
/**
* Some parts taken from https://github.com/TriumphTeam/triumph-gui/blob/master/core/src/main/java/dev/triumphteam/gui/builder/item/SkullBuilder.java
*/
@@ -23,7 +22,8 @@ public class SkullBuilder extends ItemBuilder {
Field field;
try {
- final SkullMeta skullMeta = (SkullMeta) new ItemStack(Material.PLAYER_HEAD).getItemMeta();
+ final SkullMeta skullMeta = (SkullMeta) new ItemStack(
+ Material.PLAYER_HEAD).getItemMeta();
field = skullMeta.getClass().getDeclaredField("profile");
field.setAccessible(true);
} catch (NoSuchFieldException e) {
@@ -36,7 +36,6 @@ public class SkullBuilder extends ItemBuilder {
/**
- *
* @param material The material
*/
@@ -46,6 +45,7 @@ public class SkullBuilder extends ItemBuilder {
/**
* Creates a new SkullBuilder instance
+ *
* @return this
*/
@@ -55,7 +55,6 @@ public class SkullBuilder extends ItemBuilder {
/**
- *
* @param player skull owner
* @return this
*/
@@ -68,7 +67,6 @@ public class SkullBuilder extends ItemBuilder {
}
/**
- *
* @param texture skull texture
* @return this
*/
diff --git a/src/main/resources/database.yml b/src/main/resources/database.yml
index 140ea512..363d95aa 100644
--- a/src/main/resources/database.yml
+++ b/src/main/resources/database.yml
@@ -1,4 +1,4 @@
- # SQLite or MySQL (case-insensitive)
+# SQLite or MySQL (case-insensitive)
type: "sqlite"
# The rest of these are only required for MySQL
name: "name"
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
deleted file mode 100644
index 4eb1d7ea..00000000
--- a/src/main/resources/plugin.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-name: HMCCosmetics
-main: io.github.fisher2911.hmccosmetics.HMCCosmetics
-version: 1.6.1
-api-version: 1.17
-softdepend:
- - Multiverse
- - PlaceholderAPI
- - Oraxen
- - ItemsAdder
-depend:
- - ProtocolLib
-permissions:
- hmccosmetics.cmd.default:
- default: op
- description: Permission to execute the default command
- hmccosmetics.cmd.dye:
- default: op
- description: Permission to dye armor
- hmccosmetics.cmd.reload:
- default: op
- description: Permission to use the reload command
- hmccosmetics.cmd.set:
- default: op
- description: Permission to set other users' cosmetics
\ No newline at end of file