From fe47739cb83b8ad030074e17677d02b18b38e83b Mon Sep 17 00:00:00 2001 From: _Bastler Date: Wed, 6 Oct 2021 19:12:54 +0200 Subject: [PATCH] setting boundaries --- .../board/controller/BaseController.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/bstly/board/controller/BaseController.java b/src/main/java/de/bstly/board/controller/BaseController.java index f75384b..6e6c34a 100644 --- a/src/main/java/de/bstly/board/controller/BaseController.java +++ b/src/main/java/de/bstly/board/controller/BaseController.java @@ -86,7 +86,16 @@ public class BaseController { LocalUser localUser = localUserManager.getByUsername(username); if (localUser.getSettings() != null && localUser.getSettings().containsKey("gravity")) { try { - return Double.parseDouble(localUser.getSettings().get("gravity")); + double gravity = Double.parseDouble(localUser.getSettings().get("gravity")); + if (gravity < 0) { + return 0; + } + + if (gravity > 2) { + return 2; + } + + return gravity; } catch (Exception e) { } } @@ -106,7 +115,17 @@ public class BaseController { if (localUser.getSettings() != null && localUser.getSettings().containsKey("commentDelay")) { try { - return Long.parseLong(localUser.getSettings().get("commentDelay")); + long commentDelay = Long.parseLong(localUser.getSettings().get("commentDelay")); + + if (commentDelay < 0) { + return 0; + } + + if (commentDelay > 15) { + return 15; + } + + return commentDelay; } catch (Exception e) { } }