v1.2.3 Update

Bug Fix:
  - Error when MCUpdate goes down.
  - Error from a method that was running async when it shouldn't have been.

Changes:
  - Cleaned up some code for easier reading.
This commit is contained in:
BadBones69 2017-07-07 16:30:35 -04:00
parent aa9c00dbbf
commit 2ab7a86802
12 changed files with 333 additions and 173 deletions

View File

@ -2,6 +2,16 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="/Users/Joe/Plugins/Spigot/Spigot 1.12.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/Users/Joe/Plugins/Spigot/Spigot%201.12%20JavaDoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/Users/Joe/Plugins/Spigot/Spigot 1.11.2.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/Users/Joe/Plugins/Spigot/Spigot%201.11.2%20JavaDoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/Users/Joe/Plugins/Spigot/Spigot 1.10.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/Users/Joe/Desktop/Stuff/Spigot/Spigot%201.10%20JavaDoc.jar!/"/>

2
.gitignore vendored
View File

@ -3,3 +3,5 @@
*.prefs
*.class
bin/

21
Notes
View File

@ -1,7 +1,18 @@
Features:
(Request) Add it so you can sell more then just 64 of a stack.
(Request) Add a history purchase history.
(Bug) When you collect an item from the expired list with a fully inventory, the item gets lost.
Feature Requests:
- Add it so you can sell more then just 64 of a stack.
- Add a history purchase history.
- Add a taxation option.
- Add an option to broadcast a message when a player adds a new item.
- Add a black list to block names and lores.
- Add an option to set Bidding as the 1st GUI.
- Add the command translation for Spanish and Portugees.
- Add MySQL support.
- Make the command messages all configurable.
- Add a tax system for when a player buys an item.
- Add an option to search for items by ID.
Reports:
- When you collect an item from the expired list with a fully inventory, the item gets lost.
Bug Fixes:
-
@ -13,4 +24,4 @@ Changes:
-
Removed:
- MCStats metrics has been removed due to it being dead.
-

View File

@ -2,7 +2,7 @@ name: CrazyAuctions
author: BadBones69
main: me.badbones69.crazyauctions.Main
website: https://www.spigotmc.org/resources/authors/kicjow.9719/
version: 1.2.2
version: 1.2.3
depend: [Vault]
description: >
A plugin to auction off items globally.

View File

@ -6,9 +6,14 @@ import org.bukkit.Material;
public enum Category{
NONE("None", new ArrayList<Material>()), OTHER("Other", getOthers()),
ARMOR("Armor", getArmor()), WEAPONS("Weapons", getWeapons()), TOOLS("Tools", getTools()),
FOOD("Food", getFood()), POTIONS("Potions", getPotions()), BLOCKS("Blocks", getBlocks());
NONE("None", new ArrayList<Material>()),
OTHER("Other", getOthers()),
ARMOR("Armor", getArmor()),
WEAPONS("Weapons", getWeapons()),
TOOLS("Tools", getTools()),
FOOD("Food", getFood()),
POTIONS("Potions", getPotions()),
BLOCKS("Blocks", getBlocks());
private String Name;
private ArrayList<Material> Items;
@ -18,8 +23,8 @@ public enum Category{
* @param name Name of the Shop Type.
*/
private Category(String name, ArrayList<Material> items){
this.Name=name;
this.Items=items;
this.Name = name;
this.Items = items;
}
/**
@ -70,6 +75,7 @@ public enum Category{
ma.add(Material.DIAMOND_BOOTS);
return ma;
}
private static ArrayList<Material> getTools(){
ArrayList<Material> ma = new ArrayList<Material>();
ma.add(Material.WOOD_PICKAXE);
@ -90,6 +96,7 @@ public enum Category{
ma.add(Material.DIAMOND_HOE);
return ma;
}
private static ArrayList<Material> getWeapons(){
ArrayList<Material> ma = new ArrayList<Material>();
ma.add(Material.WOOD_SWORD);
@ -103,6 +110,7 @@ public enum Category{
ma.add(Material.BOW);
return ma;
}
private static ArrayList<Material> getFood(){
ArrayList<Material> ma = new ArrayList<Material>();
for(Material m : Material.values()){
@ -112,11 +120,13 @@ public enum Category{
}
return ma;
}
private static ArrayList<Material> getPotions(){
ArrayList<Material> ma = new ArrayList<Material>();
ma.add(Material.POTION);
return ma;
}
private static ArrayList<Material> getBlocks(){
ArrayList<Material> ma = new ArrayList<Material>();
for(Material m : Material.values()){
@ -126,6 +136,7 @@ public enum Category{
}
return ma;
}
private static ArrayList<Material> getOthers(){
ArrayList<Material> ma = new ArrayList<Material>();
for(Material m : Material.values()){
@ -136,4 +147,5 @@ public enum Category{
}
return ma;
}
}

View File

@ -8,9 +8,12 @@ import org.bukkit.inventory.ItemStack;
public class CrazyAuctions {
static CrazyAuctions instance = new CrazyAuctions();
public static CrazyAuctions instance;
public static CrazyAuctions getInstance() {
if(instance == null){
instance = new CrazyAuctions();
}
return instance;
}
@ -33,7 +36,7 @@ public class CrazyAuctions {
if(data.contains("Items")){
for(String i : data.getConfigurationSection("Items").getKeys(false)){
if(data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())){
if(data.getBoolean("Items."+i+".Biddable")){
if(data.getBoolean("Items." + i + ".Biddable")){
if(type == Shop.BID){
items.add(data.getItemStack("Items."+i+".Item").clone());
}
@ -48,4 +51,4 @@ public class CrazyAuctions {
return items;
}
}
}

View File

@ -19,7 +19,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import me.badbones69.crazyauctions.currency.CM;
import me.badbones69.crazyauctions.currency.CurrencyManager;
public class GUI implements Listener{
@ -43,7 +43,7 @@ public class GUI implements Listener{
data.set("Items.Clear", null);
Main.settings.saveData();
}
if(cat!=null){
if(cat != null){
Cat.put(player, cat);
}else{
Cat.put(player, Category.NONE);
@ -51,7 +51,7 @@ public class GUI implements Listener{
if(data.contains("Items")){
for(String i : data.getConfigurationSection("Items").getKeys(false)){
List<String> lore = new ArrayList<String>();
if(cat.getItems().contains(data.getItemStack("Items."+i+".Item").getType())||cat==Category.NONE){
if(cat.getItems().contains(data.getItemStack("Items."+i+".Item").getType()) || cat == Category.NONE){
if(data.getBoolean("Items."+i+".Biddable")){
if(sell==Shop.BID){
String seller = data.getString("Items."+i+".Seller");
@ -493,9 +493,9 @@ public class GUI implements Listener{
String ID = BiddingID.get(player);
int bid = Bidding.get(player);
String topBidder = data.getString("Items."+ID+".TopBidder");
if(CM.getMoney(player)<bid){
if(CurrencyManager.getMoney(player)<bid){
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Need-More-Money")
.replaceAll("%Money_Needed%", (bid-CM.getMoney(player))+"").replaceAll("%money_needed%", (bid-CM.getMoney(player))+"")));
.replaceAll("%Money_Needed%", (bid-CurrencyManager.getMoney(player))+"").replaceAll("%money_needed%", (bid-CurrencyManager.getMoney(player))+"")));
return;
}
if(data.getLong("Items."+ID+".Price")>bid){
@ -705,7 +705,7 @@ public class GUI implements Listener{
return;
}
Long cost = data.getLong("Items."+i+".Price");
if(CM.getMoney(player)<cost){
if(CurrencyManager.getMoney(player)<cost){
String it = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Name");
ItemStack I = new ItemStack(Material.AIR);
@ -790,15 +790,15 @@ public class GUI implements Listener{
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Inventory-Full")));
return;
}
if(CM.getMoney(player)<cost){
if(CurrencyManager.getMoney(player)<cost){
playClick(player);
player.closeInventory();
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Need-More-Money")
.replaceAll("%Money_Needed%", (cost-CM.getMoney(player))+"").replaceAll("%money_needed%", (cost-CM.getMoney(player))+"")));
.replaceAll("%Money_Needed%", (cost-CurrencyManager.getMoney(player))+"").replaceAll("%money_needed%", (cost-CurrencyManager.getMoney(player))+"")));
return;
}
CM.removeMoney(player, cost);
CM.addMoney(Methods.getOfflinePlayer(seller), cost);
CurrencyManager.removeMoney(player, cost);
CurrencyManager.addMoney(Methods.getOfflinePlayer(seller), cost);
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Bought-Item")
.replaceAll("%Price%", Methods.getPrice(ID, false)).replaceAll("%price%", Methods.getPrice(ID, false))));
if(Methods.isOnline(seller)){

View File

@ -15,166 +15,280 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
public class MCUpdate implements Listener {
private final static String VERSION = "1.0";
private final static String VERSION = "1.1";
private static final String BASE_URL = "http://report.mcupdate.org";
private static final String BASE_URL = "http://report.mcupdate.org";
/**
* Server received information.
*/
private static String updateMessage = "";
private static boolean upToDate = true;
/**
* Server received information.
*/
private static String updateMessage = "";
private static boolean upToDate = true;
private boolean checkUpdate = true;
private Plugin pl;
private Plugin pl;
/**
* Interval of time to ping (seconds)
*/
private int PING_INTERVAL;
/**
* Interval of time to ping (seconds)
*/
private int PING_INTERVAL;
/**
* The scheduled task
*/
private volatile BukkitTask task = null;
/**
* The scheduled task
*/
private volatile BukkitTask task = null;
public MCUpdate(Plugin plugin, boolean startTask) throws IOException
{
if (plugin != null)
{
this.pl = plugin;
//I should add a custom configuration for MCUpdate itself
Bukkit.getPluginManager().registerEvents(this, plugin);
setPingInterval(900);
if (startTask)
{
start();
}
}
}
private boolean start() {
// Is MCUpdate already running?
if (task == null) {
// Begin hitting the server with glorious data
task = pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, () -> {
report();
if (!upToDate) {
pl.getServer().getConsoleSender().sendMessage(format(updateMessage));
/**
* Start up the MCUpdater.
*
* @param plugin
* The plugin using this.
* @throws IOException
*/
public MCUpdate(Plugin plugin) throws IOException {
if (plugin != null) {
this.pl = plugin;
// I should add a custom configuration for MCUpdate itself
Bukkit.getPluginManager().registerEvents(this, plugin);
setPingInterval(900);
}
}, 0, PING_INTERVAL * 20);
}
return true;
}
}
private int getOnlinePlayers() {
try {
Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
if (onlinePlayerMethod.getReturnType().equals(Collection.class)) {
return ((Collection<?>) onlinePlayerMethod.invoke(Bukkit.getServer())).size();
} else {
return ((Player[]) onlinePlayerMethod.invoke(Bukkit.getServer())).length;
}
} catch (Exception ex) {
}
return 0;
}
/**
*
* Start up the MCUpdater.
*
* @param plugin
* The plugin using this.
* @param activate
* Toggle if it starts the MCUpdater when used.
* @throws IOException
*/
public MCUpdate(Plugin plugin, Boolean activate) throws IOException {
if (plugin != null) {
this.pl = plugin;
// I should add a custom configuration for MCUpdate itself
Bukkit.getPluginManager().registerEvents(this, plugin);
setPingInterval(900);
if (activate) {
startLogging();
}
}
}
private void report() {
String ver = pl.getDescription().getVersion();
String name = pl.getDescription().getName();
int playersOnline = this.getOnlinePlayers();
boolean onlineMode = pl.getServer().getOnlineMode();
String serverVersion = pl.getServer().getVersion();
/**
* Call when you wan't to start the updater.
*
* @return True if everything starts and false if it doesn't start.
*/
public boolean startLogging() {
// Is MCUpdate already running?
if (task == null) {
// Begin hitting the server with glorious data
task = pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, () -> {
report();
if (!upToDate) {
if (checkUpdate) {
pl.getServer().getConsoleSender().sendMessage(format(updateMessage));
}
}
}, 0, PING_INTERVAL * 20);
}
return true;
}
String osname = System.getProperty("os.name");
String osarch = System.getProperty("os.arch");
String osversion = System.getProperty("os.version");
String java_version = System.getProperty("java.version");
int coreCount = Runtime.getRuntime().availableProcessors();
/**
* Call when you want to stop the updater.
*
* @return True if it successfully stoped and false if couldn't.
*/
public boolean stopLogging() {
if (task != null) {
try {
task.cancel();
return true;
} catch (Exception e) {
}
} else {
return true;
}
return false;
}
String report = "{ \"report\": {";
report += toJson("plugin", name) + ",";
report += toJson("version", ver) + ",";
report += toJson("playersonline", playersOnline + "") + ",";
report += toJson("onlinemode", onlineMode + "") + ",";
report += toJson("serverversion", serverVersion) + ",";
/**
* Check if MCUpdate is logging information.
*
* @return True if it is logging info and false if not.
*/
public Boolean isLogging() {
return task != null;
}
report += toJson("osname", osname) + ",";
report += toJson("osarch", osarch) + ",";
report += toJson("osversion", osversion) + ",";
report += toJson("javaversion", java_version) + ",";
report += toJson("corecount", coreCount + "") + "";
/**
* Set if the updater uses the internal update checker.
*
* @param checkUpdate
* True if you want to use the internal update checker and false
* if not.
*/
public void checkUpdate(Boolean checkUpdate) {
this.checkUpdate = checkUpdate;
}
report += "} }";
/**
* Checks if the internal updater is active.
*
* @return True if the internal updater is activated and false if not.
*/
public Boolean needsUpdated() {
return checkUpdate;
}
byte[] data = report.getBytes();
/**
* Set the rate the information is sent to MCUpdate.org.
*
* @param PING_INTERVAL
* The rate at which the data is sent in seconds.
*/
public void setPingInterval(int PING_INTERVAL) {
this.PING_INTERVAL = PING_INTERVAL;
}
try {
/**
* Get the rate which the data is sent to MCUpdate.org.
*
* @return The rate the data is sent in seconds.
*/
public int getPingInterval() {
return PING_INTERVAL;
}
URL url = new URL(BASE_URL);
URLConnection c = url.openConnection();
c.setConnectTimeout(2500);
c.setReadTimeout(3500);
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if (p.isOp() && !upToDate) {
if (checkUpdate) {
p.sendMessage(format(updateMessage));
}
}
}
c.addRequestProperty("User-Agent", "MCUPDATE/" + VERSION);
c.addRequestProperty("Content-Type", "application/json");
c.addRequestProperty("Content-Length", Integer.toString(data.length));
c.addRequestProperty("Accept", "application/json");
c.addRequestProperty("Connection", "close");
private int getOnlinePlayers() {
try {
Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
if (onlinePlayerMethod.getReturnType().equals(Collection.class)) {
return ((Collection<?>) onlinePlayerMethod.invoke(Bukkit.getServer())).size();
} else {
return ((Player[]) onlinePlayerMethod.invoke(Bukkit.getServer())).length;
}
} catch (Exception ex) {
}
return 0;
}
c.setDoOutput(true);
private void report() {
String ver = pl.getDescription().getVersion();
String name = pl.getDescription().getName();
int playersOnline = this.getOnlinePlayers();
boolean onlineMode = pl.getServer().getOnlineMode();
String serverVersion = pl.getServer().getVersion();
OutputStream os = c.getOutputStream();
os.write(data);
os.flush();
String osname = System.getProperty("os.name");
String osarch = System.getProperty("os.arch");
String osversion = System.getProperty("os.version");
String java_version = System.getProperty("java.version");
int coreCount = Runtime.getRuntime().availableProcessors();
BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream()));
String endData = br.readLine().trim();
String report = "{ \"report\": {";
report += toJson("plugin", name) + ",";
report += toJson("version", ver) + ",";
report += toJson("playersonline", playersOnline + "") + ",";
report += toJson("onlinemode", onlineMode + "") + ",";
report += toJson("serverversion", serverVersion) + ",";
String serverMessage = getString(endData, "message");
String cVersion = getString(endData, "pl_Version");
updateMessage = getString(endData, "update_Message");
report += toJson("osname", osname) + ",";
report += toJson("osarch", osarch) + ",";
report += toJson("osversion", osversion) + ",";
report += toJson("javaversion", java_version) + ",";
report += toJson("corecount", coreCount + "") + "";
if (!serverMessage.equals("ERROR")) {
if (!ver.equals(cVersion)) {
upToDate = false;
}
}
br.close();
report += "} }";
} catch (IOException ignored) {
}
}
byte[] data = report.getBytes();
private String getString(String data, String key) {
String dat = data.replace("{ \"Response\": {\"", "");
dat = dat.replace("\"} }", "");
List<String> list = Arrays.asList(dat.split("\",\""));
try {
for (String stub : list) {
List<String> list2 = Arrays.asList(stub.split("\":\""));
if (key.equals(list2.get(0))) {
return list2.get(1);
}
}
return null;
}
URL url = new URL(BASE_URL);
URLConnection c = url.openConnection();
c.setConnectTimeout(2500);
c.setReadTimeout(3500);
private static String toJson(String key, String value) {
return "\"" + key + "\":\"" + value + "\"";
}
c.addRequestProperty("User-Agent", "MCUPDATE/" + VERSION);
c.addRequestProperty("Content-Type", "application/json");
c.addRequestProperty("Content-Length", Integer.toString(data.length));
c.addRequestProperty("Accept", "application/json");
c.addRequestProperty("Connection", "close");
private static String format(String format) {
return ChatColor.translateAlternateColorCodes('&', format);
}
c.setDoOutput(true);
OutputStream os = c.getOutputStream();
os.write(data);
os.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream()));
String endData = br.readLine().trim();
String serverMessage = getString(endData, "message");
String cVersion = getString(endData, "pl_Version");
updateMessage = getString(endData, "update_Message");
if (serverMessage != null) {
if (!serverMessage.equals("ERROR")) {
if (cVersion != null) {
if (!ver.equals(cVersion)) {
upToDate = false;
}
}
}
}
br.close();
} catch (Exception ignored) {
}
}
private String getString(String data, String key) {
String dat = data.replace("{ \"Response\": {\"", "");
dat = dat.replace("\"} }", "");
List<String> list = Arrays.asList(dat.split("\",\""));
for (String stub : list) {
List<String> list2 = Arrays.asList(stub.split("\":\""));
if (key.equals(list2.get(0))) {
return list2.get(1);
}
}
return "";
}
private static String toJson(String key, String value) {
return "\"" + key + "\":\"" + value + "\"";
}
private static String format(String format) {
if (format != null) {
return ChatColor.translateAlternateColorCodes('&', format);
} else {
return "";
}
}
public void setPingInterval(int PING_INTERVAL) {
this.PING_INTERVAL = PING_INTERVAL;
}
}

View File

@ -23,13 +23,7 @@ public class Main extends JavaPlugin implements Listener{
public static SettingsManager settings = SettingsManager.getInstance();
public static CrazyAuctions auc = CrazyAuctions.getInstance();
int file = 0;
@Override
public void onDisable(){
Bukkit.getScheduler().cancelTask(file);
settings.saveData();
}
private int file = 0;
@Override
public void onEnable(){
@ -54,6 +48,12 @@ public class Main extends JavaPlugin implements Listener{
} catch (IOException e) {}
}
@Override
public void onDisable(){
Bukkit.getScheduler().cancelTask(file);
settings.saveData();
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLable, String[] args){
if(commandLable.equalsIgnoreCase("CrazyAuctions") || commandLable.equalsIgnoreCase("CrazyAuction")
|| commandLable.equalsIgnoreCase("CA") || commandLable.equalsIgnoreCase("AH")
@ -299,7 +299,7 @@ public class Main extends JavaPlugin implements Listener{
public void run() {
Methods.updateAuction();
}
}.runTaskTimerAsynchronously(this, 20, 5*20);
}.runTaskTimer(this, 20, 5*20);
}
private ArrayList<Material> getDamageableItems(){
@ -355,4 +355,4 @@ public class Main extends JavaPlugin implements Listener{
return ma;
}
}
}

View File

@ -23,20 +23,18 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import me.badbones69.crazyauctions.currency.CM;
import me.badbones69.crazyauctions.currency.CurrencyManager;
public class Methods {
public static Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions");
public static String color(String msg){
msg = ChatColor.translateAlternateColorCodes('&', msg);
return msg;
return ChatColor.translateAlternateColorCodes('&', msg);
}
public static String removeColor(String msg){
msg = ChatColor.stripColor(msg);
return msg;
return ChatColor.stripColor(msg);
}
public static String getPrefix(){
@ -399,12 +397,12 @@ public class Methods {
if(cal.after(expireTime)){
int num = 1;
for(;data.contains("OutOfTime/Cancelled."+num);num++);
if(data.getBoolean("Items."+i+".Biddable")&&!data.getString("Items."+i+".TopBidder").equalsIgnoreCase("None")&&CM.getMoney(Methods.getPlayer(data.getString("Items."+i+".TopBidder")))>=data.getInt("Items."+i+".Price")){
if(data.getBoolean("Items."+i+".Biddable")&&!data.getString("Items."+i+".TopBidder").equalsIgnoreCase("None")&&CurrencyManager.getMoney(Methods.getPlayer(data.getString("Items."+i+".TopBidder")))>=data.getInt("Items."+i+".Price")){
String winner = data.getString("Items."+i+".TopBidder");
String seller = data.getString("Items."+i+".Seller");
Long price = data.getLong("Items."+i+".Price");
CM.addMoney(Methods.getOfflinePlayer(seller), price);
CM.removeMoney(Methods.getOfflinePlayer(winner), price);
CurrencyManager.addMoney(Methods.getOfflinePlayer(seller), price);
CurrencyManager.removeMoney(Methods.getOfflinePlayer(winner), price);
if(Methods.isOnline(winner)){
Player player = Methods.getPlayer(winner);
player.sendMessage(Methods.getPrefix()+Methods.color(msg.getString("Messages.Win-Bidding")

View File

@ -6,7 +6,8 @@ import org.bukkit.entity.Player;
import me.badbones69.crazyauctions.Main;
public enum CM { // Currency Manager
public enum CurrencyManager { // Currency Manager
VAULT("Vault", "Money");
String PluginName, Name;
@ -17,7 +18,7 @@ public enum CM { // Currency Manager
* @param name
* Name of the Currency.
*/
private CM(String pluginname, String name) {
private CurrencyManager(String pluginname, String name) {
this.PluginName = pluginname;
this.Name = name;
}
@ -41,8 +42,8 @@ public enum CM { // Currency Manager
* Name of the Type you want.
* @return Returns the Currency as a Enum.
*/
public static CM getFromName(String name) {
for (CM type : CM.values()) {
public static CurrencyManager getFromName(String name) {
for (CurrencyManager type : CurrencyManager.values()) {
if (type.getPluginName().equalsIgnoreCase(name)) {
return type;
}

View File

@ -9,14 +9,17 @@ import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
public class Vault {
public static Economy econ = null;
public static EconomyResponse r;
public static boolean hasVault(){
if(Bukkit.getServer().getPluginManager().getPlugin("Vault")!=null){
return true;
}
return false;
}
public static boolean setupEconomy(){
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null){
return false;
@ -28,22 +31,28 @@ public class Vault {
econ = rsp.getProvider();
return econ != null;
}
public static Long getMoney(Player player){
if(player != null){
return (long) econ.getBalance(player);
}
return 0L;
}
public static void removeMoney(Player player, Long amount){
econ.withdrawPlayer(player, amount);
}
public static void removeMoney(OfflinePlayer player, Long amount){
econ.withdrawPlayer(player, amount);
}
public static void addMoney(Player player, Long amount){
econ.depositPlayer(player, amount);
}
public static void addMoney(OfflinePlayer player, Long amount){
econ.depositPlayer(player, amount);
}
}