This commit is contained in:
MattBDev
2016-07-16 22:51:49 -04:00
parent 8b0e59209c
commit 8538170cba
17 changed files with 268 additions and 554 deletions

View File

@ -0,0 +1,9 @@
package com.intellectualcrafters.plot;
public enum Platform {
Bukkit,
Sponge,
Spigot,
Cauldron
}

View File

@ -118,7 +118,7 @@ public class Auto extends SubCommand {
}
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
Expression<Double> costExp = plotarea.PRICES.get("claim");
double cost = costExp.evalute((double) currentPlots);
double cost = costExp.evaluate((double) currentPlots);
cost = (size_x * size_z) * cost;
if (cost > 0d) {
if (EconHandler.manager.getMoney(player) < cost) {

View File

@ -50,7 +50,7 @@ public class Claim extends SubCommand {
PlotArea world = plot.getArea();
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
Expression<Double> costExr = world.PRICES.get("claim");
double cost = costExr.evalute((double) currentPlots);
double cost = costExr.evaluate((double) currentPlots);
if (cost > 0d) {
if (EconHandler.manager.getMoney(player) < cost) {
return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);

View File

@ -56,7 +56,7 @@ public class Delete extends SubCommand {
plot.removeRunning();
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
Expression<Double> valueExr = plotArea.PRICES.get("sell");
double value = plots.size() * valueExr.evalute((double) currentPlots);
double value = plots.size() * valueExr.evaluate((double) currentPlots);
if (value > 0d) {
EconHandler.manager.depositMoney(player, value);
sendMessage(player, C.ADDED_BALANCE, String.valueOf(value));

View File

@ -141,7 +141,7 @@ public class MainCommand extends Command {
PlotArea area = player.getApplicablePlotArea();
if (area != null) {
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evalute(0d) : 0d;
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != null && EconHandler.manager.getMoney(player) < price) {
if (failure != null) {
failure.run();
@ -161,7 +161,7 @@ public class MainCommand extends Command {
PlotArea area = player.getApplicablePlotArea();
if (area != null) {
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evalute(0d) : 0d;
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d && EconHandler.manager.getMoney(player) < price) {
if (failure != null) {
failure.run();

View File

@ -74,7 +74,7 @@ public class Merge extends SubCommand {
final PlotArea plotArea = plot.getArea();
Expression<Double> priceExr = plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : null;
final int size = plot.getConnectedPlots().size();
final double price = priceExr == null ? 0d : priceExr.evalute((double) size);
final double price = priceExr == null ? 0d : priceExr.evaluate((double) size);
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(player) < price) {
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
return false;

View File

@ -75,7 +75,7 @@ public enum C {
*/
CONSOLE_JAVA_OUTDATED_1_8("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance "
+ "and security. PlotSquared will require Java 9 in a future update.", "static.console"),
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stabability, performance, and features. "
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stability, performance, and features. "
+ "Bug fixes and new features are influenced on metrics.", "static.console"),
/*
* Confirm
@ -368,7 +368,7 @@ public enum C {
/*
* Unknown Error
*/
ERROR("$2An error occured: %s", "Errors"),
ERROR("$2An error occurred: %s", "Errors"),
// SETTINGS_PASTE_UPLOADED("$2settings.yml was uploaded to: $1%url%", "Paste"),
// LATEST_LOG_UPLOADED("$2latest.log was uploaded to: $1%url%", "Paste"),
DEBUG_REPORT_CREATED("$1Uploaded a full debug to: $1%url%", "Paste"),

View File

@ -296,7 +296,7 @@ public class Settings extends Config {
public static boolean WORLDEDIT_RESTRICTIONS = true;
@Comment("Allow economy to be used")
public static boolean ECONOMY = true;
@Comment("Send anonymous usage statistics")
@Comment("Send anonymous usage statistics. Bukkit only setting.")
public static boolean METRICS = true;
@Comment("Expiry will clear old or simplistic plots")
public static boolean PLOT_EXPIRY = false;

View File

@ -6,12 +6,12 @@ import com.intellectualcrafters.plot.commands.MainCommand;
import javax.script.ScriptException;
public abstract class Expression<T> {
public abstract T evalute(T arg);
public abstract T evaluate(T arg);
public static <U> Expression<U> constant(final U value) {
return new Expression<U>() {
@Override
public U evalute(U arg) {
public U evaluate(U arg) {
return value;
}
};
@ -20,8 +20,8 @@ public abstract class Expression<T> {
public static Expression<Double> linearDouble(final Double value) {
return new Expression<Double>() {
@Override
public Double evalute(Double arg) {
return (arg.doubleValue() * value.doubleValue());
public Double evaluate(Double arg) {
return (arg * value);
}
};
}
@ -29,15 +29,15 @@ public abstract class Expression<T> {
public static Expression<Double> doubleExpression(final String expression) {
try {
return constant(Double.parseDouble(expression));
} catch (Exception ignore) {}
} catch (NumberFormatException ignore) {}
if (expression.endsWith("*{arg}")) {
try {
return linearDouble(Double.parseDouble(expression.substring(0, expression.length() - 6)));
} catch (Exception ignore) {}
} catch (NumberFormatException ignore) {}
}
return new Expression<Double>() {
@Override
public Double evalute(Double arg) {
public Double evaluate(Double arg) {
DebugExec exec = (DebugExec) MainCommand.getInstance().getCommand(DebugExec.class);
try {
return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg));