From 5c426cb613ad3a0a9b7d6a55c70c98a16dec07d6 Mon Sep 17 00:00:00 2001 From: Ztrolix Date: Wed, 16 Oct 2024 16:49:32 +1100 Subject: [PATCH] Cleaned Code --- src/main/java/dev/xdpxi/xdlib/api/convert.java | 12 ++++++++++++ src/main/java/dev/xdpxi/xdlib/api/custom.java | 16 +++++++++++++--- src/main/java/dev/xdpxi/xdlib/plugin/xdlib.java | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/xdpxi/xdlib/api/convert.java b/src/main/java/dev/xdpxi/xdlib/api/convert.java index dcc3a89..f56de90 100644 --- a/src/main/java/dev/xdpxi/xdlib/api/convert.java +++ b/src/main/java/dev/xdpxi/xdlib/api/convert.java @@ -4,12 +4,15 @@ public class convert { public static String toString(String convert) { return convert; } + public static String toString(int convert) { return String.valueOf(convert); } + public static String toString(boolean convert) { return String.valueOf(convert); } + public static String toString(float convert) { return String.valueOf(convert); } @@ -17,12 +20,15 @@ public static String toString(float convert) { public static int toInt(String convert) { return Integer.parseInt(convert); } + public static int toInt(int convert) { return convert; } + public static int toInt(boolean convert) { return convert ? 1 : 0; } + public static int toInt(float convert) { return (int) convert; } @@ -30,12 +36,15 @@ public static int toInt(float convert) { public static boolean toBoolean(String convert) { return Boolean.parseBoolean(convert); } + public static boolean toBoolean(int convert) { return convert != 0; } + public static boolean toBoolean(boolean convert) { return convert; } + public static boolean toBoolean(float convert) { return convert != 0.0f; } @@ -43,12 +52,15 @@ public static boolean toBoolean(float convert) { public static float toFloat(String convert) { return Float.parseFloat(convert); } + public static float toFloat(int convert) { return (float) convert; } + public static float toFloat(boolean convert) { return convert ? 1.0f : 0.0f; } + public static float toFloat(float convert) { return convert; } diff --git a/src/main/java/dev/xdpxi/xdlib/api/custom.java b/src/main/java/dev/xdpxi/xdlib/api/custom.java index f875c69..b758135 100644 --- a/src/main/java/dev/xdpxi/xdlib/api/custom.java +++ b/src/main/java/dev/xdpxi/xdlib/api/custom.java @@ -33,7 +33,10 @@ public static void ItemGroup(String itemGroupID, String modID, Item itemIconID, } }); } - public static void AddToItemGroup(String itemGroupID, String modID, List itemsToAdd) { ItemGroup(itemGroupID, modID, null, itemsToAdd); } + + public static void AddToItemGroup(String itemGroupID, String modID, List itemsToAdd) { + ItemGroup(itemGroupID, modID, null, itemsToAdd); + } public static Item Item(String itemID, String modID, RegistryKey itemGroup) { itemID = itemID.toLowerCase(); @@ -46,6 +49,7 @@ public static Item Item(String itemID, String modID, RegistryKey item } return item; } + public static Item Item(String itemID, String modID) { return Item(itemID, modID, null); } @@ -63,6 +67,7 @@ public static BlockItem Block(String blockID, String modID, RegistryKey armorType, ArmorItem.Type armorPart, RegistryKey itemGroup) { armorID = armorID.toLowerCase(); @@ -92,5 +99,8 @@ public static Item Armor(String armorID, String modID, RegistryEntry armorType, ArmorItem.Type armorPart) { return Armor(armorID, modID, armorType, armorPart, null); } + + public static Item Armor(String armorID, String modID, RegistryEntry armorType, ArmorItem.Type armorPart) { + return Armor(armorID, modID, armorType, armorPart, null); + } } \ No newline at end of file diff --git a/src/main/java/dev/xdpxi/xdlib/plugin/xdlib.java b/src/main/java/dev/xdpxi/xdlib/plugin/xdlib.java index a21fc65..f21a41b 100644 --- a/src/main/java/dev/xdpxi/xdlib/plugin/xdlib.java +++ b/src/main/java/dev/xdpxi/xdlib/plugin/xdlib.java @@ -10,10 +10,10 @@ import java.util.UUID; public final class xdlib extends JavaPlugin implements CommandExecutor { + private final HashMap teleportRequests = new HashMap<>(); private welcomeListener WelcomeListener; private chatListener ChatListener; private joinLeaveListener JoinLeaveListener; - private final HashMap teleportRequests = new HashMap<>(); @Override public void onEnable() {