88package org .mvplugins .multiverse .signportals ;
99
1010import com .dumptruckman .minecraft .util .Logging ;
11- import org .mvplugins .multiverse .core .MultiverseCore ;
12- import org .mvplugins .multiverse .core .api .config .MVCoreConfig ;
11+ import org .mvplugins .multiverse .core .MultiverseCoreApi ;
12+ import org .mvplugins .multiverse .core .MultiversePlugin ;
13+ import org .mvplugins .multiverse .core .config .MVCoreConfig ;
1314import org .mvplugins .multiverse .core .inject .PluginServiceLocator ;
14- import org .mvplugins .multiverse .core .submodules . MVCore ;
15- import org .mvplugins .multiverse .core .submodules . MVPlugin ;
15+ import org .mvplugins .multiverse .core .inject . PluginServiceLocatorFactory ;
16+ import org .mvplugins .multiverse .core .utils . StringFormatter ;
1617import org .mvplugins .multiverse .external .jvnet .hk2 .annotations .Service ;
1718import org .mvplugins .multiverse .external .vavr .control .Option ;
1819import org .mvplugins .multiverse .external .vavr .control .Try ;
19- import org .bukkit .plugin .java .JavaPlugin ;
2020import org .mvplugins .multiverse .signportals .listeners .SignPortalsListener ;
2121
2222import java .util .logging .Level ;
2323
2424@ Service
25- public class MultiverseSignPortals extends JavaPlugin implements MVPlugin {
25+ public class MultiverseSignPortals extends MultiversePlugin {
2626
27- private MultiverseCore core ;
27+ private MultiverseCoreApi core ;
2828 private PluginServiceLocator serviceLocator ;
2929
3030 private final static int requiresProtocol = 50 ;
@@ -38,29 +38,13 @@ public void onLoad() {
3838 public void onEnable () {
3939 Logging .init (this );
4040
41- this .core = (MultiverseCore ) getServer ().getPluginManager ().getPlugin ("Multiverse-Core" );
42- // Test if the Core was found, if not we'll disable this plugin.
43- if (this .core == null ) {
44- Logging .info ("Multiverse-Core not found, will keep looking." );
45- getServer ().getPluginManager ().disablePlugin (this );
46- return ;
47- }
48- if (this .core .getProtocolVersion () < requiresProtocol ) {
49- Logging .severe ("Your Multiverse-Core is OUT OF DATE" );
50- Logging .severe ("This version of SignPortals requires Protocol Level: " + requiresProtocol );
51- Logging .severe ("Your of Core Protocol Level is: " + this .core .getProtocolVersion ());
52- Logging .severe ("Grab an updated copy at: " );
53- Logging .severe ("http://dev.bukkit.org/bukkit-plugins/multiverse-core/" );
54- getServer ().getPluginManager ().disablePlugin (this );
55- return ;
56- }
41+ this .core = MultiverseCoreApi .get ();
5742
5843 initializeDependencyInjection ();
5944 registerEvents ();
6045 Logging .setDebugLevel (serviceLocator .getActiveService (MVCoreConfig .class ).getGlobalDebug ());
6146
62- this .core .incrementPluginCount ();
63- Logging .log (true , Level .INFO , " Enabled - By %s" , getAuthors ());
47+ Logging .log (true , Level .INFO , " Enabled - By %s" , StringFormatter .joinAnd (getDescription ().getAuthors ()));
6448 }
6549
6650 public void onDisable () {
@@ -70,7 +54,7 @@ public void onDisable() {
7054 }
7155
7256 private void initializeDependencyInjection () {
73- serviceLocator = core . getServiceLocatorFactory ()
57+ serviceLocator = PluginServiceLocatorFactory . get ()
7458 .registerPlugin (new MultiverseSignPortalsPluginBinder (this ), core .getServiceLocator ())
7559 .flatMap (PluginServiceLocator ::enable )
7660 .getOrElseThrow (exception -> {
@@ -102,24 +86,6 @@ private void registerEvents() {
10286 });
10387 }
10488
105- /**
106- * Parse the Authors Array into a readable String with ',' and 'and'.
107- *
108- * @return An comma separated string of authors
109- */
110- @ Override
111- public String getAuthors () {
112- String authors = "" ;
113- for (int i = 0 ; i < this .getDescription ().getAuthors ().size (); i ++) {
114- if (i == this .getDescription ().getAuthors ().size () - 1 ) {
115- authors += " and " + this .getDescription ().getAuthors ().get (i );
116- } else {
117- authors += ", " + this .getDescription ().getAuthors ().get (i );
118- }
119- }
120- return authors .substring (2 );
121- }
122-
12389 @ Override
12490 public PluginServiceLocator getServiceLocator () {
12591 return serviceLocator ;
@@ -130,12 +96,7 @@ public String getVersionInfo() {
13096 }
13197
13298 @ Override
133- public MVCore getCore () {
134- return this .core ;
135- }
136-
137- @ Override
138- public int getProtocolVersion () {
139- return 1 ;
99+ public int getTargetCoreProtocolVersion () {
100+ return requiresProtocol ;
140101 }
141102}
0 commit comments