Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public static void onRegisterCommands(RegisterCommandsEvent event) {
.executes(AutoLevelingCommands::executeGetLevelCommand)))
.requires(AutoLevelingCommands::hasPermission);
event.getDispatcher().register(getGlobalLevelCommand);
LiteralArgumentBuilder<CommandSourceStack> setGlobalLevelCommand =
Commands.literal("autoleveling")
.then(
Commands.literal("level")
.then(
Commands.literal("set")
.then(
Commands.argument("value", IntegerArgumentType.integer())
.executes(AutoLevelingCommands::executeSetLevelCommand))))
.requires(AutoLevelingCommands::hasPermission);
event.getDispatcher().register(setGlobalLevelCommand);
}

private static int executeAddLevelCommand(CommandContext<CommandSourceStack> ctx) {
Expand All @@ -56,6 +67,14 @@ private static int executeGetLevelCommand(CommandContext<CommandSourceStack> ctx
return 1;
}

private static int executeSetLevelCommand(CommandContext<CommandSourceStack> ctx) {
MinecraftServer server = ctx.getSource().getServer();
GlobalLevelingData globalLevelingData = GlobalLevelingData.get(server);
Integer newLevel = ctx.getArgument("value", Integer.class);
globalLevelingData.setLevel(newLevel);
return 1;
}

private static boolean hasPermission(CommandSourceStack commandSourceStack) {
return commandSourceStack.hasPermission(2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static void applyAttributeBonuses(LivingEntity entity) {

private static Map<Attribute, AttributeModifier> getAttributeBonuses(LivingEntity entity) {
LevelingSettings settings = getLevelingSettings(entity);
if (settings.attributeModifiers().isEmpty()) {
if (settings.attributeModifiers() == null || settings.attributeModifiers().isEmpty()) {
return Config.getAttributeBonuses();
}
return settings.attributeModifiers();
Expand Down