mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36: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;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(world);
|
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;
|
double cost = pWorld.PLOT_PRICE;
|
||||||
cost = (size_x * size_z) * cost;
|
cost = (size_x * size_z) * cost;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
final Economy economy = PlotSquared.economy;
|
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||||
if (economy.getBalance(plr.getName()) < cost) {
|
|
||||||
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
EconHandler.withdrawPlayer(plr, cost);
|
EconHandler.manager.withdrawMoney(plr, cost);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class Buy extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||||
if (PlotSquared.economy == null) {
|
if (EconHandler.manager == null) {
|
||||||
return sendMessage(plr, C.ECON_DISABLED);
|
return sendMessage(plr, C.ECON_DISABLED);
|
||||||
}
|
}
|
||||||
final Location loc = plr.getLocation();
|
final Location loc = plr.getLocation();
|
||||||
@ -93,13 +93,13 @@ 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 ((PlotSquared.economy != null) && (price > 0d)) {
|
if ((EconHandler.manager != null) && (price > 0d)) {
|
||||||
if (EconHandler.getBalance(plr) < price) {
|
if (EconHandler.manager.getMoney(plr) < price) {
|
||||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
|
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
|
||||||
}
|
}
|
||||||
EconHandler.withdrawPlayer(plr, price);
|
EconHandler.manager.withdrawMoney(plr, price);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, 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);
|
final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
|
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);
|
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||||
}
|
}
|
||||||
final PlotWorld world = PlotSquared.getPlotWorld(plot.world);
|
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;
|
final double cost = world.PLOT_PRICE;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
if (EconHandler.getBalance(plr) < cost) {
|
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||||
}
|
}
|
||||||
EconHandler.withdrawPlayer(plr, cost);
|
EconHandler.manager.withdrawMoney(plr, cost);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,10 @@ public class Delete extends SubCommand {
|
|||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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;
|
final double c = pWorld.SELL_PRICE;
|
||||||
if (c > 0d) {
|
if (c > 0d) {
|
||||||
EconHandler.depositPlayer(plr, c);
|
EconHandler.manager.depositMoney(plr, c);
|
||||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,15 +173,15 @@ public class Merge extends SubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
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;
|
double cost = plotWorld.MERGE_PRICE;
|
||||||
cost = plots.size() * cost;
|
cost = plots.size() * cost;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
if (EconHandler.getBalance(plr) < cost) {
|
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EconHandler.withdrawPlayer(plr, cost);
|
EconHandler.manager.withdrawMoney(plr, cost);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,15 +202,15 @@ public class Merge extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
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;
|
double cost = plotWorld.MERGE_PRICE;
|
||||||
cost = plots.size() * cost;
|
cost = plots.size() * cost;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
if (EconHandler.getBalance(plr) < cost) {
|
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
EconHandler.withdrawPlayer(plr, cost);
|
EconHandler.manager.withdrawMoney(plr, cost);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,10 @@ public class Unclaim extends SubCommand {
|
|||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world);
|
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;
|
final double c = pWorld.SELL_PRICE;
|
||||||
if (c > 0d) {
|
if (c > 0d) {
|
||||||
EconHandler.depositPlayer(plr, c);
|
EconHandler.manager.depositMoney(plr, c);
|
||||||
sendMessage(plr, C.ADDED_BALANCE, 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.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
@ -60,7 +61,7 @@ public class list extends SubCommand {
|
|||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||||
if (plr != null) {
|
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>"}));
|
builder.append(getArgumentList(new String[] { "mine", "shared", "world", "all", "unowned", "unknown", "forsale", "<player>", "<world>"}));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -161,7 +162,7 @@ public class list extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (PlotSquared.economy == null) {
|
if (EconHandler.manager == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
plots = new HashSet<>();
|
plots = new HashSet<>();
|
||||||
|
@ -4,9 +4,13 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
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.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@ -149,4 +153,25 @@ public class BukkitPlayer implements PlotPlayer {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return getName();
|
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.config.Settings;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jesse Boyd
|
* @author Jesse Boyd
|
||||||
@ -139,7 +140,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") && (PlotSquared.economy != null);
|
this.USE_ECONOMY = config.getBoolean("economy.use") && (EconHandler.manager != 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");
|
||||||
|
@ -67,6 +67,31 @@ public class MainUtil {
|
|||||||
return true;
|
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) {
|
public static boolean unlinkPlot(final Plot plot) {
|
||||||
final String world = plot.world;
|
final String world = plot.world;
|
||||||
final PlotId pos1 = MainUtil.getBottomPlot(plot).id;
|
final PlotId pos1 = MainUtil.getBottomPlot(plot).id;
|
||||||
|
@ -27,12 +27,14 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
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.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
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) {
|
public static String getPlayerName(final UUID uuid) {
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
|
Loading…
Reference in New Issue
Block a user