11package com .azuredoom .levelingcore ;
22
3- import com .azuredoom .levelingcore .events .GainXPEventSystem ;
43import com .hypixel .hytale .logger .HytaleLogger ;
54import com .hypixel .hytale .server .core .plugin .JavaPlugin ;
65import com .hypixel .hytale .server .core .plugin .JavaPluginInit ;
7- import com .hypixel .hytale .server .core .universe .world .storage .EntityStore ;
86import com .hypixel .hytale .server .core .util .Config ;
97
108import java .nio .file .Path ;
1513import com .azuredoom .levelingcore .commands .*;
1614import com .azuredoom .levelingcore .config .GUIConfig ;
1715import com .azuredoom .levelingcore .config .internal .ConfigBootstrap ;
16+ import com .azuredoom .levelingcore .events .GainXPEventSystem ;
17+ import com .azuredoom .levelingcore .events .LossXPEventSystem ;
1818import com .azuredoom .levelingcore .exceptions .LevelingCoreException ;
1919import com .azuredoom .levelingcore .level .LevelServiceImpl ;
2020
@@ -24,9 +24,9 @@ public class LevelingCore extends JavaPlugin {
2424
2525 public static final Path configPath = Paths .get ("./mods/levelingcore_LevelingCore/data/config/" );
2626
27- private static final ConfigBootstrap .Bootstrap bootstrap = ConfigBootstrap .bootstrap (configPath );
27+ public static final ConfigBootstrap .Bootstrap bootstrap = ConfigBootstrap .bootstrap (configPath );
2828
29- private static LevelServiceImpl levelingService ;
29+ public static LevelServiceImpl levelingService ;
3030
3131 private static LevelingCore INSTANCE ;
3232
@@ -46,9 +46,14 @@ public LevelingCore(@Nonnull JavaPluginInit init) {
4646 config = this .withConfig ("levelingcore" , GUIConfig .CODEC );
4747 }
4848
49+ /**
50+ * Initializes the core components of the leveling system. This method sets up necessary configurations, registers
51+ * commands, and configures systems to handle player leveling and experience management. It also initializes the
52+ * singleton instance of the {@code LevelingCore} class.
53+ */
4954 @ Override
5055 protected void setup () {
51- super . setup () ;
56+ INSTANCE = this ;
5257 this .config .save ();
5358 LOGGER .at (Level .INFO ).log ("Leveling Core initializing" );
5459 levelingService = bootstrap .service ();
@@ -58,9 +63,17 @@ protected void setup() {
5863 getCommandRegistry ().registerCommand (new SetLevelCommand ());
5964 getCommandRegistry ().registerCommand (new RemoveLevelCommand ());
6065 getCommandRegistry ().registerCommand (new RemoveXpCommand ());
61- getEntityStoreRegistry ().registerSystem (new GainXPEventSystem ());
66+ getEntityStoreRegistry ().registerSystem (new GainXPEventSystem (config ));
67+ getEntityStoreRegistry ().registerSystem (new LossXPEventSystem (config ));
6268 }
6369
70+ /**
71+ * Shuts down the {@code LevelingCore} instance and releases allocated resources. This method performs cleanup
72+ * operations required to properly terminate the leveling system. It includes closing any resources associated with
73+ * the {@code bootstrap} object and logging the shutdown process.
74+ *
75+ * @throws LevelingCoreException if resource cleanup fails.
76+ */
6477 @ Override
6578 protected void shutdown () {
6679 super .shutdown ();
@@ -72,18 +85,6 @@ protected void shutdown() {
7285 }
7386 }
7487
75- // static void main() {
76- // TODO: Remove once hooks into the player/mob kill events are found and integrable.
77- // var testId = UUID.fromString("d3804858-4bb8-4026-ae21-386255ed467d");
78- // if (LevelingCoreApi.getLevelServiceIfPresent().isPresent()) {
79- // var levelingService = LevelingCoreApi.getLevelServiceIfPresent().get();
80- // levelingService.addXp(testId, 500);
81- // TODO: Move to chat or display based logging instead of loggers for gaining or lossing Levels/XP.
82- // LOGGER.at(Level.INFO).log("Added 500 XP to player");
83- // LOGGER.at(Level.INFO).log("Player level: " + levelingService.getLevel(testId));
84- // }
85- // }
86-
8788 /**
8889 * Retrieves the {@link LevelServiceImpl} instance managed by the {@code LevelingCore} class. The
8990 * {@code LevelService} provides methods for managing player levels and experience points (XP).
0 commit comments