aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHacktheTime <l4bg0jb7@duck.com>2023-12-10 21:25:48 +0100
committerHacktheTime <l4bg0jb7@duck.com>2023-12-10 21:25:48 +0100
commit709972ffd493632949282ca848fee848146a01ad (patch)
treeb9bd1dcbdd744230445fdad461ab6d654da0c3aa
parent6b0885b7a371d3e15e73fa997ecc2133b63553fd (diff)
downloadBBsentials-709972ffd493632949282ca848fee848146a01ad.tar.gz
BBsentials-709972ffd493632949282ca848fee848146a01ad.tar.bz2
BBsentials-709972ffd493632949282ca848fee848146a01ad.zip
crash fix with NumPad Codes when typing a dot.
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/DoubleFieldWidget.java2
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/IntegerFieldWidget.java15
2 files changed, 8 insertions, 9 deletions
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/DoubleFieldWidget.java b/fabric/src/main/java/de/hype/bbsentials/fabric/DoubleFieldWidget.java
index 968cb92..67cbf21 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/DoubleFieldWidget.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/DoubleFieldWidget.java
@@ -20,7 +20,7 @@ public class DoubleFieldWidget extends IntegerFieldWidget {
@Override
public boolean charTyped(char chr, int modifiers) {
- if (chr == '.' || chr == ',') return super.typeChar('.', modifiers);
+ if (chr == '.' || chr == ',') return super.typeChar('.', modifiers, true);
return super.charTyped(chr, modifiers);
}
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/IntegerFieldWidget.java b/fabric/src/main/java/de/hype/bbsentials/fabric/IntegerFieldWidget.java
index fbbd649..d5f9a2e 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/IntegerFieldWidget.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/IntegerFieldWidget.java
@@ -20,6 +20,13 @@ public class IntegerFieldWidget extends TextFieldWidget {
@Override
public boolean charTyped(char chr, int modifiers) {
+ return typeChar(chr, modifiers, false);
+ }
+
+ public boolean typeChar(char chr, int modifiers, boolean doNotBlock) {
+ if (doNotBlock) {
+ return super.charTyped(chr, modifiers);
+ }
// Allow removal (backspace and delete) and specific key combinations (Ctrl+A)
if (chr == 8 || chr == 127 || (modifiers & 1) == 1) {
return super.charTyped(chr, modifiers);
@@ -30,12 +37,4 @@ public class IntegerFieldWidget extends TextFieldWidget {
}
return false; // Block other characters
}
-
- /**
- * Use this to bypass the check from the own charTyped. Passes this to the super Class of this.
- */
- public boolean typeChar(char chr, int modifiers) {
- return charTyped(chr, modifiers);
- }
-
}