mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Fixed errors
This commit is contained in:
parent
ea669b7697
commit
ffbc2f9611
@ -130,16 +130,15 @@ public class Auto extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(world);
|
||||
if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY) {
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) {
|
||||
double cost = pWorld.PLOT_PRICE;
|
||||
cost = (size_x * size_z) * cost;
|
||||
if (cost > 0d) {
|
||||
final Economy economy = PlotSquared.economy;
|
||||
if (economy.getBalance(plr.getName()) < cost) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
return true;
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr, cost);
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class Buy extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (PlotSquared.economy == null) {
|
||||
if (EconHandler.manager == null) {
|
||||
return sendMessage(plr, C.ECON_DISABLED);
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
@ -93,13 +93,13 @@ public class Buy extends SubCommand {
|
||||
price += plotworld.PLOT_PRICE * size;
|
||||
initPrice += plotworld.SELL_PRICE * size;
|
||||
}
|
||||
if ((PlotSquared.economy != null) && (price > 0d)) {
|
||||
if (EconHandler.getBalance(plr) < price) {
|
||||
if ((EconHandler.manager != null) && (price > 0d)) {
|
||||
if (EconHandler.manager.getMoney(plr) < price) {
|
||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr, price);
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
||||
EconHandler.manager.depositMoney(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
||||
final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||
if (owner != null) {
|
||||
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
|
||||
|
@ -98,13 +98,13 @@ public class Claim extends SubCommand {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
final PlotWorld world = PlotSquared.getPlotWorld(plot.world);
|
||||
if ((PlotSquared.economy != null) && world.USE_ECONOMY) {
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
final double cost = world.PLOT_PRICE;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.getBalance(plr) < cost) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr, cost);
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ public class Delete extends SubCommand {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.isOwner(UUIDHandler.getUUID(plr))) {
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.isOwner(UUIDHandler.getUUID(plr))) {
|
||||
final double c = pWorld.SELL_PRICE;
|
||||
if (c > 0d) {
|
||||
EconHandler.depositPlayer(plr, c);
|
||||
EconHandler.manager.depositMoney(plr, c);
|
||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||
}
|
||||
}
|
||||
|
@ -173,15 +173,15 @@ public class Merge extends SubCommand {
|
||||
return;
|
||||
}
|
||||
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
||||
if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) {
|
||||
if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
|
||||
double cost = plotWorld.MERGE_PRICE;
|
||||
cost = plots.size() * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.getBalance(plr) < cost) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||
return;
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr, cost);
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
@ -202,15 +202,15 @@ public class Merge extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
||||
if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) {
|
||||
if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
|
||||
double cost = plotWorld.MERGE_PRICE;
|
||||
cost = plots.size() * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.getBalance(plr) < cost) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||
return false;
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr, cost);
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ public class Unclaim extends SubCommand {
|
||||
}
|
||||
assert plot != null;
|
||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world);
|
||||
if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY) {
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) {
|
||||
final double c = pWorld.SELL_PRICE;
|
||||
if (c > 0d) {
|
||||
EconHandler.depositPlayer(plr, c);
|
||||
EconHandler.manager.depositMoney(plr, c);
|
||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
@ -60,7 +61,7 @@ public class list extends SubCommand {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||
if (plr != null) {
|
||||
if (PlotSquared.economy != null) {
|
||||
if (EconHandler.manager != null) {
|
||||
builder.append(getArgumentList(new String[] { "mine", "shared", "world", "all", "unowned", "unknown", "forsale", "<player>", "<world>"}));
|
||||
}
|
||||
else {
|
||||
@ -161,7 +162,7 @@ public class list extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
||||
return false;
|
||||
}
|
||||
if (PlotSquared.economy == null) {
|
||||
if (EconHandler.manager == null) {
|
||||
break;
|
||||
}
|
||||
plots = new HashSet<>();
|
||||
|
@ -4,9 +4,13 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -149,4 +153,25 @@ public class BukkitPlayer implements PlotPlayer {
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key) {
|
||||
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
|
||||
if (perm == null) {
|
||||
perm = new Permission(key, PermissionDefault.FALSE);
|
||||
Bukkit.getServer().getPluginManager().addPermission(perm);
|
||||
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
||||
}
|
||||
EconHandler.manager.setPermission(this, key, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAttribute(String key) {
|
||||
return player.hasPermission(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String key) {
|
||||
EconHandler.manager.setPermission(this, key, false);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
|
||||
/**
|
||||
* @author Jesse Boyd
|
||||
@ -139,7 +140,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") && (PlotSquared.economy != null);
|
||||
this.USE_ECONOMY = config.getBoolean("economy.use") && (EconHandler.manager != 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");
|
||||
|
@ -67,6 +67,31 @@ public class MainUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges all plots in the arraylist (with cost)
|
||||
*
|
||||
* @param plr
|
||||
* @param world
|
||||
* @param plotIds
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean mergePlots(final PlotPlayer player, final String world, final ArrayList<PlotId> plotIds) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
|
||||
final double cost = plotIds.size() * plotworld.MERGE_PRICE;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
MainUtil.sendMessage(player, C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||
return false;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(player, cost);
|
||||
MainUtil.sendMessage(player, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
return MainUtil.mergePlots(world, plotIds, true);
|
||||
}
|
||||
|
||||
public static boolean unlinkPlot(final Plot plot) {
|
||||
final String world = plot.world;
|
||||
final PlotId pos1 = MainUtil.getBottomPlot(plot).id;
|
||||
|
@ -27,12 +27,14 @@ import java.util.UUID;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
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;
|
||||
@ -69,32 +71,6 @@ public class BukkitPlayerFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges all plots in the arraylist (with cost)
|
||||
*
|
||||
* @param plr
|
||||
* @param world
|
||||
* @param plotIds
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean mergePlots(final Player plr, final String world, final ArrayList<PlotId> plotIds) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) {
|
||||
final double cost = plotIds.size() * plotworld.MERGE_PRICE;
|
||||
if (cost > 0d) {
|
||||
final Economy economy = PlotSquared.economy;
|
||||
if (economy.getBalance(plr) < cost) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||
return false;
|
||||
}
|
||||
EconHandler.withdrawPlayer(BukkitUtil.getPlayer(plr), cost);
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
return MainUtil.mergePlots(world, plotIds, true);
|
||||
}
|
||||
|
||||
public static String getPlayerName(final UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return "unknown";
|
||||
|
Loading…
Reference in New Issue
Block a user