1212import org .kilocraft .essentials .api .KiloEssentials ;
1313import org .kilocraft .essentials .api .KiloServer ;
1414import org .kilocraft .essentials .api .ModConstants ;
15+ import org .kilocraft .essentials .api .feature .ConfigurableFeature ;
1516import org .kilocraft .essentials .api .feature .ConfigurableFeatures ;
1617import org .kilocraft .essentials .api .server .Server ;
1718import org .kilocraft .essentials .api .user .CommandSourceUser ;
1819import org .kilocraft .essentials .api .user .NeverJoinedUser ;
1920import org .kilocraft .essentials .api .user .OnlineUser ;
2021import org .kilocraft .essentials .api .user .User ;
21- import org .kilocraft .essentials .api .util .Litebans2Vanilla ;
2222import org .kilocraft .essentials .chat .ServerChat ;
2323import org .kilocraft .essentials .commands .CommandUtils ;
2424import org .kilocraft .essentials .commands .misc .DiscordCommand ;
3232import org .kilocraft .essentials .extensions .warps .serverwidewarps .ServerWarpManager ;
3333import org .kilocraft .essentials .user .ServerUserManager ;
3434import org .kilocraft .essentials .user .UserHomeHandler ;
35- import org .kilocraft .essentials .util .MutedPlayerList ;
3635import org .kilocraft .essentials .util .PermissionUtil ;
3736import org .kilocraft .essentials .util .StartupScript ;
3837import org .kilocraft .essentials .util .messages .MessageUtil ;
3938import org .kilocraft .essentials .util .messages .nodes .ExceptionMessageNode ;
4039
41- import java .io .File ;
4240import java .io .IOException ;
4341import java .util .List ;
4442import java .util .Optional ;
5755 */
5856
5957public final class KiloEssentialsImpl implements KiloEssentials {
60- private static boolean running = false ;
58+ public static boolean running = false ;
6159 private static final Logger LOGGER = LogManager .getLogger ("KiloEssentials" );
6260 private static KiloEssentialsImpl instance ;
6361
64- private final ConfigurableFeatures FEATURES ;
65- private final KiloCommands commands ;
66-
67- private PermissionUtil permUtil ;
62+ private PermissionUtil permUtil ;
6863 private StartupScript startupScript ;
6964
7065 public static CommandDispatcher <ServerCommandSource > commandDispatcher ;
7166
72- public static void onServerSet (@ NotNull final Server server ) {
67+ public static void onServerSet (final Server server ) {
7368 KiloDebugUtils .validateDebugMode (false );
74- new KiloEssentialsImpl ();
75- }
76-
77- KiloEssentialsImpl () {
78- if (running ) {
79- throw new RuntimeException ("KiloEssentialsImpl is already running!" );
80- } else {
81- running = true ;
82- }
83-
84- KiloEssentialsImpl .instance = this ;
85- KiloEssentialsImpl .LOGGER .info ("Running KiloEssentials version " + ModConstants .getVersion ());
86-
87- KiloConfig .load ();
8869 try {
8970 getServer ().getUserManager ().getMutedPlayerList ().load ();
9071 } catch (IOException e ) {
9172 KiloEssentials .getLogger ().error ("An unexpected error occurred while loading the Muted Player List" , e );
9273 }
9374 new KiloEvents ();
94- this .commands = new KiloCommands ();
75+ }
76+
77+
78+
79+ public KiloEssentialsImpl () {
80+ if (running ) {
81+ throw new RuntimeException ("KiloEssentialsImpl is already running!" );
82+ } else {
83+ running = true ;
84+ }
85+ KiloEssentialsImpl .instance = this ;
86+ KiloEssentialsImpl .LOGGER .info ("Running KiloEssentials version " + ModConstants .getVersion ());
9587
9688 if (SharedConstants .isDevelopment ) {
9789 new KiloDebugUtils ();
9890 }
99-
10091 ServerChat .load ();
101-
102- FEATURES = new ConfigurableFeatures ();
103- FEATURES .tryToRegister (new UserHomeHandler (), "playerHomes" );
104- FEATURES .tryToRegister (new ServerWarpManager (), "serverWideWarps" );
105- FEATURES .tryToRegister (new PlayerWarpsManager (), "playerWarps" );
106- FEATURES .tryToRegister (new SeatManager (), "betterChairs" );
107- FEATURES .tryToRegister (new CustomCommands (), "customCommands" );
108- FEATURES .tryToRegister (new ParticleAnimationManager (), "magicalParticles" );
109- FEATURES .tryToRegister (new DiscordCommand (), "discordCommand" );
110- FEATURES .tryToRegister (new VoteCommand (), "voteCommand" );
111- FEATURES .tryToRegister (new PlaytimeCommands (), "playtimeCommands" );
112-
11392 if (KiloConfig .main ().startupScript ().enabled ) {
11493 this .startupScript = new StartupScript ();
11594 }
116-
11795 this .permUtil = new PermissionUtil ();
118-
119-
12096 }
12197
12298 public static Logger getLogger () {
@@ -140,7 +116,6 @@ public static KiloEssentialsImpl getInstance() {
140116 if (KiloEssentialsImpl .instance != null ) {
141117 return KiloEssentialsImpl .instance ;
142118 }
143-
144119 throw new RuntimeException ("Its too early to get a static instance of KiloEssentials!" );
145120 }
146121
@@ -154,7 +129,8 @@ public static Server getServer() {
154129
155130 @ Override
156131 public KiloCommands getCommandHandler () {
157- return this .commands ;
132+ return KiloCommands .getInstance ();
133+ // return this.commands;
158134 }
159135
160136 @ Override
@@ -317,7 +293,7 @@ public PermissionUtil getPermissionUtil() {
317293
318294 @ Override
319295 public ConfigurableFeatures getFeatures () {
320- return this . FEATURES ;
296+ return ConfigurableFeatures . getInstance () ;
321297 }
322298
323299 public void onServerStop () {
@@ -327,6 +303,7 @@ public void onServerStop() {
327303 }
328304
329305 public void onServerLoad () {
306+ new KiloCommands ();
330307 this .permUtil = new PermissionUtil ();
331308 }
332309
0 commit comments