@@ -57,23 +57,25 @@ public final class OriginBlacklist {
5757 private final OriginBlacklistHTTPServer http ;
5858 private final Json5 json5 ;
5959 private String updateURL ;
60+ private Path jarFile ;
6061
6162 public OriginBlacklist (final IOriginBlacklistPlugin plugin ) {
6263 this .plugin = plugin ;
6364 this .config = new OriginBlacklistConfig (this );
6465 this .http = new OriginBlacklistHTTPServer (this );
6566 this .json5 = Json5 .builder (builder -> builder .prettyPrinting ().indentFactor (0 ).build ());
66- plugin .scheduleRepeat (() -> {
67- this .checkForUpdates ();
68- }, this .config .getInteger ("update_checker.check_timer" ), TimeUnit .SECONDS );
6967 }
7068
7169 public final void init () {
72- this .plugin .log (EnumLogLevel .INFO , "Initialized Plugin" );
73- this .plugin .log (EnumLogLevel .DEBUG , "Commit " + COMMIT_L );
70+ this .jarFile = this .plugin .getPluginJarPath ();
71+ this .plugin .scheduleRepeat (() -> {
72+ this .checkForUpdates ();
73+ }, this .config .getInteger ("update_checker.check_timer" ), TimeUnit .SECONDS );
7474 if (this .isHTTPServerEnabled ()) {
7575 this .http .start ();
7676 }
77+ this .plugin .log (EnumLogLevel .INFO , "Initialized Plugin" );
78+ this .plugin .log (EnumLogLevel .DEBUG , "Commit " + COMMIT_L );
7779 }
7880
7981 public final void shutdown () {
@@ -190,7 +192,7 @@ public final void checkForUpdates(final Runnable action1, final Runnable action2
190192 public final void updatePlugin (final Runnable action1 , final Runnable action2 ) {
191193 try {
192194 final URL url = new URL (this .updateURL );
193- final Path jar = this .plugin . getPluginJarPath () ;
195+ final Path jar = this .jarFile ;
194196 final Path bak = jar .resolveSibling (jar .getFileName ().toString () + ".bak" );
195197 final Path upd = jar
196198 .resolveSibling (Paths .get (URLDecoder .decode (url .getPath (), StandardCharsets .UTF_8 )).getFileName ());
@@ -215,6 +217,7 @@ public final void updatePlugin(final Runnable action1, final Runnable action2) {
215217 }
216218 Files .delete (jar );
217219 Files .delete (bak );
220+ this .jarFile = upd ;
218221 action1 .run ();
219222 return ;
220223 } catch (final Throwable t ) {
0 commit comments