aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--src/main/java/world/anhgelus/lifesteal/Commands.java18
-rw-r--r--src/main/java/world/anhgelus/lifesteal/LifeSteal.java1
3 files changed, 24 insertions, 1 deletions
diff --git a/README.md b/README.md
index e187771..152cdd6 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
LifeSteal is a server-side mod recreating the LifeSteal SMP experience.
+Players can withdraw hearts with `/withdraw <amount>`.
+
The number of maximum hearts can be set via the gamerule `lifesteal:maxHearts` (default: 20).
The grace period is the period when the PvP is deactivated.
@@ -13,4 +15,6 @@ Hearts cannot be crafted by a player at/above 10 hearts.
You can disable this via the gamerule `lifesteal:canCraftHeartsAboveVanillaMax` (default: false).
Hearts cannot be stored in ender chests.
-You can disable this via the gamerule `lifesteal:canStoreHeartsInEC` (default: false). \ No newline at end of file
+You can disable this via the gamerule `lifesteal:canStoreHeartsInEC` (default: false).
+
+Operators can use `/gethearts <amount>` to get hearts. \ No newline at end of file
diff --git a/src/main/java/world/anhgelus/lifesteal/Commands.java b/src/main/java/world/anhgelus/lifesteal/Commands.java
index 5bf10c5..6accf8d 100644
--- a/src/main/java/world/anhgelus/lifesteal/Commands.java
+++ b/src/main/java/world/anhgelus/lifesteal/Commands.java
@@ -34,4 +34,22 @@ public class Commands {
dispatcher.register(cmd);
}
+
+ public static void registerGetHearts(CommandDispatcher<ServerCommandSource> dispatcher) {
+ final var cmd = literal("gethearts")
+ .requires(s -> s.hasPermissionLevel(3))
+ .then(argument("hearts", IntegerArgumentType.integer(1))
+ .executes(context -> {
+ final var source = context.getSource();
+ final var hearts = IntegerArgumentType.getInteger(context, "hearts");
+ final var p = source.getPlayerOrThrow();
+ final var lifeStealer = LifeStealer.Manager.getLifeStealer(p);
+ p.giveOrDropStack(lifeStealer.getHeart().copyWithCount(hearts));
+ source.sendFeedback(() -> Text.of("Hearts given."), false);
+ return Command.SINGLE_SUCCESS;
+ })
+ );
+
+ dispatcher.register(cmd);
+ }
}
diff --git a/src/main/java/world/anhgelus/lifesteal/LifeSteal.java b/src/main/java/world/anhgelus/lifesteal/LifeSteal.java
index cc1b4eb..7fb5b33 100644
--- a/src/main/java/world/anhgelus/lifesteal/LifeSteal.java
+++ b/src/main/java/world/anhgelus/lifesteal/LifeSteal.java
@@ -78,6 +78,7 @@ public class LifeSteal implements ModInitializer {
CommandRegistrationCallback.EVENT.register((CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) -> {
Commands.registerWithdraw(dispatcher);
+ Commands.registerGetHearts(dispatcher);
});
ServerLifecycleEvents.SERVER_STARTED.register(server -> {