mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-24 15:51:23 +01:00
Merge branch '1.12' into 1.13
This commit is contained in:
commit
f1ce97dbce
@ -68,6 +68,9 @@ public class Properties {
|
||||
@ConfigurationComment("How much money do you get back when destroying a sign?")
|
||||
public static double SHOP_REFUND_PRICE = 0;
|
||||
|
||||
@ConfigurationComment("How many decimal places are allowed at a maximum for prices?")
|
||||
public static int PRICE_PRECISION = 2;
|
||||
|
||||
@PrecededBySpace
|
||||
@ConfigurationComment("Should we block shops that sell things for more than they buy? (This prevents newbies from creating shops that would be exploited)")
|
||||
public static boolean BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE = true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
|
||||
|
||||
import com.Acrobot.Breeze.Utils.PriceUtil;
|
||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -18,7 +19,13 @@ public class PriceChecker implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public static void onPreShopCreation(PreShopCreationEvent event) {
|
||||
String line = event.getSignLine(PRICE_LINE).toUpperCase();
|
||||
line = line.replaceAll("(\\.\\d*?[1-9])0+", "$1"); //remove trailing zeroes
|
||||
if (Properties.PRICE_PRECISION <= 0) {
|
||||
line = line.replaceAll("\\.\\d*", ""); //remove too many decimal places
|
||||
} else {
|
||||
line = line.replaceAll("(\\.\\d{0," + Properties.PRICE_PRECISION + "})\\d*", "$1"); //remove too many decimal places
|
||||
}
|
||||
line = line.replaceAll("(\\.\\d*[1-9])0+", "$1"); //remove trailing zeroes
|
||||
line = line.replaceAll("(\\d)\\.0+(\\D|$)", "$1$2"); //remove point and zeroes from strings that only have trailing zeros
|
||||
|
||||
String[] part = line.split(":");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user