Skip to content

Commit

Permalink
Small resilience fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Mar 12, 2023
1 parent 5505c74 commit 7d0237b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private WatchedDirectory(Path dir, BiConsumer<Path, WatchEvent.Kind<Path>> liste
}

private void createRecursiveWatchers(Path dir) {
if (!Files.isDirectory(dir)) {
if (!Files.isDirectory(dir) || !Files.isReadable(dir)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ private void setLogLevels() {
System.setProperty("org.slf4j.simpleLogger.log.com.crschnick.pdx_unlimiter.app.installation", "info");
}

if (PdxuInstallation.getInstance().isNativeHookEnabled()) {
java.util.logging.Logger logger = java.util.logging.Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
logger.setUseParentHandlers(false);
GlobalScreen.isNativeHookRegistered();
try {
if (PdxuInstallation.getInstance().isNativeHookEnabled()) {
java.util.logging.Logger logger = java.util.logging.Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
logger.setUseParentHandlers(false);
GlobalScreen.isNativeHookRegistered();
}
} catch (Throwable t) {
t.printStackTrace();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public class GuiStyle {
public static String CLASS_CLEAR = "clear-button";

public static void addStylesheets(Scene scene) {
if (PdxuInstallation.getInstance() == null) {
return;
}

try {
Files.list(PdxuInstallation.getInstance().getResourceDir().resolve("style"))
.map(p -> p.toUri().toString())
Expand All @@ -84,6 +88,10 @@ public static void addStylesheets(Scene scene) {
}

public static void makeEmptyAlert(Scene scene) {
if (PdxuInstallation.getInstance() == null) {
return;
}

scene.getStylesheets().add(PdxuInstallation.getInstance().getResourceDir().resolve("style")
.resolve("empty-alert.css").toUri().toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class ValueNode extends Node {

private static final byte DOUBLE_QUOTE_CHAR = 34;
private static final Pattern LONG = Pattern.compile("[+-]?[0-9]+");
private static final Pattern DOUBLE = Pattern.compile("[+-]?([0-9]+)\\.([0-9]+)");
private static final Pattern DOUBLE = Pattern.compile("[+-]?([0-9]+)[.,]([0-9]+)");

private NodeContext context;
private int scalarIndex;
Expand Down Expand Up @@ -111,7 +111,8 @@ public long getLong() {

@Override
public double getDouble() {
return Double.parseDouble(evaluateContent());
// Replaces decimal commas
return Double.parseDouble(evaluateContent().replaceAll(",", "."));
}

@Override
Expand Down

0 comments on commit 7d0237b

Please sign in to comment.