EpicHeads/main/java/com/songoda/epicheads/economy/PlayerPointsEconomy.java
Brianna O'Keefe 83a77b3578 Replaced existing commandManager with my CommandManager v2
Replaced localization system with mine.
2018-09-20 21:42:20 -04:00

57 lines
1.3 KiB
Java

package com.songoda.epicheads.economy;
import org.black_ixx.playerpoints.PlayerPoints;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class PlayerPointsEconomy implements Economy {
private PlayerPoints playerPoints;
@Override
public String getName() {
return "PlayerPoints";
}
private int convertAmount(double amount) {
return (int) Math.ceil(amount);
}
@Override
public String formatBalance(double bal) {
int amount = convertAmount(bal);
return Integer.toString(amount);
}
@Override
public boolean tryHook() {
if (Bukkit.getServer().getPluginManager().getPlugin("PlayerPoints") == null)
return false;
playerPoints = (PlayerPoints) Bukkit.getPluginManager().getPlugin("PlayerPoints");
return true;
}
@Override
public boolean isHooked() {
return playerPoints != null;
}
@Override
public boolean hasBalance(Player player, double bal) {
int amount = convertAmount(bal);
return playerPoints.getAPI().look(player.getUniqueId()) >= amount;
}
@Override
public boolean takeBalance(Player player, double bal) {
int amount = convertAmount(bal);
return playerPoints.getAPI().take(player.getUniqueId(), amount);
}
}