From da44b634bf13aefb513be4bf68e1c92fb245cd78 Mon Sep 17 00:00:00 2001 From: NotAlexNoyle Date: Thu, 10 Oct 2024 11:43:55 +0000 Subject: [PATCH] Update dependencies --- libs/GxUI-OG | 2 +- libs/Utilities-OG | 2 +- src/main/java/plugin/Listeners.java | 31 +++++++--- src/main/java/plugin/Utils.java | 90 ----------------------------- src/main/resources/plugin.yml | 2 +- 5 files changed, 26 insertions(+), 101 deletions(-) delete mode 100644 src/main/java/plugin/Utils.java diff --git a/libs/GxUI-OG b/libs/GxUI-OG index 133d7e6..b006ff1 160000 --- a/libs/GxUI-OG +++ b/libs/GxUI-OG @@ -1 +1 @@ -Subproject commit 133d7e626dad10127c5dcdb2ca2bd168e5ef47e0 +Subproject commit b006ff1070ae5ba06d71e30a79c641707c9e5d98 diff --git a/libs/Utilities-OG b/libs/Utilities-OG index f7ac260..f973ab6 160000 --- a/libs/Utilities-OG +++ b/libs/Utilities-OG @@ -1 +1 @@ -Subproject commit f7ac26069b11c7b548a6aa79c73cd26206464ad4 +Subproject commit f973ab638b7815bdb609333348f0e3df36a1c203 diff --git a/src/main/java/plugin/Listeners.java b/src/main/java/plugin/Listeners.java index 7f7aed2..99b1266 100644 --- a/src/main/java/plugin/Listeners.java +++ b/src/main/java/plugin/Listeners.java @@ -1,23 +1,38 @@ -// This is free and unencumbered software released into the public domain. -// Author: NotAlexNoyle. package plugin; -// Import libraries. import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; -// Hook into Bukkit's Listener. +import net.trueog.utilitiesog.UtilitiesOG; + public class Listeners implements Listener { - // Perform this plugin's action before other plugins actions. @EventHandler(priority = EventPriority.HIGHEST) - // When a block is broken, do this... public void onBlockBreak(BlockBreakEvent event) { - // Open a spectator GUI for the player who broke the block. - new SpectatorGui(TemplateOG.getPlugin(), event.getPlayer()); + //CompletableFuture asyncPlayerBalance = DiamondBankOG.getApi().getPlayerBalance(event.getPlayer().getUniqueId(), PostgreSQL.BalanceType.ALL); + + //try { + + //PostgreSQL.PlayerBalance balanceResult = asyncPlayerBalance.get(); + + //double totalBalance = balanceResult.getBankBalance() + balanceResult.getEnderChestBalance() + balanceResult.getInventoryBalance(); + + // Send a message to the player with their balance. + + UtilitiesOG.trueogMessage(event.getPlayer(), "&BYour balance is: &e" + 5 + "&B Diamonds."); + + UtilitiesOG.logToConsole("[Template-OG]", "The player: " + event.getPlayer() + "'s balance is: " + 5 + "&B Diamonds"); + + + //} + //catch (InterruptedException | ExecutionException error) { + + // UtilitiesOG.logToConsole(TemplateOG.getPlugin(), "ERROR: The player: " + event.getPlayer() + "'s balance could not be fetched! ERROR: " + error.getMessage()); + + //} } diff --git a/src/main/java/plugin/Utils.java b/src/main/java/plugin/Utils.java deleted file mode 100644 index eef2d44..0000000 --- a/src/main/java/plugin/Utils.java +++ /dev/null @@ -1,90 +0,0 @@ -package plugin; - -import org.bukkit.entity.Player; - -import net.kyori.adventure.text.TextComponent; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; - -public class Utils { - - // Sends a formatted message to the player (including name replacement). - public static void templateOGPlaceholderMessage(Player p, String message) { - - p.sendMessage(legacySerializerAnyCase((message))); - - } - - public static TextComponent legacySerializerAnyCase(String subject) { - - int count = 0; - // Count the number of '&' characters to determine the size of the array - for (char c : subject.toCharArray()) { - - if (c == '&') { - - count++; - - } - - } - - // Create an array to store the positions of '&' characters - int[] positions = new int[count]; - int index = 0; - // Find the positions of '&' characters and store in the array - for (int i = 0; i < subject.length(); i++) { - - if (subject.charAt(i) == '&') { - - if (isUpperBukkitCode(subject.charAt(i + 1))) { - - subject = replaceCharAtIndex(subject, (i + 1), Character.toLowerCase(subject.charAt(i + 1))); - - } - - positions[index++] = i; - - } - - } - - return LegacyComponentSerializer.legacyAmpersand().deserialize(subject); - - } - - private static boolean isUpperBukkitCode(char input) { - - char[] bukkitColorCodes = {'A', 'B', 'C', 'D', 'E', 'F', 'K', 'L', 'M', 'N', 'O', 'R'}; - boolean match = false; - - // Loop through each character in the array. - for (char c : bukkitColorCodes) { - // Check if the current character in the array is equal to the input character. - if (c == input) { - - match = true; - - } - - } - - return match; - - } - - private static String replaceCharAtIndex(String original, int index, char newChar) { - - // Check if the index is valid - if (index >= 0 && index < original.length()) { - - // Create a new string with the replaced character - return original.substring(0, index) + newChar + original.substring(index + 1); - - } - - // If the index is invalid, return the original string - return original; - - } - -} \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index fe9ce00..a2f73a9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,4 +5,4 @@ website: https://github.com/true-og/Template-OG/ version: '${version}' api-version: '${apiVersion}' main: plugin.TemplateOG -depend: [DiamondBank-OG] +depend: [DiamondBank-OG, Utilities-OG]