From ebfc7351dd5c21bd16a30f7b004c967667112922 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 25 Aug 2019 14:34:42 +0700 Subject: [PATCH] =?UTF-8?q?[F]=20=D0=9A=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4?= =?UTF-8?q?=D0=B0=20Json*PermissionsHandler=20-=20save?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../permissions/JsonFilePermissionsHandler.java | 13 +++++++++++++ .../permissions/JsonLongFilePermissionsHandler.java | 13 +++++++++++++ .../launchserver/components/AbstractLimiter.java | 1 - 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java index 4f2f41fd..fc779fb3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java @@ -52,6 +52,19 @@ public void invoke(String... args) throws Exception { } }; commands.put("reload", reload); + commands.put("save", new SubCommand() { + @Override + public void invoke(String... args) throws Exception { + Path path = Paths.get(filename); + if (!IOHelper.exists(path)) { + try (Writer writer = IOHelper.newWriter(path)) { + Launcher.gsonManager.gson.toJson(map, writer); + } catch (IOException e) { + LogHelper.error(e); + } + } + } + }); return commands; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java index 29848645..1649303c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java @@ -53,6 +53,19 @@ public void invoke(String... args) throws Exception { } }; commands.put("reload", reload); + commands.put("save", new SubCommand() { + @Override + public void invoke(String... args) throws Exception { + Path path = Paths.get(filename); + if (!IOHelper.exists(path)) { + try (Writer writer = IOHelper.newWriter(path)) { + Launcher.gsonManager.gson.toJson(map, writer); + } catch (IOException e) { + LogHelper.error(e); + } + } + } + }); return commands; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java index 1087e359..44742e0b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java @@ -52,7 +52,6 @@ public void invoke(String... args) throws Exception { commands.put("clearExclude", new SubCommand() { @Override public void invoke(String... args) throws Exception { - verifyArgs(args, 1); exclude.clear(); } });