Skip to content

Commit 27ab64c

Browse files
committed
Do it in a non api-breaking way
1 parent a43ea74 commit 27ab64c

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class MultiverseNetherPortals extends MultiverseModule {
3838
private static final String DEFAULT_END_SUFFIX = "_the_end";
3939

4040
protected MultiverseCoreApi core;
41-
protected boolean multiversePortalsEnabled;
41+
protected Plugin multiversePortals;
4242
protected FileConfiguration MVNPConfiguration;
4343
private Map<String, String> linkMap;
4444
private Map<String, String> endLinkMap;
@@ -59,7 +59,7 @@ public void onEnable() {
5959
super.onEnable();
6060
Logging.init(this);
6161
this.core = MultiverseCoreApi.get();
62-
this.multiversePortalsEnabled = getServer().getPluginManager().isPluginEnabled("Multiverse-Portals");
62+
this.multiversePortals = getServer().getPluginManager().getPlugin("Multiverse-Portals");
6363

6464
// Test if the Core was found, if not we'll disable this plugin.
6565
if (this.core == null) {
@@ -284,7 +284,7 @@ public void setEndPlatformDropBlocks(boolean endPlatformDropBlocks) {
284284
}
285285

286286
public boolean isHandledByNetherPortals(Location l) {
287-
if (multiversePortalsEnabled) {
287+
if (multiversePortals != null) {
288288
// Catch errors which could occur if classes aren't present or are missing methods.
289289
try {
290290
PortalManager portalManager = MultiversePortalsApi.get().getPortalManager();
@@ -299,16 +299,8 @@ public boolean isHandledByNetherPortals(Location l) {
299299
}
300300

301301
@ApiStatus.Internal
302-
public void setPortalsEnabled(boolean enabled) {
303-
this.multiversePortalsEnabled = enabled;
304-
}
305-
306-
/**
307-
* @deprecated Use {@link MultiversePortalsApi} instead. This method should be internal use only anyways.
308-
*/
309-
@Deprecated
310302
public void setPortals(Plugin multiversePortals) {
311-
// do nothing
303+
this.multiversePortals = multiversePortals;
312304
}
313305

314306
public String getDebugInfo() {

src/main/java/org/mvplugins/multiverse/netherportals/listeners/MVNPPluginListener.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mvplugins.multiverse.netherportals.listeners;
22

3+
import org.bukkit.event.EventHandler;
34
import org.bukkit.event.server.PluginDisableEvent;
45
import org.bukkit.event.server.PluginEnableEvent;
56

@@ -20,15 +21,15 @@ public MVNPPluginListener(MultiverseNetherPortals plugin) {
2021

2122
@EventMethod
2223
public void onPluginEnable(PluginEnableEvent event) {
23-
if (event.getPlugin().getName().equals("Multiverse-Portals")) {
24-
this.plugin.setPortalsEnabled(true);
24+
if (event.getPlugin().getDescription().getName().equals("Multiverse-Portals")) {
25+
this.plugin.setPortals(event.getPlugin());
2526
}
2627
}
2728

2829
@EventMethod
2930
public void onPluginDisable(PluginDisableEvent event) {
30-
if (event.getPlugin().getName().equals("Multiverse-Portals")) {
31-
this.plugin.setPortalsEnabled(true);
31+
if (event.getPlugin().getDescription().getName().equals("Multiverse-Portals")) {
32+
this.plugin.setPortals(null);
3233
}
3334
}
3435
}

0 commit comments

Comments
 (0)