Update dependencies
This commit is contained in:
1 parent
8a371dc975
commit
da44b634bf
5 files changed
+26
-101
No files matched your search
+1
-1
Submodule libs/GxUI-OG updated: 133d7e626d...b006ff1070.
+1
-1
Submodule libs/Utilities-OG updated: f7ac26069b...f973ab638b.
@@ -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<PostgreSQL.PlayerBalance> 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 <aqua>balance</aqua> 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());
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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]
|
||||
Reference in new issue
Block a user