mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Various
Progress on #929 Fix area loading from config with negative ids @skroob
This commit is contained in:
parent
b95fdeccca
commit
00c174fdf1
@ -1519,7 +1519,7 @@ public class PS {
|
||||
}
|
||||
for (String areaId : areasSection.getKeys(false)) {
|
||||
log(C.PREFIX.s() + "&3 - " + areaId);
|
||||
String[] split = areaId.split("-");
|
||||
String[] split = areaId.split("(?<![;])-");
|
||||
if (split.length != 3) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
}
|
||||
if ((EconHandler.manager != null) && plotarea.USE_ECONOMY) {
|
||||
double cost = plotarea.PLOT_PRICE;
|
||||
double cost = plotarea.PRICES.get("claim");
|
||||
cost = (size_x * size_z) * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
|
@ -109,7 +109,7 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
final PlotArea world = plot.getArea();
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
final double cost = world.PLOT_PRICE;
|
||||
final double cost = world.PRICES.get("claim");
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
|
@ -74,7 +74,7 @@ public class Delete extends SubCommand {
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
|
||||
final double value = plotworld.SELL_PRICE * plots.size();
|
||||
final double value = plotworld.PRICES.get("sell") * plots.size();
|
||||
if (value > 0d) {
|
||||
EconHandler.manager.depositMoney(plr, value);
|
||||
sendMessage(plr, C.ADDED_BALANCE, value + "");
|
||||
|
@ -88,9 +88,10 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
}
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d
|
||||
&& EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
|
||||
final double price = plotworld.PRICES.get("merge");
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d
|
||||
&& EconHandler.manager.getMoney(plr) < price) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + "");
|
||||
return false;
|
||||
}
|
||||
final int size = plot.getConnectedPlots().size();
|
||||
@ -122,9 +123,9 @@ public class Merge extends SubCommand {
|
||||
terrain = "true".equalsIgnoreCase(args[1]);
|
||||
}
|
||||
if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||
if (EconHandler.manager != null && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
@ -152,9 +153,9 @@ public class Merge extends SubCommand {
|
||||
terrain = Settings.MERGE_REMOVES_ROADS;
|
||||
}
|
||||
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
@ -187,13 +188,13 @@ public class Merge extends SubCommand {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < price) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + "");
|
||||
return;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
}
|
||||
|
@ -1595,7 +1595,7 @@ public class SQLManager implements AbstractDB {
|
||||
ConfigurationSection areaSection = worldSection.getConfigurationSection(worldKey + ".areas");
|
||||
if (areaSection != null) {
|
||||
for (String areaKey : areaSection.getKeys(false)) {
|
||||
String[] split = areaKey.split("-");
|
||||
String[] split = areaKey.split("(?<![;])-");
|
||||
if (split.length == 3) {
|
||||
areas.add(worldKey + ";" + split[0]);
|
||||
}
|
||||
@ -2473,7 +2473,7 @@ public class SQLManager implements AbstractDB {
|
||||
ConfigurationSection areaSection = worldSection.getConfigurationSection(worldKey + ".areas");
|
||||
if (areaSection != null) {
|
||||
for (String areaKey : areaSection.getKeys(false)) {
|
||||
String[] split = areaKey.split("-");
|
||||
String[] split = areaKey.split("(?<![;])-");
|
||||
if (split.length == 3) {
|
||||
areas.add(worldKey + ";" + split[0]);
|
||||
}
|
||||
|
@ -63,9 +63,7 @@ public abstract class PlotArea {
|
||||
public List<String> SCHEMATICS = null;
|
||||
public HashMap<String, Flag> DEFAULT_FLAGS;
|
||||
public boolean USE_ECONOMY = false;
|
||||
public double PLOT_PRICE = 100;
|
||||
public double MERGE_PRICE = 100;
|
||||
public double SELL_PRICE = 100;
|
||||
public HashMap<String, Double> PRICES = new HashMap<>();
|
||||
public boolean SPAWN_EGGS = false;
|
||||
public boolean SPAWN_CUSTOM = true;
|
||||
public boolean SPAWN_BREEDING = false;
|
||||
@ -209,9 +207,10 @@ public abstract class PlotArea {
|
||||
SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
|
||||
SCHEMATICS = config.getStringList("schematic.schematics");
|
||||
USE_ECONOMY = config.getBoolean("economy.use") && EconHandler.manager != null;
|
||||
PLOT_PRICE = config.getDouble("economy.prices.claim");
|
||||
MERGE_PRICE = config.getDouble("economy.prices.merge");
|
||||
SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
|
||||
for (String key : priceSection.getKeys(false)) {
|
||||
PRICES.put(key, priceSection.getDouble(key));
|
||||
}
|
||||
PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||
WORLD_BORDER = config.getBoolean("world.border");
|
||||
MAX_BUILD_HEIGHT = config.getInt("world.max_height");
|
||||
@ -303,9 +302,9 @@ public abstract class PlotArea {
|
||||
options.put("schematic.specify_on_claim", SCHEMATIC_CLAIM_SPECIFY);
|
||||
options.put("schematic.schematics", SCHEMATICS);
|
||||
options.put("economy.use", USE_ECONOMY);
|
||||
options.put("economy.prices.claim", PLOT_PRICE);
|
||||
options.put("economy.prices.merge", MERGE_PRICE);
|
||||
options.put("economy.prices.sell", SELL_PRICE);
|
||||
options.put("economy.prices.claim", 100);
|
||||
options.put("economy.prices.merge", 100);
|
||||
options.put("economy.prices.sell", 100);
|
||||
options.put("chat.enabled", PLOT_CHAT);
|
||||
options.put("flags.default", null);
|
||||
options.put("event.spawn.egg", SPAWN_EGGS);
|
||||
@ -700,7 +699,7 @@ public abstract class PlotArea {
|
||||
|
||||
public boolean mergePlots(final PlotPlayer player, final ArrayList<PlotId> plotIds) {
|
||||
if (EconHandler.manager != null && USE_ECONOMY) {
|
||||
final double cost = plotIds.size() * MERGE_PRICE;
|
||||
final double cost = plotIds.size() * PRICES.getOrDefault("merge", 0d);
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
MainUtil.sendMessage(player, C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user