22
33import com .tcoded .folialib .enums .ImplementationType ;
44import com .tcoded .folialib .impl .ServerImplementation ;
5+ import com .tcoded .folialib .util .InvalidTickDelayNotifier ;
56import org .bukkit .plugin .java .JavaPlugin ;
67
78import java .lang .reflect .InvocationTargetException ;
@@ -41,7 +42,8 @@ public FoliaLib(JavaPlugin plugin) {
4142 }
4243
4344 // Check for valid relocation
44- // Runtime replace to avoid relocations changing this string too
45+ // Runtime replace commas to avoid compiler relocations changing this string too
46+ // Not beautiful, but functional
4547 String originalLocation = "com,tcoded,folialib," .replace ("," , "." );
4648 if (this .getClass ().getName ().startsWith (originalLocation )) {
4749 Logger logger = this .plugin .getLogger ();
@@ -53,20 +55,7 @@ public FoliaLib(JavaPlugin plugin) {
5355 }
5456 }
5557
56- private ServerImplementation createServerImpl (String implName ) {
57- String basePackage = this .getClass ().getPackage ().getName () + ".impl." ;
58-
59- try {
60- return (ServerImplementation ) Class .forName (basePackage + implName )
61- .getConstructor (this .getClass ())
62- .newInstance (this );
63- } catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
64- IllegalAccessException e ) {
65- e .printStackTrace ();
66- }
67-
68- return null ;
69- }
58+ // Getters
7059
7160 @ SuppressWarnings ("unused" )
7261 public ImplementationType getImplType () {
@@ -85,12 +74,12 @@ public boolean isFolia() {
8574
8675 @ SuppressWarnings ("unused" )
8776 public boolean isPaper () {
88- return implementationType == ImplementationType .PAPER ;
77+ return implementationType == ImplementationType .PAPER || implementationType == ImplementationType . LEGACY_PAPER ;
8978 }
9079
9180 @ SuppressWarnings ("unused" )
9281 public boolean isSpigot () {
93- return implementationType == ImplementationType .SPIGOT ;
82+ return implementationType == ImplementationType .SPIGOT || implementationType == ImplementationType . LEGACY_SPIGOT ;
9483 }
9584
9685 @ SuppressWarnings ("unused" )
@@ -101,4 +90,33 @@ public boolean isUnsupported() {
10190 public JavaPlugin getPlugin () {
10291 return plugin ;
10392 }
93+
94+ // Public Options
95+
96+ @ SuppressWarnings ("unused" )
97+ public void disableInvalidTickValueWarning () {
98+ InvalidTickDelayNotifier .disableNotifications = true ;
99+ }
100+
101+ @ SuppressWarnings ("unused" )
102+ public void enableInvalidTickValueDebug () {
103+ InvalidTickDelayNotifier .debugMode = true ;
104+ }
105+
106+ // Internal Utils
107+
108+ private ServerImplementation createServerImpl (String implName ) {
109+ String basePackage = this .getClass ().getPackage ().getName () + ".impl." ;
110+
111+ try {
112+ return (ServerImplementation ) Class .forName (basePackage + implName )
113+ .getConstructor (this .getClass ())
114+ .newInstance (this );
115+ } catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
116+ IllegalAccessException e ) {
117+ e .printStackTrace ();
118+ }
119+
120+ return null ;
121+ }
104122}
0 commit comments