From 6e8183c7bd45071967b2179095c2163d6ad2179f Mon Sep 17 00:00:00 2001 From: Brianna Date: Fri, 25 Sep 2020 12:13:26 -0500 Subject: [PATCH] Added support for the new number utilities in SongodaCore. --- pom.xml | 4 +- .../command/commands/admin/SetMaxMembers.java | 4 +- .../commands/admin/SetSizeCommand.java | 4 +- .../commands/island/CreateCommand.java | 1 + .../commands/island/DeleteCommand.java | 1 + .../command/commands/island/LevelCommand.java | 3 +- .../command/commands/island/OwnerCommand.java | 1 + .../commands/island/UnlockCommand.java | 4 +- .../command/commands/island/ValueCommand.java | 4 +- .../skyblock/gui/bank/GuiBankSelector.java | 6 +-- .../songoda/skyblock/gui/biome/GuiBiome.java | 1 + .../com/songoda/skyblock/island/Island.java | 4 +- .../skyblock/listeners/BlockListeners.java | 4 +- .../skyblock/listeners/InteractListeners.java | 6 +-- .../com/songoda/skyblock/menus/Biome.java | 1 + .../com/songoda/skyblock/menus/Creator.java | 1 + .../songoda/skyblock/menus/Leaderboard.java | 4 +- .../com/songoda/skyblock/menus/Levelling.java | 11 ++-- .../com/songoda/skyblock/menus/Members.java | 1 + .../com/songoda/skyblock/menus/Upgrade.java | 50 +++++++++---------- .../com/songoda/skyblock/menus/Visit.java | 8 +-- .../com/songoda/skyblock/menus/Visitors.java | 1 + .../skyblock/menus/admin/Levelling.java | 8 +-- .../songoda/skyblock/menus/admin/Upgrade.java | 18 +++---- .../placeholder/PlaceholderProcessor.java | 22 ++++---- .../songoda/skyblock/stackable/Stackable.java | 4 +- .../songoda/skyblock/tasks/HologramTask.java | 10 ++-- .../songoda/skyblock/utils/NumberUtil.java | 33 ------------ 28 files changed, 98 insertions(+), 121 deletions(-) diff --git a/pom.xml b/pom.xml index ef510080..b1a4cab7 100644 --- a/pom.xml +++ b/pom.xml @@ -140,7 +140,7 @@ public - http://repo.songoda.com/artifactory/public/ + http://repo.songoda.com/repository/public/ @@ -229,7 +229,7 @@ com.songoda SongodaCore - 2.4.8 + LATEST compile diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java index 897c4e40..16ff21be 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java @@ -9,7 +9,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.player.OfflinePlayer; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -109,7 +109,7 @@ public class SetMaxMembers extends SubCommand { messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.SetMaxMembers.Set.Message") .replace("%player", targetPlayerName) - .replace("%maxMembers", NumberUtil.formatNumberByDecimal(maxMembers))); + .replace("%maxMembers", NumberUtils.formatNumber(maxMembers))); soundManager.playSound(sender, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); } } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java index 814e02c6..f12a9148 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java @@ -9,7 +9,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.player.OfflinePlayer; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -109,7 +109,7 @@ public class SetSizeCommand extends SubCommand { messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.SetSize.Set.Message") .replace("%player", targetPlayerName) - .replace("%size", NumberUtil.formatNumberByDecimal(size))); + .replace("%size", NumberUtils.formatNumber(size))); soundManager.playSound(sender, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); } } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java index ad67a9c5..3642c905 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java @@ -13,6 +13,7 @@ import com.songoda.skyblock.menus.Creator; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.structure.Structure; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java index 25317d3b..a104ea91 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java @@ -16,6 +16,7 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.ChatComponent; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java index f4641db3..c9702894 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java @@ -14,6 +14,7 @@ import com.songoda.skyblock.menus.Levelling; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.visit.Visit; @@ -68,7 +69,7 @@ public class LevelCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Level.Message") .replace("%player", targetPlayerName).replace("%level", - "" + NumberUtil.formatNumberByDecimal(visit.getLevel().getLevel()))); + "" + NumberUtils.formatNumber(visit.getLevel().getLevel()))); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); return; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java index 9d9d65ec..55dbfcaf 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java @@ -17,6 +17,7 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.ChatComponent; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; import net.md_5.bungee.api.ChatColor; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java index 11e5781b..07c8a8fa 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java @@ -10,7 +10,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import org.apache.commons.lang.WordUtils; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -71,7 +71,7 @@ public class UnlockCommand extends SubCommand { if (!economy.hasBalance(player, price)) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Money.Message").replace( - "%cost%", NumberUtil.formatNumberByDecimal(price))); + "%cost%", NumberUtils.formatNumber(price))); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java index 7ae02baa..c1cd5cf8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java @@ -8,7 +8,7 @@ import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import org.apache.commons.lang.WordUtils; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -41,7 +41,7 @@ public class ValueCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Value.Value.Message").replace("%material", WordUtils.capitalizeFully(materials.name().toLowerCase().replace("_", " "))) - .replace("%points", "" + worth).replace("%level", "" + NumberUtil.formatNumberByDecimal(level))); + .replace("%points", "" + worth).replace("%level", "" + NumberUtils.formatNumber(level))); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F); } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Value.None.Message")); diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index dc220321..6379d314 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -12,7 +12,7 @@ import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import org.bukkit.configuration.file.FileConfiguration; import java.io.File; @@ -123,7 +123,7 @@ public class GuiBankSelector extends Gui { case SUCCESS: soundManager.playSound(event.player, CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.getSound(), 1f, 1f); messageManager.sendMessage(event.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank." + finalAction + ".Message")).replace( - "%amount%", NumberUtil.formatNumberByDecimal(amount))); + "%amount%", NumberUtils.formatNumber(amount))); break; } @@ -180,7 +180,7 @@ public class GuiBankSelector extends Gui { case SUCCESS: soundManager.playSound(event.player, CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.getSound(), 1f, 1f); messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank." + finalAction + ".Message")).replace( - "%amount%", NumberUtil.formatNumberByDecimal(amount))); + "%amount%", NumberUtils.formatNumber(amount))); break; } diff --git a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java index d44c5100..5e8e38ce 100644 --- a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java @@ -18,6 +18,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 50be601c..95e30ad6 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -15,7 +15,7 @@ import com.songoda.skyblock.permission.BasicPermission; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.upgrade.Upgrade; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.world.WorldBorder; import com.songoda.skyblock.visit.Visit; import com.songoda.skyblock.world.WorldManager; @@ -957,7 +957,7 @@ public class Island { messageManager.sendMessage(player, this.plugin.getLanguage() .getString("Island.Unlock." + type.name() + ".Message").replace( - "%cost%", NumberUtil.formatNumberByDecimal(price))); + "%cost%", NumberUtils.formatNumber(price))); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); if(type.equals(IslandWorld.End)){ diff --git a/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java b/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java index 3fa92830..4321d24b 100644 --- a/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java +++ b/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java @@ -18,7 +18,7 @@ import com.songoda.skyblock.limit.impl.BlockLimitation; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.version.CompatibleSpawners; import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.LocationUtil; @@ -339,7 +339,7 @@ public class BlockListeners implements Listener { } plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Limit.Block.Exceeded.Message") - .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit))); + .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtils.formatNumber(limit))); plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); diff --git a/src/main/java/com/songoda/skyblock/listeners/InteractListeners.java b/src/main/java/com/songoda/skyblock/listeners/InteractListeners.java index a9d4a308..bbe380dd 100644 --- a/src/main/java/com/songoda/skyblock/listeners/InteractListeners.java +++ b/src/main/java/com/songoda/skyblock/listeners/InteractListeners.java @@ -16,7 +16,7 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.structure.StructureUtil; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; @@ -113,7 +113,7 @@ public class InteractListeners implements Listener { CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getItem().getType()); plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Limit.Block.Exceeded.Message") - .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit))); + .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtils.formatNumber(limit))); plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); @@ -195,7 +195,7 @@ public class InteractListeners implements Listener { if (limits.isBlockLimitExceeded(block, limit)) { plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message") - .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit))); + .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtils.formatNumber(limit))); plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); diff --git a/src/main/java/com/songoda/skyblock/menus/Biome.java b/src/main/java/com/songoda/skyblock/menus/Biome.java index 5ad1ec9e..a2def64a 100644 --- a/src/main/java/com/songoda/skyblock/menus/Biome.java +++ b/src/main/java/com/songoda/skyblock/menus/Biome.java @@ -15,6 +15,7 @@ import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.version.SBiome; diff --git a/src/main/java/com/songoda/skyblock/menus/Creator.java b/src/main/java/com/songoda/skyblock/menus/Creator.java index 3c9fd6b5..80f06d69 100644 --- a/src/main/java/com/songoda/skyblock/menus/Creator.java +++ b/src/main/java/com/songoda/skyblock/menus/Creator.java @@ -12,6 +12,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.structure.Structure; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import org.bukkit.Bukkit; diff --git a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java index 7f08f48e..d67dd49d 100644 --- a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java +++ b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java @@ -8,7 +8,7 @@ import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; @@ -302,7 +302,7 @@ public class Leaderboard { new Placeholder("%position", "" + (leaderboard.getPosition() + 1)), new Placeholder("%owner", playerName), new Placeholder("%level", "" + visit.getLevel().getLevel()), - new Placeholder("%balance", NumberUtil.formatNumberByDecimal(visit.getBankBalance())), + new Placeholder("%balance", NumberUtils.formatNumber(visit.getBankBalance())), new Placeholder("%votes", "" + visit.getVoters().size()), new Placeholder("%members", "" + visit.getMembers())}, null, null), diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index 580c35f2..3a1c2b03 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -17,6 +17,7 @@ import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; @@ -210,7 +211,7 @@ public class Levelling { new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 3, 5); nInv.addItem( nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Statistics.Lore"), - new Placeholder[]{new Placeholder("%level_points", NumberUtil.formatNumberByDecimal(level.getPoints())), new Placeholder("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))}, null, null), + new Placeholder[]{new Placeholder("%level_points", NumberUtils.formatNumber(level.getPoints())), new Placeholder("%level", NumberUtils.formatNumber(level.getLevel()))}, null, null), 4); nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); @@ -275,11 +276,11 @@ public class Levelling { long finalMaterialAmountCounted = materialAmountCounted; List lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore"); - lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)).replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)) - .replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted))); + lore.replaceAll(x -> x.replace("%points", NumberUtils.formatNumber(pointsEarned)).replace("%blocks", NumberUtils.formatNumber(materialAmount)) + .replace("%material", name).replace("%counted", NumberUtils.formatNumber(finalMaterialAmountCounted))); - nInv.addItem(nInv.createItem(is, configLoad.getString("Menu.Levelling.Item.Material.Displayname").replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)) - .replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted)) + nInv.addItem(nInv.createItem(is, configLoad.getString("Menu.Levelling.Item.Material.Displayname").replace("%points", NumberUtils.formatNumber(pointsEarned)) + .replace("%blocks", NumberUtils.formatNumber(materialAmount)).replace("%material", name).replace("%counted", NumberUtils.formatNumber(finalMaterialAmountCounted)) , lore, null, null, null), inventorySlot); } diff --git a/src/main/java/com/songoda/skyblock/menus/Members.java b/src/main/java/com/songoda/skyblock/menus/Members.java index 676b2e69..40a524ff 100644 --- a/src/main/java/com/songoda/skyblock/menus/Members.java +++ b/src/main/java/com/songoda/skyblock/menus/Members.java @@ -12,6 +12,7 @@ import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.StringUtil; import com.songoda.skyblock.utils.item.SkullUtil; diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java index 3770e1bd..8cedad20 100644 --- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java @@ -15,7 +15,7 @@ import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.upgrade.UpgradeManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; @@ -532,7 +532,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Speed.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Speed))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); @@ -543,7 +543,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Speed.Claimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); } else { nInv.addItem(nInv.createItem(potion, @@ -551,7 +551,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Speed.Unclaimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); } } @@ -585,7 +585,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Jump.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Jump))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); @@ -596,7 +596,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Jump.Claimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); } else { nInv.addItem(nInv.createItem(potion, @@ -604,7 +604,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Jump.Unclaimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); } } @@ -623,7 +623,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Crop.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Crop))}, null, null), 3); @@ -634,7 +634,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Crop.Claimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 3); } else { nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), @@ -642,7 +642,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Crop.Unclaimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 3); } } @@ -661,7 +661,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Fly.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Fly))}, null, null), 4); @@ -672,7 +672,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Fly.Claimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 4); } else { nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), @@ -680,7 +680,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Fly.Unclaimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 4); } } @@ -699,7 +699,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Drops.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Drops))}, null, null), 5); @@ -710,7 +710,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Drops.Claimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 5); } else { nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), @@ -718,7 +718,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Drops.Unclaimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 5); } } @@ -746,7 +746,7 @@ public class Upgrade { "" + tier)), configLoad.getStringList("Menu.Upgrade.Item.Members.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%tier", "" + tier), new Placeholder("%maxMembers", "" + upgrade.getValue())}, null, null), 6); @@ -760,7 +760,7 @@ public class Upgrade { configLoad.getStringList("Menu.Upgrade.Item.Members.Claimable.Lore"), new Placeholder[]{ new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), + NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%tier", "" + tier), new Placeholder("%maxMembers", "" + upgrade.getValue())}, null, null), @@ -774,7 +774,7 @@ public class Upgrade { configLoad.getStringList("Menu.Upgrade.Item.Members.Unclaimable.Lore"), new Placeholder[]{ new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), + NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%tier", "" + tier), new Placeholder("%maxMembers", "" + upgrade.getValue())}, null, null), @@ -808,7 +808,7 @@ public class Upgrade { "" + tier)), configLoad.getStringList("Menu.Upgrade.Item.Size.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%tier", "" + tier), new Placeholder("%size", "" + upgrade.getValue())}, null, null), 7); @@ -822,7 +822,7 @@ public class Upgrade { configLoad.getStringList("Menu.Upgrade.Item.Size.Claimable.Lore"), new Placeholder[]{ new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), + NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%tier", "" + tier), new Placeholder("%size", "" + upgrade.getValue())}, null, null), @@ -836,7 +836,7 @@ public class Upgrade { configLoad.getStringList("Menu.Upgrade.Item.Size.Unclaimable.Lore"), new Placeholder[]{ new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), + NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%tier", "" + tier), new Placeholder("%size", "" + upgrade.getValue())}, null, null), @@ -861,7 +861,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Spawner.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner))}, null, null), 8); @@ -872,7 +872,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Spawner.Claimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 8); } else { nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), @@ -880,7 +880,7 @@ public class Upgrade { configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), configLoad.getStringList("Menu.Upgrade.Item.Spawner.Unclaimable.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost()))}, null, null), 8); } } diff --git a/src/main/java/com/songoda/skyblock/menus/Visit.java b/src/main/java/com/songoda/skyblock/menus/Visit.java index f483432c..8f9479b5 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visit.java +++ b/src/main/java/com/songoda/skyblock/menus/Visit.java @@ -15,7 +15,7 @@ import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.StringUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; @@ -347,10 +347,10 @@ public class Visit { configLoad.getString("Menu.Visit.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Visit.Item.Statistics.Lore"), new Placeholder[]{ - new Placeholder("%islands_open", NumberUtil.formatNumberByDecimal(visitIslands.size())), + new Placeholder("%islands_open", NumberUtils.formatNumber(visitIslands.size())), new Placeholder("%islands_closed", - NumberUtil.formatNumberByDecimal(totalIslands - visitIslands.size())), - new Placeholder("%islands", NumberUtil.formatNumberByDecimal(totalIslands))}, + NumberUtils.formatNumber(totalIslands - visitIslands.size())), + new Placeholder("%islands", NumberUtils.formatNumber(totalIslands))}, null, null), 4); nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Visit.Item.Sort.Displayname"), diff --git a/src/main/java/com/songoda/skyblock/menus/Visitors.java b/src/main/java/com/songoda/skyblock/menus/Visitors.java index 32a235b2..8c758c7e 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visitors.java +++ b/src/main/java/com/songoda/skyblock/menus/Visitors.java @@ -12,6 +12,7 @@ import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java index df2af1ed..920afd64 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java @@ -13,7 +13,7 @@ import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.AbstractAnvilGUI; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.version.NMSUtil; @@ -134,7 +134,7 @@ public class Levelling implements Listener { .replace("%material", material.getMaterials().name())), configLoad.getStringList("Menu.Admin.Levelling.Item.Material.Lore"), new Placeholder[]{new Placeholder("%points", - NumberUtil.formatNumberByDecimal(material.getPoints()))}, + NumberUtils.formatNumber(material.getPoints()))}, null, null), inventorySlot); } @@ -220,7 +220,7 @@ public class Levelling implements Listener { messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Division.Message") - .replace("%division", NumberUtil.formatNumberByDecimal(pointDivision))); + .replace("%division", NumberUtils.formatNumber(pointDivision))); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { @@ -322,7 +322,7 @@ public class Levelling implements Listener { messageManager.sendMessage(player, configLoad .getString("Island.Admin.Levelling.Points.Message") .replace("%material", materials.name()).replace("%points", - NumberUtil.formatNumberByDecimal(materialPoints))); + NumberUtils.formatNumber(materialPoints))); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java index 58aa335f..5ab30b3f 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java @@ -12,7 +12,7 @@ import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.upgrade.UpgradeManager; import com.songoda.skyblock.utils.AbstractAnvilGUI; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; @@ -270,7 +270,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Speed.Displayname")), configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Speed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); @@ -288,7 +288,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Jump.Displayname")), configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Jump.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); @@ -298,7 +298,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Crop.Displayname")), configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Crop.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, null, null), 2); @@ -308,7 +308,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Fly.Displayname")), configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Fly.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, null, null), 3); @@ -318,7 +318,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Drops.Displayname")), configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Drops.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, null, null), 4); @@ -356,7 +356,7 @@ public class Upgrade { plugin.formatText(configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Spawner.Displayname")), configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Spawner.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%cost", NumberUtils.formatNumber(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, null, null), 6); @@ -783,7 +783,7 @@ public class Upgrade { configLoad.getStringList("Menu.Admin.Upgrade.Size.Item.Tier.Lore"), new Placeholder[]{new Placeholder("%size", "" + upgrade.getValue()), new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + NumberUtils.formatNumber(upgrade.getCost()))}, null, null), i + 3); } } @@ -1210,7 +1210,7 @@ public class Upgrade { configLoad.getStringList("Menu.Admin.Upgrade.Members.Item.Tier.Lore"), new Placeholder[]{new Placeholder("%maxMembers", "" + upgrade.getValue()), new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + NumberUtils.formatNumber(upgrade.getCost()))}, null, null), i + 3); } } diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java index 50f45601..4d3246aa 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java @@ -10,7 +10,7 @@ import com.songoda.skyblock.leaderboard.Leaderboard; import com.songoda.skyblock.leaderboard.LeaderboardManager; import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.upgrade.Upgrade; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.visit.Visit; import com.songoda.skyblock.visit.VisitManager; @@ -123,7 +123,7 @@ public class PlaceholderProcessor { } else { returnValue = TextUtils.formatText( placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Non-empty").replace( - "{PLACEHOLDER}", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel()))); + "{PLACEHOLDER}", "" + NumberUtils.formatWithSuffix(island.getLevel().getLevel()))); } break; case "fabledskyblock_island_points": @@ -318,7 +318,7 @@ public class PlaceholderProcessor { } else { returnValue = TextUtils.formatText( placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Non-empty")) - .replace("{PLACEHOLDER}", "" + NumberUtil.formatNumberByDecimal(island.getBankBalance())); + .replace("{PLACEHOLDER}", "" + NumberUtils.formatNumber(island.getBankBalance())); } break; case "fabledskyblock_island_bank_balance_formatted": @@ -328,7 +328,7 @@ public class PlaceholderProcessor { } else { returnValue = TextUtils.formatText( placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Non-empty")) - .replace("{PLACEHOLDER}", "" + NumberUtil.formatNumberBySuffix((long) island.getBankBalance())); + .replace("{PLACEHOLDER}", "" + NumberUtils.formatWithSuffix((long) island.getBankBalance())); } break; } @@ -362,7 +362,7 @@ public class PlaceholderProcessor { placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_votes.Non-empty") .replace("{POSITION}", "" + (value)) .replace("{PLAYER}", islandOwnerName) - .replace("{VOTES}", NumberUtil.formatNumberByDecimal(visit.getVoters().size()))); + .replace("{VOTES}", NumberUtils.formatNumber(visit.getVoters().size()))); } else { returnValue = TextUtils.formatText( @@ -396,7 +396,7 @@ public class PlaceholderProcessor { placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_bank.Non-empty") .replace("{POSITION}", "" + (value)) .replace("{PLAYER}", islandOwnerName) - .replace("{BALANCE}", NumberUtil.formatNumberByDecimal(visit.getBankBalance()))); + .replace("{BALANCE}", NumberUtils.formatNumber(visit.getBankBalance()))); } else { returnValue = TextUtils.formatText( @@ -431,8 +431,8 @@ public class PlaceholderProcessor { placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_level.Non-empty") .replace("{POSITION}", "" + (value)) .replace("{PLAYER}", islandOwnerName) - .replace("{LEVEL}", NumberUtil.formatNumberByDecimal(level.getLevel())) - .replace("{POINTS}", NumberUtil.formatNumberByDecimal(level.getPoints()))); + .replace("{LEVEL}", NumberUtils.formatNumber(level.getLevel())) + .replace("{POINTS}", NumberUtils.formatNumber(level.getPoints()))); } else { returnValue = TextUtils.formatText( @@ -482,7 +482,7 @@ public class PlaceholderProcessor { long blockCount = island.getLevel().getMaterialAmount(materials.name()); returnValue = TextUtils.formatText( placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_count.Non-empty") - .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockCount))); + .replace("{PLACEHOLDER}", NumberUtils.formatNumber(blockCount))); } } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_points_")) { @@ -499,7 +499,7 @@ public class PlaceholderProcessor { long blockPoints = island.getLevel().getMaterialPoints(materials.name()); returnValue = TextUtils.formatText( placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_points.Non-empty") - .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockPoints))); + .replace("{PLACEHOLDER}", NumberUtils.formatNumber(blockPoints))); } } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_level_block_value_")) { @@ -512,7 +512,7 @@ public class PlaceholderProcessor { double blockValue = levellingManager.getWorth(materials); returnValue = TextUtils.formatText( placeholdersLoad.getString("Placeholders.fabledskyblock_level_block_value.Non-empty") - .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockValue))); + .replace("{PLACEHOLDER}", NumberUtils.formatNumber(blockValue))); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_has_upgrade_")) { Upgrade.Type type; diff --git a/src/main/java/com/songoda/skyblock/stackable/Stackable.java b/src/main/java/com/songoda/skyblock/stackable/Stackable.java index ab257220..741ab608 100644 --- a/src/main/java/com/songoda/skyblock/stackable/Stackable.java +++ b/src/main/java/com/songoda/skyblock/stackable/Stackable.java @@ -4,7 +4,7 @@ import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -184,6 +184,6 @@ public class Stackable { private String getCustomName() { return ChatColor .translateAlternateColorCodes('&', SkyBlock.getInstance().getLanguage().getString("Hologram.Stackable.Message")) - .replace("%block", SkyBlock.getInstance().getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(material)).replace("%amount", NumberUtil.formatNumber(this.size)); + .replace("%block", SkyBlock.getInstance().getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(material)).replace("%amount", NumberUtils.formatNumber(this.size)); } } diff --git a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java index 5810dc52..17a77bd7 100644 --- a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java @@ -9,7 +9,7 @@ import com.songoda.skyblock.hologram.HologramType; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.leaderboard.Leaderboard; import com.songoda.skyblock.leaderboard.LeaderboardManager; -import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.core.utils.NumberUtils; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.visit.Visit; @@ -119,22 +119,22 @@ public class HologramTask extends BukkitRunnable { languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed") .replace("%position", "" + (i + 1)) .replace("%player", islandOwnerName) - .replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel())) - .replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints())))); + .replace("%level", NumberUtils.formatNumber(level.getLevel())) + .replace("%points", NumberUtils.formatNumber(level.getPoints())))); } else if (type == HologramType.Bank) { hologramLines.add(TextUtils.formatText( languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed") .replace("%position", "" + (i + 1)) .replace("%player", islandOwnerName) .replace("%balance", - "" + NumberUtil.formatNumberByDecimal(visit.getBankBalance())))); + "" + NumberUtils.formatNumber(visit.getBankBalance())))); } else if (type == HologramType.Votes) { hologramLines.add(TextUtils.formatText( languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed") .replace("%position", "" + (i + 1)) .replace("%player", islandOwnerName) .replace("%votes", - "" + NumberUtil.formatNumberByDecimal(visit.getVoters().size())))); + "" + NumberUtils.formatNumber(visit.getVoters().size())))); } } diff --git a/src/main/java/com/songoda/skyblock/utils/NumberUtil.java b/src/main/java/com/songoda/skyblock/utils/NumberUtil.java index 1341ea7a..a627e7b0 100644 --- a/src/main/java/com/songoda/skyblock/utils/NumberUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/NumberUtil.java @@ -1,42 +1,9 @@ package com.songoda.skyblock.utils; -import java.text.DecimalFormat; import java.util.Date; public final class NumberUtil { - public static String formatNumber(long number) { - return String.format("%,d", number); - } - - public static String formatNumberByDecimal(double number) { - String withoutDecimal = new DecimalFormat("0.#").format(number).replace(",", "."), withDecimal = ""; - - if (withoutDecimal.contains(".")) { - withDecimal = "." + withoutDecimal.split("\\.")[1]; - withoutDecimal = withoutDecimal.replace(withDecimal, ""); - } - - if (withDecimal.equals(".0")) { - withDecimal = ""; - } - - long itemCostWithoutDecimalValue = Long.valueOf(withoutDecimal); - - return formatNumber(itemCostWithoutDecimalValue) + withDecimal; - - } - - public static String formatNumberBySuffix(long number) { - if (number < 1000) { - return "" + number; - } - - int exp = (int) (Math.log(number) / Math.log(1000)); - - return String.format("%.1f%c", number / Math.pow(1000, exp), "kMGTPE".charAt(exp - 1)); - } - public static long[] getDuration(int time) { long seconds = time % 60; long minutes = time % 3600 / 60;