mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Fixed issue when shop limit by permission is smaller than default
This commit is contained in:
parent
73f5d0f79e
commit
98c79f5e8a
@ -118,12 +118,14 @@ public class ShopUtils {
|
|||||||
* @return The shop limits of the given player
|
* @return The shop limits of the given player
|
||||||
*/
|
*/
|
||||||
public int getShopLimit(Player p) {
|
public int getShopLimit(Player p) {
|
||||||
int limit = plugin.getShopChestConfig().default_limit;
|
int limit = 0;
|
||||||
|
boolean useDefault = true;
|
||||||
|
|
||||||
for (PermissionAttachmentInfo permInfo : p.getEffectivePermissions()) {
|
for (PermissionAttachmentInfo permInfo : p.getEffectivePermissions()) {
|
||||||
if (permInfo.getPermission().startsWith("shopchest.limit.")) {
|
if (permInfo.getPermission().startsWith("shopchest.limit.")) {
|
||||||
if (permInfo.getPermission().equalsIgnoreCase(Permissions.NO_LIMIT)) {
|
if (permInfo.getPermission().equalsIgnoreCase(Permissions.NO_LIMIT)) {
|
||||||
limit = -1;
|
limit = -1;
|
||||||
|
useDefault = false;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
String[] spl = permInfo.getPermission().split("shopchest.limit.");
|
String[] spl = permInfo.getPermission().split("shopchest.limit.");
|
||||||
@ -131,7 +133,14 @@ public class ShopUtils {
|
|||||||
if (spl.length > 1) {
|
if (spl.length > 1) {
|
||||||
try {
|
try {
|
||||||
int newLimit = Integer.valueOf(spl[1]);
|
int newLimit = Integer.valueOf(spl[1]);
|
||||||
|
|
||||||
|
if (newLimit < 0) {
|
||||||
|
limit = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
limit = Math.max(limit, newLimit);
|
limit = Math.max(limit, newLimit);
|
||||||
|
useDefault = false;
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
/* Ignore and continue */
|
/* Ignore and continue */
|
||||||
}
|
}
|
||||||
@ -141,7 +150,7 @@ public class ShopUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (limit < -1) limit = -1;
|
if (limit < -1) limit = -1;
|
||||||
return limit;
|
return (useDefault ? plugin.getShopChestConfig().default_limit : limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user