Skip to content

Commit 339da07

Browse files
authored
Merge pull request #476 from UnicacityAddon/bugfix/numberformatexception-in-medic-storage-message
bugfix/numberformatexception-in-medic-storage-message
2 parents b2ba492 + 3569ad4 commit 339da07

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/main/java/de/rettichlp/ucutils/listener/impl/faction/MedicListener.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.regex.Matcher;
1515
import java.util.regex.Pattern;
1616

17+
import static de.rettichlp.ucutils.UCUtils.LOGGER;
1718
import static de.rettichlp.ucutils.UCUtils.commandService;
1819
import static de.rettichlp.ucutils.UCUtils.player;
1920
import static de.rettichlp.ucutils.UCUtils.storage;
@@ -102,9 +103,19 @@ public boolean onMessageReceive(Component text, String message) {
102103
Matcher storageIngredientShareMatcher = STORAGE_INGREDIENT_SHARE_PATTERN.matcher(message);
103104
if (storageIngredientShareMatcher.find()) {
104105
String playerName = storageIngredientShareMatcher.group("playerName");
105-
int ingredient1 = parseInt(storageIngredientShareMatcher.group("ingredient1"));
106-
int ingredient2 = parseInt(storageIngredientShareMatcher.group("ingredient2"));
107-
int ingredient3 = parseInt(storageIngredientShareMatcher.group("ingredient3"));
106+
107+
int ingredient1;
108+
int ingredient2;
109+
int ingredient3;
110+
111+
try {
112+
ingredient1 = parseInt(storageIngredientShareMatcher.group("ingredient1"));
113+
ingredient2 = parseInt(storageIngredientShareMatcher.group("ingredient2"));
114+
ingredient3 = parseInt(storageIngredientShareMatcher.group("ingredient3"));
115+
} catch (NumberFormatException e) {
116+
LOGGER.warn("Could not parse ingredient amounts from message: {}", message);
117+
return true;
118+
}
108119

109120
player.sendSystemMessage(empty());
110121

0 commit comments

Comments
 (0)