Skip to content

Commit 695ab61

Browse files
authored
Refactor logging initialization and improve plugin dependency handling (#299)
1 parent 34cd8ba commit 695ab61

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/main/java/org/mvplugins/multiverse/netherportals/MultiverseNetherPortals.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import java.util.Map;
77
import java.util.Set;
88
import java.util.logging.Level;
9+
import java.util.logging.Logger;
910

1011
import com.dumptruckman.minecraft.util.Logging;
1112
import org.jetbrains.annotations.ApiStatus;
13+
import org.jetbrains.annotations.NotNull;
1214
import org.mvplugins.multiverse.core.MultiverseCoreApi;
1315
import org.mvplugins.multiverse.core.config.CoreConfig;
1416
import org.mvplugins.multiverse.core.module.MultiverseModule;
@@ -37,9 +39,8 @@ public class MultiverseNetherPortals extends MultiverseModule {
3739
private static final String DEFAULT_END_PREFIX = "";
3840
private static final String DEFAULT_END_SUFFIX = "_the_end";
3941

40-
protected MultiverseCoreApi core;
41-
protected Plugin multiversePortals;
42-
protected FileConfiguration MVNPConfiguration;
42+
private Plugin multiversePortals;
43+
private FileConfiguration MVNPConfiguration;
4344
private Map<String, String> linkMap;
4445
private Map<String, String> endLinkMap;
4546

@@ -51,31 +52,24 @@ public class MultiverseNetherPortals extends MultiverseModule {
5152
@Override
5253
public void onLoad() {
5354
super.onLoad();
55+
Logging.init(this);
5456
getDataFolder().mkdirs();
5557
}
5658

5759
@Override
5860
public void onEnable() {
5961
super.onEnable();
60-
Logging.init(this);
61-
this.core = MultiverseCoreApi.get();
6262
this.multiversePortals = getServer().getPluginManager().getPlugin("Multiverse-Portals");
6363

64-
// Test if the Core was found, if not we'll disable this plugin.
65-
if (this.core == null) {
66-
Logging.info("Multiverse-Core not found, will keep looking.");
67-
getServer().getPluginManager().disablePlugin(this);
68-
return;
69-
}
70-
7164
initializeDependencyInjection(new MultiverseNetherPortalsPluginBinder(this));
7265
Logging.setDebugLevel(coreConfig.get().getGlobalDebug());
7366

7467
loadConfig();
7568
this.registerCommands(NetherPortalsCommand.class);
7669
this.registerDynamicListeners(MVNPListener.class);
7770

78-
Logging.log(true, Level.INFO, " Enabled - By %s", StringFormatter.joinAnd(this.getDescription().getAuthors()));
71+
Logging.config("Version %s (API v%s) Enabled - By %s",
72+
this.getDescription().getVersion(), getVersionAsNumber(), StringFormatter.joinAnd(this.getDescription().getAuthors()));
7973
}
8074

8175
public void loadConfig() {
@@ -149,13 +143,19 @@ private void initMVNPConfig() {
149143
public void onDisable() {
150144
shutdownDependencyInjection();
151145
Logging.info("- Disabled");
146+
Logging.shutdown();
152147
}
153148

154149
@Override
155150
public double getTargetCoreVersion() {
156151
return TARGET_CORE_API_VERSION;
157152
}
158153

154+
@Override
155+
public @NotNull Logger getLogger() {
156+
return Logging.getLogger();
157+
}
158+
159159
public void setNetherPrefix(String netherPrefix) {
160160
this.MVNPConfiguration.set("portal-auto-link-when.nether.prefix", netherPrefix);
161161
}

0 commit comments

Comments
 (0)