2.53.1 - placeholder api fix, increased short number format range

This commit is contained in:
Kiran Hart 2022-01-18 13:07:32 -05:00
parent 9aa111cc73
commit 63e9bcc3c6
6 changed files with 46 additions and 5 deletions

View File

@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>ca.tweetzy</groupId> <groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId> <artifactId>auctionhouse</artifactId>
<version>2.53.0</version> <version>2.53.1</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -36,6 +36,8 @@ import co.aikar.taskchain.TaskChain;
import co.aikar.taskchain.TaskChainFactory; import co.aikar.taskchain.TaskChainFactory;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderHook;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -236,7 +238,7 @@ public class AuctionHouse extends TweetyPlugin {
); );
// Placeholder API // Placeholder API
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPIHook") != null) { if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderAPIHook(this).register(); new PlaceholderAPIHook(this).register();
} }

View File

@ -2,10 +2,17 @@ package ca.tweetzy.auctionhouse.api.hook;
import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import lombok.experimental.UtilityClass;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* The current file has been created by Kiran Hart * The current file has been created by Kiran Hart
* Date Created: August 07 2021 * Date Created: August 07 2021
@ -66,4 +73,17 @@ public class PlaceholderAPIHook extends PlaceholderExpansion {
return null; 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<String> tryReplace(Player player, List<String> msgs) {
return msgs.stream().map(line -> tryReplace(player, line)).collect(Collectors.toList());
}
}
} }

View File

@ -4,7 +4,9 @@ import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent; import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent;
import ca.tweetzy.auctionhouse.api.hook.FloodGateHook; 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.AuctionItemCategory;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType; import ca.tweetzy.auctionhouse.auction.enums.AuctionSortType;
@ -388,7 +390,7 @@ public class GUIAuctionHouse extends Gui {
*/ */
private void drawVariableButtons() { private void drawVariableButtons() {
if (Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ENABLED.getBoolean()) { 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<String, Object>() {{ 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<String, Object>() {{
put("%active_player_auctions%", auctionPlayer.getItems(false).size()); 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()))); 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 -> { }}), e -> {

View File

@ -2,6 +2,10 @@ package ca.tweetzy.auctionhouse.settings;
import ca.tweetzy.auctionhouse.AuctionHouse; import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.core.configuration.Config; 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; import java.util.HashMap;
@ -179,6 +183,14 @@ public class LocaleSettings {
languageNodes.put("commands.description.markchest", "Toggles whether a chest is an auction chest"); 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() { public static void setup() {
Config config = AuctionHouse.getInstance().getLocale().getConfig(); Config config = AuctionHouse.getInstance().getLocale().getConfig();

View File

@ -1,3 +1,5 @@
import ca.tweetzy.auctionhouse.api.AuctionAPI;
/** /**
* The current file has been created by Kiran Hart * The current file has been created by Kiran Hart
* Date Created: July 21 2021 * Date Created: July 21 2021
@ -30,7 +32,10 @@ public class Test {
// long future = System.currentTimeMillis() + 1000L * 10; // 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) { public static long getSecondsFromString(String time) {