Compare commits

...

4 Commits

Author SHA1 Message Date
Nikolaos Grammatikos 98a4c346eb
prod: introducing version 2.12.6-SNAPSHOT 2023-07-30 20:42:17 +01:00
Nikolaos Grammatikos f1e114b400
chore: update maven-shade-plugin to 3.5.0 2023-07-30 20:41:36 +01:00
Nikolaos Grammatikos 3ac3445e2c
feat: log a warning if denomination's type is null [fixes #149 . #154] 2023-07-30 20:38:06 +01:00
Nikolaos Grammatikos 65586478a3
fix: line0 should not be converted to lower case [fixes #132] 2023-07-30 20:15:00 +01:00
3 changed files with 51 additions and 21 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>minecraftwars</groupId>
<artifactId>gringotts</artifactId>
<version>2.12.5</version>
<version>2.12.6-SNAPSHOT</version>
<properties>
<maven.deploy.skip>false</maven.deploy.skip>
@ -58,7 +58,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
<configuration>
<artifactSet>
<excludes>

View File

@ -186,9 +186,21 @@ public class AccountChest {
}
String[] lines = sign.getLines();
String line0 = lines[0].toLowerCase().trim();
String line0 = lines[0];
return !line0.matches(Configuration.CONF.vaultPattern) || lines[2] == null || lines[2].length() == 0 || chest() == null;
if (!line0.matches(Configuration.CONF.vaultPattern)) {
return true;
}
if (lines[2] == null) {
return true;
}
if (lines[2].isEmpty()) {
return true;
}
return chest() == null;
}
/**

View File

@ -2,7 +2,6 @@ package org.gestern.gringotts;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Tag;
import org.bukkit.block.ShulkerBox;
@ -206,26 +205,45 @@ public class GringottsAccount {
if (remaining == 0) {
return TransactionResult.SUCCESS;
} else {
if (Configuration.CONF.dropOverflowingItem) {
for (Denomination denomination : Configuration.CONF.getCurrency().getDenominations()) {
if (denomination.getValue() <= remaining) {
ItemStack stack = new ItemStack(denomination.getKey().type);
int stackSize = stack.getMaxStackSize();
long denItemCount = denomination.getValue() > 0 ? remaining / denomination.getValue() : 0;
while (denItemCount > 0) {
int remainderStackSize = denItemCount > stackSize ? stackSize : (int) denItemCount;
stack.setAmount(remainderStackSize);
denItemCount -= remainderStackSize;
remaining -= remainderStackSize * denomination.getValue();
playerOpt.get().getWorld().dropItem(playerOpt.get().getLocation(), stack);
}
}
if (Configuration.CONF.dropOverflowingItem && playerOpt.isPresent()) {
for (Denomination denomination : Configuration.CONF.getCurrency().getDenominations()) {
if (denomination.getValue() > remaining) {
continue;
}
// noinspection ConstantValue
if (denomination.getKey().type == null) {
Gringotts.instance.getLogger().warning("Denomination " + denomination.getUnitName() + " has no item type set!");
continue;
}
ItemStack stack = new ItemStack(denomination.getKey().type);
int stackSize = stack.getMaxStackSize();
long denItemCount = denomination.getValue() > 0 ? remaining / denomination.getValue() : 0;
while (denItemCount > 0) {
int remainderStackSize;
if (denItemCount > stackSize) {
remainderStackSize = stackSize;
} else {
remainderStackSize = (int) denItemCount;
}
stack.setAmount(remainderStackSize);
denItemCount -= remainderStackSize;
remaining -= remainderStackSize * denomination.getValue();
playerOpt.get().getWorld().dropItem(playerOpt.get().getLocation(), stack);
}
}
return TransactionResult.INSUFFICIENT_SPACE;
}
return TransactionResult.INSUFFICIENT_SPACE;
};
return getTimeout(callSync(callMe));