This commit is contained in:
boy0001 2015-02-21 23:09:20 +11:00
parent 1eb0ba47b4
commit 406ae58391
8 changed files with 20 additions and 9 deletions

View File

@ -381,6 +381,7 @@ public class PlotSquared {
THIS = this;
IMP = imp_class;
VERSION = IMP.getVersion();
economy = IMP.getEconomy();
C.setupTranslations();
C.saveTranslations();
if (getJavaVersion() < 1.7) {
@ -428,7 +429,6 @@ public class PlotSquared {
if (Settings.AUTO_CLEAR) {
ExpireManager.runTask();
}
economy = IMP.getEconomy();
}
public void disable() {

View File

@ -138,7 +138,7 @@ public class Auto extends SubCommand {
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
return true;
}
economy.withdrawPlayer(plr.getName(), cost);
EconHandler.withdrawPlayer(plr.getName(), cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}

View File

@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
@ -92,12 +93,12 @@ public class Buy extends SubCommand {
price += plotworld.PLOT_PRICE * size;
initPrice += plotworld.SELL_PRICE * size;
}
if (price > 0d) {
if (PlotSquared.economy != null && price > 0d) {
final Economy economy = PlotSquared.economy;
if (economy.getBalance(plr) < price) {
if (EconHandler.getBalance(plr) < price) {
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
}
economy.withdrawPlayer(plr, price);
EconHandler.withdrawPlayer(plr, price);
sendMessage(plr, C.REMOVED_BALANCE, price + "");
economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);

View File

@ -104,7 +104,7 @@ public class Claim extends SubCommand {
if (economy.getBalance(plr) < cost) {
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
}
economy.withdrawPlayer(plr, cost);
EconHandler.withdrawPlayer(plr, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}

View File

@ -151,7 +151,7 @@ public class Merge extends SubCommand {
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
return false;
}
economy.withdrawPlayer(plr, cost);
EconHandler.withdrawPlayer(plr, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}

View File

@ -115,7 +115,7 @@ public abstract class PlotWorld {
this.SCHEMATIC_FILE = config.getString("schematic.file");
this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
this.SCHEMATICS = config.getStringList("schematic.schematics");
this.USE_ECONOMY = config.getBoolean("economy.use");
this.USE_ECONOMY = config.getBoolean("economy.use") && PlotSquared.economy != null;
this.PLOT_PRICE = config.getDouble("economy.prices.claim");
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
this.SELL_PRICE = config.getDouble("economy.prices.sell");

View File

@ -1,5 +1,15 @@
package com.intellectualcrafters.plot.util;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.object.PlotPlayer;
public class EconHandler {
// TODO economy shit
public static double getBalance(PlotPlayer player) {
return PlotSquared.economy.getBalance(player.getName());
}
public static void withdrawPlayer(PlotPlayer player, double amount) {
EconHandler.withdrawPlayer(player.getName(), amount);
}
}

View File

@ -88,7 +88,7 @@ public class BukkitPlayerFunctions {
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost);
return false;
}
economy.withdrawPlayer(plr, cost);
EconHandler.withdrawPlayer(plr, cost);
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + "");
}
}