88import java .util .logging .Level ;
99
1010import com .dumptruckman .minecraft .util .Logging ;
11+ import org .mvplugins .multiverse .core .MultiverseCoreApi ;
12+ import org .mvplugins .multiverse .core .MultiversePlugin ;
13+ import org .mvplugins .multiverse .core .inject .PluginServiceLocatorFactory ;
14+ import org .mvplugins .multiverse .core .utils .StringFormatter ;
1115import org .mvplugins .multiverse .netherportals .commands .NetherPortalsCommand ;
1216import org .mvplugins .multiverse .netherportals .listeners .MVNPListener ;
1317import org .bukkit .Location ;
1620import org .bukkit .configuration .file .FileConfiguration ;
1721import org .bukkit .configuration .file .YamlConfiguration ;
1822import org .bukkit .plugin .Plugin ;
19- import org .bukkit .plugin .java .JavaPlugin ;
20- import org .mvplugins .multiverse .core .MultiverseCore ;
21- import org .mvplugins .multiverse .core .submodules .MVPlugin ;
2223import org .mvplugins .multiverse .core .commandtools .MVCommandManager ;
23- import org .mvplugins .multiverse .core .api . config .MVCoreConfig ;
24+ import org .mvplugins .multiverse .core .config .MVCoreConfig ;
2425import org .mvplugins .multiverse .core .inject .PluginServiceLocator ;
2526import org .mvplugins .multiverse .external .jakarta .inject .Inject ;
2627import org .mvplugins .multiverse .external .jakarta .inject .Provider ;
2728import org .mvplugins .multiverse .external .vavr .control .Try ;
2829import org .mvplugins .multiverse .portals .MultiversePortals ;
2930import org .mvplugins .multiverse .portals .utils .PortalManager ;
3031
31- public class MultiverseNetherPortals extends JavaPlugin implements MVPlugin {
32+ public class MultiverseNetherPortals extends MultiversePlugin {
3233
3334 private static final String NETHER_PORTALS_CONFIG = "config.yml" ;
3435 private static final String DEFAULT_NETHER_PREFIX = "" ;
3536 private static final String DEFAULT_NETHER_SUFFIX = "_nether" ;
3637 private static final String DEFAULT_END_PREFIX = "" ;
3738 private static final String DEFAULT_END_SUFFIX = "_the_end" ;
38- private final static int requiresProtocol = 24 ;
39+ private final static int requiresProtocol = 50 ;
3940
40- protected MultiverseCore core ;
41+ protected MultiverseCoreApi core ;
4142 protected Plugin multiversePortals ;
4243 protected FileConfiguration MVNPConfiguration ;
4344 private Map <String , String > linkMap ;
@@ -51,13 +52,15 @@ public class MultiverseNetherPortals extends JavaPlugin implements MVPlugin {
5152
5253 @ Override
5354 public void onLoad () {
55+ super .onEnable ();
5456 getDataFolder ().mkdirs ();
5557 }
5658
5759 @ Override
5860 public void onEnable () {
61+ super .onEnable ();
5962 Logging .init (this );
60- this .core = ( MultiverseCore ) getServer (). getPluginManager (). getPlugin ( "Multiverse-Core" );
63+ this .core = MultiverseCoreApi . get ( );
6164 this .multiversePortals = getServer ().getPluginManager ().getPlugin ("Multiverse-Portals" );
6265
6366 // Test if the Core was found, if not we'll disable this plugin.
@@ -66,31 +69,19 @@ public void onEnable() {
6669 getServer ().getPluginManager ().disablePlugin (this );
6770 return ;
6871 }
69- if (this .core .getProtocolVersion () < requiresProtocol ) {
70- Logging .severe ("Your Multiverse-Core is OUT OF DATE" );
71- Logging .severe ("This version of NetherPortals requires Protocol Level: " + requiresProtocol );
72- Logging .severe ("Your of Core Protocol Level is: " + this .core .getProtocolVersion ());
73- Logging .severe ("Grab an updated copy at: " );
74- Logging .severe ("http://dev.bukkit.org/bukkit-plugins/multiverse-core/" );
75- getServer ().getPluginManager ().disablePlugin (this );
76- return ;
77- }
7872
7973 initializeDependencyInjection ();
8074 Logging .setDebugLevel (mvCoreConfig .get ().getGlobalDebug ());
8175
82- this .core .incrementPluginCount ();
83- // As soon as we know MVCore was found, we can use the debug log!
84-
8576 loadConfig ();
8677 this .registerCommands ();
8778 this .registerEvents ();
8879
89- Logging .log (true , Level .INFO , " Enabled - By %s" , getAuthors ());
80+ Logging .log (true , Level .INFO , " Enabled - By %s" , StringFormatter . joinAnd ( this . getDescription (). getAuthors () ));
9081 }
9182
9283 private void initializeDependencyInjection () {
93- serviceLocator = core . getServiceLocatorFactory ()
84+ serviceLocator = PluginServiceLocatorFactory . get ()
9485 .registerPlugin (new MultiverseNetherPortalsPluginBinder (this ), core .getServiceLocator ())
9586 .flatMap (PluginServiceLocator ::enable )
9687 .getOrElseThrow (exception -> {
@@ -196,16 +187,8 @@ public void onDisable() {
196187 }
197188
198189 @ Override
199- public String getAuthors () {
200- String authors = "" ;
201- for (int i = 0 ; i < this .getDescription ().getAuthors ().size (); i ++) {
202- if (i == this .getDescription ().getAuthors ().size () - 1 ) {
203- authors += " and " + this .getDescription ().getAuthors ().get (i );
204- } else {
205- authors += ", " + this .getDescription ().getAuthors ().get (i );
206- }
207- }
208- return authors .substring (2 );
190+ public int getTargetCoreProtocolVersion () {
191+ return requiresProtocol ;
209192 }
210193
211194 @ Override
@@ -360,20 +343,6 @@ public void setPortals(Plugin multiversePortals) {
360343 this .multiversePortals = multiversePortals ;
361344 }
362345
363- public Plugin getPortals () {
364- return multiversePortals ;
365- }
366-
367- @ Override
368- public MultiverseCore getCore () {
369- return this .core ;
370- }
371-
372- @ Override
373- public int getProtocolVersion () {
374- return 1 ;
375- }
376-
377346 public String getDebugInfo () {
378347 return "[Multiverse-NetherPortals] Multiverse-NetherPortals Version: " + this .getDescription ().getVersion () + '\n'
379348 + "[Multiverse-NetherPortals] Nether Prefix: " + this .getNetherPrefix () + '\n'
0 commit comments