mirror of
https://github.com/songoda/EpicHeads.git
synced 2024-12-05 17:03:20 +01:00
83a77b3578
Replaced localization system with mine.
57 lines
1.3 KiB
Java
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);
|
|
}
|
|
|
|
}
|