Delete PlaceHolders.java

This commit is contained in:
OllieJW 2021-07-19 22:08:12 +01:00 committed by GitHub
parent 44f3f20957
commit 5c109a2be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,38 +0,0 @@
package com.olliejw.oremarket.Utils;
import com.olliejw.oremarket.OreMarket;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.text.Format;
public class PlaceHolders {
public String format (String string, HumanEntity player, ConfigurationSection configurationSection) {
Player playerObj = (Player) player;
String name = configurationSection.getString("name");
final Format DECIMAL_FORMAT = new DecimalFormat("#0.0#");
int stock = configurationSection.getInt("stock");
double value = configurationSection.getDouble("value");
double cost = configurationSection.getDouble("cost");
double difference = (value-cost);
double change = (value/cost);
double percent = ((change*100)-100);
double balance = OreMarket.getEconomy().getBalance(playerObj);
assert name != null;
return ChatColor.translateAlternateColorCodes('&', string
.replace("[name]", name)
.replace("[stock]", String.valueOf(stock))
.replace("[value]", DECIMAL_FORMAT.format(value))
.replace("[cost]", DECIMAL_FORMAT.format(cost))
.replace("[change]", DECIMAL_FORMAT.format(difference))
.replace("[percent]", DECIMAL_FORMAT.format(percent))
.replace("[balance]", DECIMAL_FORMAT.format(balance))
);
}
}