From 962fe89c01b6de4717f82f0d9f5ca8917df78c61 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Aug 2019 19:53:50 +0300 Subject: [PATCH] Reload plugin after db clear to avoid some issues --- .../commands/manage/ManageClearCommand.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index 928d83982..f2ce884e2 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -16,6 +16,7 @@ */ package com.djrapitops.plan.command.commands.manage; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.api.exceptions.database.DBOpException; import com.djrapitops.plan.db.DBType; @@ -50,6 +51,7 @@ import java.util.concurrent.ExecutionException; @Singleton public class ManageClearCommand extends CommandNode { + private final PlanPlugin plugin; private final Locale locale; private final Processing processing; private final DBSystem dbSystem; @@ -58,6 +60,7 @@ public class ManageClearCommand extends CommandNode { @Inject public ManageClearCommand( + PlanPlugin plugin, Locale locale, Processing processing, DBSystem dbSystem, @@ -65,6 +68,7 @@ public class ManageClearCommand extends CommandNode { ErrorHandler errorHandler ) { super("clear", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS); + this.plugin = plugin; this.locale = locale; this.processing = processing; @@ -110,6 +114,7 @@ public class ManageClearCommand extends CommandNode { .get(); // Wait for completion queryService.dataCleared(); sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS)); + reloadPlugin(sender); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (DBOpException | ExecutionException e) { @@ -118,4 +123,14 @@ public class ManageClearCommand extends CommandNode { } }); } + + private void reloadPlugin(Sender sender) { + try { + plugin.reloadPlugin(true); + } catch (Exception e) { + errorHandler.log(L.CRITICAL, this.getClass(), e); + sender.sendMessage(locale.getString(CommandLang.RELOAD_FAILED)); + } + sender.sendMessage(locale.getString(CommandLang.RELOAD_COMPLETE)); + } }