diff --git a/pom.xml b/pom.xml index b49b893..0e4e97d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 ca.tweetzy auctionhouse - 2.53.0 + 2.53.1 UTF-8 diff --git a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java index 844fe6f..8d97ddc 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java @@ -36,6 +36,8 @@ import co.aikar.taskchain.TaskChain; import co.aikar.taskchain.TaskChainFactory; import lombok.Getter; import lombok.Setter; +import me.clip.placeholderapi.PlaceholderAPI; +import me.clip.placeholderapi.PlaceholderHook; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -236,7 +238,7 @@ public class AuctionHouse extends TweetyPlugin { ); // Placeholder API - if (Bukkit.getPluginManager().getPlugin("PlaceholderAPIHook") != null) { + if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { new PlaceholderAPIHook(this).register(); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPIHook.java b/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPIHook.java index 7c80921..dae5b19 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPIHook.java +++ b/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPIHook.java @@ -2,10 +2,17 @@ package ca.tweetzy.auctionhouse.api.hook; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; +import lombok.experimental.UtilityClass; +import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; +import java.util.List; +import java.util.stream.Collectors; + /** * The current file has been created by Kiran Hart * Date Created: August 07 2021 @@ -66,4 +73,17 @@ public class PlaceholderAPIHook extends PlaceholderExpansion { return null; } + + @UtilityClass + public static final class PAPIReplacer { + public String tryReplace(Player player, String msg) { + if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) + msg = PlaceholderAPI.setPlaceholders(player, msg); + return msg; + } + + public List tryReplace(Player player, List msgs) { + return msgs.stream().map(line -> tryReplace(player, line)).collect(Collectors.toList()); + } + } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java index ce91ef9..3d10814 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java @@ -4,7 +4,9 @@ import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent; import ca.tweetzy.auctionhouse.api.hook.FloodGateHook; -import ca.tweetzy.auctionhouse.auction.*; +import ca.tweetzy.auctionhouse.api.hook.PlaceholderAPIHook; +import ca.tweetzy.auctionhouse.auction.AuctionPlayer; +import ca.tweetzy.auctionhouse.auction.AuctionedItem; import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory; import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType; @@ -388,7 +390,7 @@ public class GUIAuctionHouse extends Gui { */ private void drawVariableButtons() { if (Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ENABLED.getBoolean()) { - setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList(), new HashMap() {{ + setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_NAME.getString(), PlaceholderAPIHook.PAPIReplacer.tryReplace(this.auctionPlayer.getPlayer(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList()), new HashMap() {{ put("%active_player_auctions%", auctionPlayer.getItems(false).size()); put("%player_balance%", Settings.USE_SHORT_NUMBERS_ON_PLAYER_BALANCE.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(EconomyManager.getBalance(auctionPlayer.getPlayer())) : AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(auctionPlayer.getPlayer()))); }}), e -> { diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java index cca3ea3..390ca9e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java @@ -2,6 +2,10 @@ package ca.tweetzy.auctionhouse.settings; import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.core.configuration.Config; +import me.clip.placeholderapi.PlaceholderAPI; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import java.util.HashMap; @@ -179,6 +183,14 @@ public class LocaleSettings { languageNodes.put("commands.description.markchest", "Toggles whether a chest is an auction chest"); } + public static void send(CommandSender sender, String msg) { + if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null && sender instanceof Player) { + msg = PlaceholderAPI.setPlaceholders((Player) sender, msg); + } + + AuctionHouse.getInstance().getLocale().getMessage(msg).sendPrefixedMessage(sender); + } + public static void setup() { Config config = AuctionHouse.getInstance().getLocale().getConfig(); diff --git a/src/main/test/Test.java b/src/main/test/Test.java index 0968357..fc959ee 100644 --- a/src/main/test/Test.java +++ b/src/main/test/Test.java @@ -1,3 +1,5 @@ +import ca.tweetzy.auctionhouse.api.AuctionAPI; + /** * The current file has been created by Kiran Hart * Date Created: July 21 2021 @@ -30,7 +32,10 @@ public class Test { // long future = System.currentTimeMillis() + 1000L * 10; - System.out.println("16".compareTo(System.getProperty("java.version")) <= 0); +// System.out.println("16".compareTo(System.getProperty("java.version")) <= 0); + + final double max = 99999999999999999999999999999.0D; + System.out.println(AuctionAPI.getInstance().getFriendlyNumber(max)); } public static long getSecondsFromString(String time) {