Skip to content

Commit 85fb656

Browse files
committed
v0.1.0
1 parent b67bb30 commit 85fb656

15 files changed

Lines changed: 378 additions & 96 deletions

File tree

build.gradle

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ ext {
1818
}
1919
}
2020

21+
configurations {
22+
shadowBundle
23+
implementation.extendsFrom(shadowBundle)
24+
}
25+
2126
javadoc {
2227
options.addStringOption('Xdoclint:-missing', '-quiet')
2328
}
@@ -38,18 +43,19 @@ repositories {
3843

3944
dependencies {
4045
// Hytale server
41-
implementation(files("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar"))
46+
compileOnly(files("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar"))
47+
runtimeOnly(files("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar"))
4248
// implementation("com.buuz135:MultipleHUD:1.0.1")
4349
// Needed libs
44-
implementation 'com.h2database:h2:2.4.240'
45-
implementation 'com.zaxxer:HikariCP:7.0.2'
46-
implementation 'org.slf4j:slf4j-simple:2.0.17'
47-
implementation 'org.yaml:snakeyaml:2.5'
48-
implementation 'net.objecthunter:exp4j:0.4.8'
50+
shadowBundle 'com.h2database:h2:2.4.240'
51+
shadowBundle 'com.zaxxer:HikariCP:7.0.2'
52+
shadowBundle 'org.slf4j:slf4j-simple:2.0.17'
53+
shadowBundle 'org.yaml:snakeyaml:2.5'
54+
shadowBundle 'net.objecthunter:exp4j:0.4.8'
4955
// Drivers
50-
implementation 'com.mysql:mysql-connector-j:9.5.0'
51-
implementation 'org.mariadb.jdbc:mariadb-java-client:3.5.7'
52-
implementation 'org.postgresql:postgresql:42.7.8'
56+
shadowBundle 'com.mysql:mysql-connector-j:9.5.0'
57+
shadowBundle 'org.mariadb.jdbc:mariadb-java-client:3.5.7'
58+
shadowBundle 'org.postgresql:postgresql:42.7.8'
5359
// Testing
5460
testImplementation platform("org.junit:junit-bom:6.0.1")
5561
testImplementation "org.junit.jupiter:junit-jupiter"
@@ -93,10 +99,6 @@ idea.project.settings.runConfigurations {
9399
}
94100
}
95101

96-
test {
97-
useJUnitPlatform()
98-
}
99-
100102
spotless {
101103
java {
102104
eclipse().configFile("$rootDir/eclipse-formatter.xml")
@@ -112,6 +114,8 @@ shadowJar {
112114
archiveClassifier.set('')
113115
mergeServiceFiles()
114116

117+
configurations = [project.configurations.shadowBundle]
118+
115119
manifest {
116120
attributes(
117121
'Main-Class': 'com.azuredoom.levelingcore.LevelingCore'

changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
v0.1.0
2-
- Initial release with basic functionality
2+
- Initial release with basic functionality that I could think of.
3+
4+
TODO:
5+
- Implement XP bar in the UI. (Looking for Artist or Designer help)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.caching = true
66

77
# Common
88
java_version = 25
9-
hytale_version = Release 1.0
9+
hytale_version = 1.0-SNAPSHOT
1010
release_type = RELEASE
1111
maven_url = https://maven.azuredoom.com/mods
1212

src/main/java/com/azuredoom/levelingcore/LevelingCore.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.azuredoom.levelingcore;
22

3-
import com.azuredoom.levelingcore.events.GainXPEventSystem;
43
import com.hypixel.hytale.logger.HytaleLogger;
54
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
65
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
7-
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
86
import com.hypixel.hytale.server.core.util.Config;
97

108
import java.nio.file.Path;
@@ -15,6 +13,8 @@
1513
import com.azuredoom.levelingcore.commands.*;
1614
import com.azuredoom.levelingcore.config.GUIConfig;
1715
import com.azuredoom.levelingcore.config.internal.ConfigBootstrap;
16+
import com.azuredoom.levelingcore.events.GainXPEventSystem;
17+
import com.azuredoom.levelingcore.events.LossXPEventSystem;
1818
import com.azuredoom.levelingcore.exceptions.LevelingCoreException;
1919
import 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).

src/main/java/com/azuredoom/levelingcore/commands/AddLevelCommand.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
77
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
88
import com.hypixel.hytale.server.core.universe.PlayerRef;
9+
import com.hypixel.hytale.server.core.util.EventTitleUtil;
910

1011
import javax.annotation.Nonnull;
1112

1213
import com.azuredoom.levelingcore.api.LevelingCoreApi;
1314

15+
/**
16+
* The AddLevelCommand class is responsible for handling the command logic to add levels to a player's progress using
17+
* the LevelingCore API. This command ensures that the leveling system is properly initialized before performing any
18+
* operations and updates the player's level accordingly. Feedback messages are sent to both the player and the command
19+
* executor.
20+
*/
1421
public class AddLevelCommand extends CommandBase {
1522

1623
@Nonnull
@@ -39,7 +46,13 @@ protected void executeSync(@Nonnull CommandContext commandContext) {
3946
var levelRef = this.levelArg.get(commandContext);
4047
var playerUUID = playerRef.getUuid();
4148
LevelingCoreApi.getLevelServiceIfPresent().get().addLevel(playerUUID, levelRef);
42-
commandContext.sendMessage(Message.raw("Added " + levelRef + " levels to " + playerRef.getUsername()));
43-
commandContext.sendMessage(Message.raw("Player " + playerRef.getUsername() + " now has " + LevelingCoreApi.getLevelServiceIfPresent().get().getLevel(playerUUID) + " levels"));
49+
var addedLevelMsg = "Added " + levelRef + " levels to " + playerRef.getUsername();
50+
var levelTotalMsg = "Player " + playerRef.getUsername() + " is now level " + LevelingCoreApi
51+
.getLevelServiceIfPresent()
52+
.get()
53+
.getLevel(playerUUID);
54+
EventTitleUtil.showEventTitleToPlayer(playerRef, Message.raw(levelTotalMsg), Message.raw(levelTotalMsg), true);
55+
commandContext.sendMessage(Message.raw(addedLevelMsg));
56+
commandContext.sendMessage(Message.raw(levelTotalMsg));
4457
}
4558
}

src/main/java/com/azuredoom/levelingcore/commands/AddXpCommand.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
77
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
88
import com.hypixel.hytale.server.core.universe.PlayerRef;
9+
import com.hypixel.hytale.server.core.util.EventTitleUtil;
910

1011
import javax.annotation.Nonnull;
1112

1213
import com.azuredoom.levelingcore.api.LevelingCoreApi;
1314

15+
/**
16+
* The AddXpCommand class is responsible for handling the logic to add experience points (XP) to a player's progress
17+
* using the LevelingCore API. This command validates that the leveling system is initialized before proceeding with XP
18+
* modification. It updates the player's XP and calculates the resulting level, sending feedback messages to both the
19+
* player and the command executor.
20+
*/
1421
public class AddXpCommand extends CommandBase {
1522

1623
@Nonnull
@@ -39,7 +46,13 @@ protected void executeSync(@Nonnull CommandContext commandContext) {
3946
var xpRef = this.xpArg.get(commandContext);
4047
var playerUUID = playerRef.getUuid();
4148
LevelingCoreApi.getLevelServiceIfPresent().get().addXp(playerUUID, xpRef);
42-
commandContext.sendMessage(Message.raw("Added " + xpRef + " xp to " + playerRef.getUsername()));
43-
commandContext.sendMessage(Message.raw("Player " + playerRef.getUsername() + " now has " + LevelingCoreApi.getLevelServiceIfPresent().get().getXp(playerUUID) + " xp"));
49+
var setXPMsg = "Set " + playerRef.getUsername() + " xp to " + xpRef;
50+
var levelTotalMsg = "Player " + playerRef.getUsername() + " is now level " + LevelingCoreApi
51+
.getLevelServiceIfPresent()
52+
.get()
53+
.getLevel(playerUUID);
54+
EventTitleUtil.showEventTitleToPlayer(playerRef, Message.raw(levelTotalMsg), Message.raw(setXPMsg), true);
55+
commandContext.sendMessage(Message.raw(setXPMsg));
56+
commandContext.sendMessage(Message.raw(levelTotalMsg));
4457
}
4558
}

src/main/java/com/azuredoom/levelingcore/commands/CheckLevelCommand.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
77
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
88
import com.hypixel.hytale.server.core.universe.PlayerRef;
9+
import com.hypixel.hytale.server.core.util.EventTitleUtil;
910

1011
import javax.annotation.Nonnull;
1112

1213
import com.azuredoom.levelingcore.api.LevelingCoreApi;
1314

15+
/**
16+
* The CheckLevelCommand class is a concrete implementation of the CommandBase class. This command allows users to check
17+
* the current level of a specified player in the game. It interacts with the Leveling Core API to retrieve level data
18+
* for a given player.
19+
*/
1420
public class CheckLevelCommand extends CommandBase {
1521

1622
@Nonnull
@@ -33,12 +39,9 @@ protected void executeSync(@Nonnull CommandContext commandContext) {
3339
}
3440
var playerRef = this.playerArg.get(commandContext);
3541
var playerUUID = playerRef.getUuid();
36-
commandContext.sendMessage(
37-
Message.raw(
38-
playerRef.getUsername() + " level is: " + LevelingCoreApi.getLevelServiceIfPresent()
39-
.get()
40-
.getLevel(playerUUID)
41-
)
42-
);
42+
var levelRef = LevelingCoreApi.getLevelServiceIfPresent().get().getLevel(playerUUID);
43+
var currentLevelMsg = playerRef.getUsername() + " current level is " + levelRef;
44+
EventTitleUtil.showEventTitleToPlayer(playerRef, Message.raw(currentLevelMsg), Message.raw(""), true);
45+
commandContext.sendMessage(Message.raw(currentLevelMsg));
4346
}
4447
}

src/main/java/com/azuredoom/levelingcore/commands/RemoveLevelCommand.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
77
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
88
import com.hypixel.hytale.server.core.universe.PlayerRef;
9+
import com.hypixel.hytale.server.core.util.EventTitleUtil;
910

1011
import javax.annotation.Nonnull;
1112

1213
import com.azuredoom.levelingcore.api.LevelingCoreApi;
1314

15+
/**
16+
* Represents a command that removes a specific number of levels from a player. This command operates within the
17+
* Leveling Core system and adjusts the player's level based on the specified number of levels to be removed.
18+
*/
1419
public class RemoveLevelCommand extends CommandBase {
1520

1621
@Nonnull
@@ -39,7 +44,13 @@ protected void executeSync(@Nonnull CommandContext commandContext) {
3944
var levelRef = this.levelArg.get(commandContext);
4045
var playerUUID = playerRef.getUuid();
4146
LevelingCoreApi.getLevelServiceIfPresent().get().removeLevel(playerUUID, levelRef);
42-
commandContext.sendMessage(Message.raw("Removed " + levelRef + " levels from " + playerRef.getUsername()));
43-
commandContext.sendMessage(Message.raw("Player " + playerRef.getUsername() + " now has " + LevelingCoreApi.getLevelServiceIfPresent().get().getLevel(playerUUID) + " levels"));
47+
var removeLevelMsg = "Removed " + levelRef + " levels from " + playerRef.getUsername();
48+
var levelTotalMsg = "Player " + playerRef.getUsername() + " is now level " + LevelingCoreApi
49+
.getLevelServiceIfPresent()
50+
.get()
51+
.getLevel(playerUUID);
52+
EventTitleUtil.showEventTitleToPlayer(playerRef, Message.raw(levelTotalMsg), Message.raw(removeLevelMsg), true);
53+
commandContext.sendMessage(Message.raw(removeLevelMsg));
54+
commandContext.sendMessage(Message.raw(levelTotalMsg));
4455
}
4556
}

src/main/java/com/azuredoom/levelingcore/commands/RemoveXpCommand.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
package com.azuredoom.levelingcore.commands;
22

3-
import com.azuredoom.levelingcore.api.LevelingCoreApi;
43
import com.hypixel.hytale.server.core.Message;
54
import com.hypixel.hytale.server.core.command.system.CommandContext;
65
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
76
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
87
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
98
import com.hypixel.hytale.server.core.universe.PlayerRef;
9+
import com.hypixel.hytale.server.core.util.EventTitleUtil;
1010

1111
import javax.annotation.Nonnull;
1212

13+
import com.azuredoom.levelingcore.api.LevelingCoreApi;
14+
15+
/**
16+
* The RemoveXpCommand class is responsible for handling the logic to remove experience points (XP) from a player's
17+
* progress using the LevelingCore API. This command ensures that the leveling system is initialized before modifying
18+
* the XP. It retrieves the player's XP and calculates their level after removal, providing feedback messages to both
19+
* the player and the command executor.
20+
*/
1321
public class RemoveXpCommand extends CommandBase {
1422

1523
@Nonnull
@@ -19,11 +27,11 @@ public class RemoveXpCommand extends CommandBase {
1927
private final RequiredArg<Integer> xpArg;
2028

2129
public RemoveXpCommand() {
22-
super("removexp", "Remove XP from player");
30+
super("removexp", "Remove XP from player");
2331
this.playerArg = this.withRequiredArg(
24-
"player",
25-
"server.commands.levelingcore.addlevel.desc",
26-
ArgTypes.PLAYER_REF
32+
"player",
33+
"server.commands.levelingcore.addlevel.desc",
34+
ArgTypes.PLAYER_REF
2735
);
2836
this.xpArg = this.withRequiredArg("xpvalue", "server.commands.levelingcore.addlevel.desc", ArgTypes.INTEGER);
2937
}
@@ -38,7 +46,13 @@ protected void executeSync(@Nonnull CommandContext commandContext) {
3846
var xpRef = this.xpArg.get(commandContext);
3947
var playerUUID = playerRef.getUuid();
4048
LevelingCoreApi.getLevelServiceIfPresent().get().addXp(playerUUID, xpRef);
41-
commandContext.sendMessage(Message.raw("Removed " + xpRef + " xp from " + playerRef.getUsername()));
42-
commandContext.sendMessage(Message.raw("Player " + playerRef.getUsername() + " now has " + LevelingCoreApi.getLevelServiceIfPresent().get().getXp(playerUUID) + " xp"));
49+
var removedXPMsg = "Removed " + xpRef + " xp to " + playerRef.getUsername();
50+
var levelTotalMsg = "Player " + playerRef.getUsername() + " is now level " + LevelingCoreApi
51+
.getLevelServiceIfPresent()
52+
.get()
53+
.getLevel(playerUUID);
54+
EventTitleUtil.showEventTitleToPlayer(playerRef, Message.raw(levelTotalMsg), Message.raw(removedXPMsg), true);
55+
commandContext.sendMessage(Message.raw(removedXPMsg));
56+
commandContext.sendMessage(Message.raw(levelTotalMsg));
4357
}
4458
}

src/main/java/com/azuredoom/levelingcore/commands/SetLevelCommand.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
77
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
88
import com.hypixel.hytale.server.core.universe.PlayerRef;
9+
import com.hypixel.hytale.server.core.util.EventTitleUtil;
910

1011
import javax.annotation.Nonnull;
1112

1213
import com.azuredoom.levelingcore.api.LevelingCoreApi;
1314

15+
/**
16+
* This class represents a command that allows adjusting the level of a player within the context of the leveling
17+
* system.
18+
*/
1419
public class SetLevelCommand extends CommandBase {
1520

1621
@Nonnull
@@ -38,9 +43,15 @@ protected void executeSync(@Nonnull CommandContext commandContext) {
3843
var playerRef = this.playerArg.get(commandContext);
3944
var levelRef = this.levelArg.get(commandContext);
4045
var playerUUID = playerRef.getUuid();
41-
LevelingCoreApi.getLevelServiceIfPresent().get().addLevel(playerUUID, levelRef);
42-
commandContext.sendMessage(Message.raw("Set " + playerRef.getUsername()+ " level to " + levelRef));
43-
commandContext.sendMessage(Message.raw("Player " + playerRef.getUsername() + " now has " + LevelingCoreApi.getLevelServiceIfPresent().get().getLevel(playerUUID) + " levels"));
46+
LevelingCoreApi.getLevelServiceIfPresent().get().setLevel(playerUUID, levelRef);
47+
var setLevelMsg = "Set " + playerRef.getUsername() + " level to " + levelRef;
48+
var levelTotalMsg = "Player " + playerRef.getUsername() + " is now level " + LevelingCoreApi
49+
.getLevelServiceIfPresent()
50+
.get()
51+
.getLevel(playerUUID);
52+
EventTitleUtil.showEventTitleToPlayer(playerRef, Message.raw(levelTotalMsg), Message.raw(setLevelMsg), true);
53+
commandContext.sendMessage(Message.raw(setLevelMsg));
54+
commandContext.sendMessage(Message.raw(levelTotalMsg));
4455
}
4556

4657
}

0 commit comments

Comments
 (0)