mirror of
https://github.com/md5sha256/AreaShop.git
synced 2026-11-07 01:42:34 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
832d8967a3 | ||
|
|
c369d23f74 | ||
|
|
b50d57739f | ||
|
|
ce9438eaeb | ||
|
|
47cc259c40 |
No files matched your search
@@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
description = 'AreaShop'
|
||||
version = '2.6.3'
|
||||
version = '2.6.5'
|
||||
|
||||
dependencies {
|
||||
// Spigot api
|
||||
|
||||
@@ -648,7 +648,8 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
|
||||
if (!matcher0.find()) {
|
||||
matcher0 = VERSION_MATCHER_2.matcher(latestVersion);
|
||||
if (!matcher0.find()) {
|
||||
throw new IllegalArgumentException("Invalid Versions Detected!");
|
||||
// FIXME log invalid version
|
||||
return false;
|
||||
}
|
||||
dual0 = true;
|
||||
}
|
||||
@@ -657,7 +658,8 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
|
||||
if (!matcher1.find()) {
|
||||
matcher1 = VERSION_MATCHER_2.matcher(currentVersion);
|
||||
if (!matcher1.find()) {
|
||||
throw new IllegalArgumentException("Invalid Versions Detected!");
|
||||
// FIXME log invalid version
|
||||
return false;
|
||||
}
|
||||
dual1 = true;
|
||||
}
|
||||
|
||||
@@ -152,17 +152,17 @@ public class SignsFeature extends RegionFeature {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSignBreak(BlockBreakEvent event) {
|
||||
if (getRegion().invalidated()) {
|
||||
Block block = event.getBlock();
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
// Check if it is a sign
|
||||
if (Materials.isSign(block.getType())) {
|
||||
// Check if the rent sign is really the same as a saved rent
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region object is still active!");
|
||||
}
|
||||
@@ -179,13 +179,6 @@ public class SignsFeature extends RegionFeature {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onIndirectSignBreak(BlockPhysicsEvent event) {
|
||||
if (getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
// Check if the block is a sign
|
||||
if (!Materials.isSign(event.getBlock().getType())) {
|
||||
return;
|
||||
}
|
||||
final Block block = event.getBlock();
|
||||
|
||||
// Check if the sign is really the same as a saved rent
|
||||
@@ -193,6 +186,14 @@ public class SignsFeature extends RegionFeature {
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
// Check if the block is a sign
|
||||
if (!Materials.isSign(event.getBlock().getType())) {
|
||||
return;
|
||||
}
|
||||
// If the block is in an invalid position then we remove the sign
|
||||
if (!behaviourHelper.isBlockValid(block)) {
|
||||
regionSign.remove();
|
||||
@@ -206,13 +207,19 @@ public class SignsFeature extends RegionFeature {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSignClick(PlayerInteractEvent event) {
|
||||
if (getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
// Check if this sign belongs to a region
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
|
||||
// Only listen to left and right clicks on blocks
|
||||
if (!(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
|
||||
@@ -224,11 +231,6 @@ public class SignsFeature extends RegionFeature {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this sign belongs to a region
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore players that are in sign link mode (which will handle the event itself)
|
||||
Player player = event.getPlayer();
|
||||
@@ -256,7 +258,13 @@ public class SignsFeature extends RegionFeature {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
if (getRegion().invalidated()) {
|
||||
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(event.getBlock().getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@@ -120,7 +120,7 @@ public class GithubUpdateCheck {
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
debug("json: " + latestRelease.getAsString());
|
||||
debug("json: " + latestRelease.toString());
|
||||
|
||||
// Latest version
|
||||
latestVersion = latestRelease.get("tag_name").getAsString();
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
/**
|
||||
* Parse math from a string
|
||||
* Adapted from:
|
||||
* https://stackoverflow.com/questions/3422673/how-to-evaluate-a-math-expression-given-in-string-form
|
||||
*/
|
||||
public final class OperandParser {
|
||||
|
||||
private final String str;
|
||||
|
||||
private OperandParser(final String str) {
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
public static double parse(final String str) throws ParseException {
|
||||
return new OperandParser(str).parse();
|
||||
}
|
||||
|
||||
|
||||
private int pos = -1, ch;
|
||||
|
||||
private void nextChar() {
|
||||
ch = (++pos < str.length()) ? str.charAt(pos) : -1;
|
||||
}
|
||||
|
||||
private boolean eat(int charToEat) {
|
||||
while (ch == ' ') nextChar();
|
||||
if (ch == charToEat) {
|
||||
nextChar();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private double parse() throws ParseException {
|
||||
nextChar();
|
||||
double x = parseExpression();
|
||||
if (pos < str.length())
|
||||
{
|
||||
throw new ParseException("Unexpected: " + (char) ch);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
// Grammar:
|
||||
// expression = term | expression `+` term | expression `-` term
|
||||
// term = factor | term `*` factor | term `/` factor
|
||||
// factor = `+` factor | `-` factor | `(` expression `)`
|
||||
// | number | functionName factor | factor `^` factor
|
||||
|
||||
private double parseExpression() throws ParseException {
|
||||
double x = parseTerm();
|
||||
for (; ; ) {
|
||||
if (eat('+')) {
|
||||
// addition
|
||||
x += parseTerm();
|
||||
}
|
||||
else if (eat('-')) {
|
||||
// subtraction
|
||||
x -= parseTerm();
|
||||
}
|
||||
else return x;
|
||||
}
|
||||
}
|
||||
|
||||
private double parseTerm() throws ParseException {
|
||||
double x = parseFactor();
|
||||
for (; ; ) {
|
||||
if (eat('*')) {
|
||||
// multiplication
|
||||
x *= parseFactor();
|
||||
}
|
||||
else if (eat('/')) {
|
||||
// division
|
||||
x /= parseFactor();
|
||||
}
|
||||
else return x;
|
||||
}
|
||||
}
|
||||
|
||||
private double parseFactor() throws ParseException {
|
||||
if (eat('+')) {
|
||||
// unary plus
|
||||
return parseFactor();
|
||||
}
|
||||
if (eat('-')) {
|
||||
// unary minus
|
||||
return -parseFactor();
|
||||
}
|
||||
|
||||
double x;
|
||||
int startPos = this.pos;
|
||||
if (eat('(')) {
|
||||
// parentheses
|
||||
x = parseExpression();
|
||||
eat(')');
|
||||
} else if ((ch >= '0' && ch <= '9') || ch == '.') {
|
||||
// numbers
|
||||
while ((ch >= '0' && ch <= '9') || ch == '.') {
|
||||
nextChar();
|
||||
}
|
||||
x = Double.parseDouble(str.substring(startPos, this.pos));
|
||||
} else if (ch >= 'a' && ch <= 'z') {
|
||||
// functions
|
||||
while (ch >= 'a' && ch <= 'z') {
|
||||
nextChar();
|
||||
}
|
||||
String func = str.substring(startPos, this.pos);
|
||||
x = parseFactor();
|
||||
x = switch (func) {
|
||||
case "sqrt" -> Math.sqrt(x);
|
||||
case "sin" -> Math.sin(Math.toRadians(x));
|
||||
case "cos" -> Math.cos(Math.toRadians(x));
|
||||
case "tan" -> Math.tan(Math.toRadians(x));
|
||||
default -> throw new ParseException("Unknown function: " + func);
|
||||
};
|
||||
} else {
|
||||
throw new ParseException("Unexpected: " + (char) ch);
|
||||
}
|
||||
|
||||
if (eat('^')) {
|
||||
// exponentiation
|
||||
x = Math.pow(x, parseFactor());
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
public static class ParseException extends Exception {
|
||||
|
||||
public ParseException() {
|
||||
}
|
||||
|
||||
public ParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ParseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ParseException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ParseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,10 @@ import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.interactivemessenger.Log;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -22,10 +25,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
@@ -46,7 +45,6 @@ public class Utils {
|
||||
private static Set<String> weeks;
|
||||
private static Set<String> months;
|
||||
private static Set<String> years;
|
||||
private static ScriptEngine scriptEngine;
|
||||
private static Map<Double, String> suffixes;
|
||||
|
||||
// Not used
|
||||
@@ -768,16 +766,11 @@ public class Utils {
|
||||
return Double.parseDouble(input);
|
||||
}
|
||||
|
||||
// Lazy init scriptEngine
|
||||
if (scriptEngine == null) {
|
||||
scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
}
|
||||
|
||||
// Evaluate expression
|
||||
Object result;
|
||||
try {
|
||||
result = scriptEngine.eval(input);
|
||||
} catch (ScriptException e) {
|
||||
result = OperandParser.parse(input);
|
||||
} catch (OperandParser.ParseException e) {
|
||||
AreaShop.warn("Price of region", region.getName(), "is set with an invalid expression: '" + input + "', exception:", ExceptionUtils.getStackTrace(e));
|
||||
return 99999999999.0; // High fallback for safety
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "me.wiefferink.areashop"
|
||||
version = '2.6.3'
|
||||
version = '2.6.5'
|
||||
|
||||
subprojects {
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compileOnly project(':areashop-interface')
|
||||
compileOnly('org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT')
|
||||
compileOnly("com.fastasyncworldedit:FAWE-Core:1.17-5")
|
||||
compileOnly("com.fastasyncworldedit:FAWE-Bukkit:1.17-5")
|
||||
compileOnly('org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT')
|
||||
compileOnly("com.fastasyncworldedit:FAWE-Core:1.17-138")
|
||||
compileOnly("com.fastasyncworldedit:FAWE-Bukkit:1.17-138")
|
||||
compileOnly('com.sk89q.worldguard:worldguard-bukkit:7.0.5')
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,9 +1,10 @@
|
||||
package me.wiefferink.areashop.handlers.fawe.v1_17;
|
||||
|
||||
import com.fastasyncworldedit.core.FaweAPI;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.MemoryOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
|
||||
import com.fastasyncworldedit.core.object.FaweLimit;
|
||||
import com.fastasyncworldedit.core.object.RelightMode;
|
||||
import com.fastasyncworldedit.core.object.clipboard.MemoryOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.util.EditSessionBuilder;
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
|
||||
@@ -4,5 +4,5 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compileOnly project(':areashop-interface')
|
||||
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
|
||||
compileOnly 'org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT'
|
||||
}
|
||||
Reference in new issue
Block a user