File tree Expand file tree Collapse file tree
realty-paper-plan-extension
java/io/github/md5sha256/realty/plan
realty-paper/src/main/resources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies {
1010 compileOnly(" com.github.plan-player-analytics:Plan:5.7.3306" )
1111 compileOnly(" org.jetbrains:annotations:26.0.2-1" )
1212
13+ testImplementation(project(" :realty-common" ))
1314 testImplementation(platform(" org.junit:junit-bom:5.11.4" ))
1415 testImplementation(" org.junit.jupiter:junit-jupiter" )
1516 testImplementation(" com.github.plan-player-analytics:Plan:5.7.3306" )
Original file line number Diff line number Diff line change 1+ package io .github .md5sha256 .realty .plan ;
2+
3+ import com .djrapitops .plan .capability .CapabilityService ;
4+ import com .djrapitops .plan .extension .ExtensionService ;
5+ import io .github .md5sha256 .realty .api .RealtyApi ;
6+
7+ final class PlanRegistration {
8+
9+ private final RealtyDataExtension extension ;
10+
11+ PlanRegistration (RealtyApi realtyApi ) {
12+ this .extension = new RealtyDataExtension (realtyApi );
13+ }
14+
15+ void register () {
16+ CapabilityService .getInstance ().registerEnableListener (isPlanEnabled -> {
17+ if (isPlanEnabled ) {
18+ registerExtension ();
19+ }
20+ });
21+ registerExtension ();
22+ }
23+
24+ void unregister () {
25+ try {
26+ ExtensionService .getInstance ().unregister (extension );
27+ } catch (IllegalStateException ignored ) {
28+ // ExtensionService not initialized, nothing to unregister
29+ }
30+ }
31+
32+ private void registerExtension () {
33+ if (!CapabilityService .getInstance ().hasCapability ("DATA_EXTENSION_VALUES" )) {
34+ return ;
35+ }
36+ ExtensionService .getInstance ().register (extension );
37+ }
38+ }
Original file line number Diff line number Diff line change 11package io .github .md5sha256 .realty .plan ;
22
3- import com .djrapitops .plan .extension .DataExtension ;
4- import com .djrapitops .plan .extension .ExtensionService ;
53import io .github .md5sha256 .realty .api .RealtyApi ;
64import org .bukkit .plugin .java .JavaPlugin ;
75
86public final class RealtyPaperPlanExtensionPlugin extends JavaPlugin {
97
10- private DataExtension dataExtension ;
8+ private PlanRegistration registration ;
119
1210 @ Override
1311 public void onEnable () {
@@ -17,13 +15,14 @@ public void onEnable() {
1715 getServer ().getPluginManager ().disablePlugin (this );
1816 return ;
1917 }
20- var api = provider .getProvider ();
21- this .dataExtension = new RealtyDataExtension (api );
22- ExtensionService .getInstance ().register (dataExtension );
18+ this .registration = new PlanRegistration (provider .getProvider ());
19+ this .registration .register ();
2320 }
2421
2522 @ Override
2623 public void onDisable () {
27- ExtensionService .getInstance ().unregister (dataExtension );
24+ if (registration != null ) {
25+ registration .unregister ();
26+ }
2827 }
2928}
Original file line number Diff line number Diff line change 1- name : Realty- Plan- Extension
1+ name : Realty Plan Extension
22version : " ${version}"
33main : io.github.md5sha256.realty.plan.RealtyPaperPlanExtensionPlugin
44api-version : " 1.21.8"
55authors : [ md5sha256 ]
66dependencies :
77 server :
88 Realty :
9+ load : BEFORE
910 join-classpath : true
1011 required : true
1112 Plan :
13+ load : BEFORE
1214 join-classpath : true
1315 required : true
Original file line number Diff line number Diff line change @@ -6,12 +6,15 @@ authors: [ md5sha256 ]
66dependencies :
77 server :
88 Vault :
9+ load : BEFORE
910 join-classpath : true
1011 required : true
1112 WorldGuard :
13+ load : BEFORE
1214 join-classpath : true
1315 required : true
1416 Essentials :
17+ load : BEFORE
1518 join-classpath : true
1619 required : false
1720permissions :
You can’t perform that action at this time.
0 commit comments