mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
econ
This commit is contained in:
parent
1eb0ba47b4
commit
406ae58391
@ -381,6 +381,7 @@ public class PlotSquared {
|
|||||||
THIS = this;
|
THIS = this;
|
||||||
IMP = imp_class;
|
IMP = imp_class;
|
||||||
VERSION = IMP.getVersion();
|
VERSION = IMP.getVersion();
|
||||||
|
economy = IMP.getEconomy();
|
||||||
C.setupTranslations();
|
C.setupTranslations();
|
||||||
C.saveTranslations();
|
C.saveTranslations();
|
||||||
if (getJavaVersion() < 1.7) {
|
if (getJavaVersion() < 1.7) {
|
||||||
@ -428,7 +429,6 @@ public class PlotSquared {
|
|||||||
if (Settings.AUTO_CLEAR) {
|
if (Settings.AUTO_CLEAR) {
|
||||||
ExpireManager.runTask();
|
ExpireManager.runTask();
|
||||||
}
|
}
|
||||||
economy = IMP.getEconomy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
|
@ -138,7 +138,7 @@ public class Auto extends SubCommand {
|
|||||||
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
economy.withdrawPlayer(plr.getName(), cost);
|
EconHandler.withdrawPlayer(plr.getName(), cost);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
@ -92,12 +93,12 @@ public class Buy extends SubCommand {
|
|||||||
price += plotworld.PLOT_PRICE * size;
|
price += plotworld.PLOT_PRICE * size;
|
||||||
initPrice += plotworld.SELL_PRICE * size;
|
initPrice += plotworld.SELL_PRICE * size;
|
||||||
}
|
}
|
||||||
if (price > 0d) {
|
if (PlotSquared.economy != null && price > 0d) {
|
||||||
final Economy economy = PlotSquared.economy;
|
final Economy economy = PlotSquared.economy;
|
||||||
if (economy.getBalance(plr) < price) {
|
if (EconHandler.getBalance(plr) < price) {
|
||||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
|
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
|
||||||
}
|
}
|
||||||
economy.withdrawPlayer(plr, price);
|
EconHandler.withdrawPlayer(plr, price);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||||
economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
||||||
final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
|
final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
|
||||||
|
@ -104,7 +104,7 @@ public class Claim extends SubCommand {
|
|||||||
if (economy.getBalance(plr) < cost) {
|
if (economy.getBalance(plr) < cost) {
|
||||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||||
}
|
}
|
||||||
economy.withdrawPlayer(plr, cost);
|
EconHandler.withdrawPlayer(plr, cost);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class Merge extends SubCommand {
|
|||||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
economy.withdrawPlayer(plr, cost);
|
EconHandler.withdrawPlayer(plr, cost);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public abstract class PlotWorld {
|
|||||||
this.SCHEMATIC_FILE = config.getString("schematic.file");
|
this.SCHEMATIC_FILE = config.getString("schematic.file");
|
||||||
this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
|
this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
|
||||||
this.SCHEMATICS = config.getStringList("schematic.schematics");
|
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.PLOT_PRICE = config.getDouble("economy.prices.claim");
|
||||||
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
||||||
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
|
||||||
public class EconHandler {
|
public class EconHandler {
|
||||||
// TODO economy shit
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class BukkitPlayerFunctions {
|
|||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost);
|
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
economy.withdrawPlayer(plr, cost);
|
EconHandler.withdrawPlayer(plr, cost);
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + "");
|
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user