-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d962d38
commit 2b93e7c
Showing
3 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
src/main/java/com/insertsoda/craterchat/commands/HpCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.insertsoda.craterchat.commands; | ||
|
||
import com.insertsoda.craterchat.CraterChat; | ||
import com.insertsoda.craterchat.api.v1.Command; | ||
import com.insertsoda.craterchat.api.v1.CommandManager; | ||
import com.insertsoda.craterchat.api.v1.CommandSource; | ||
import com.insertsoda.craterchat.api.v1.arguments.types.RelativeFloatType; | ||
import com.mojang.brigadier.arguments.FloatArgumentType; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import finalforeach.cosmicreach.gamestates.InGame; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public class HpCommand implements Command { | ||
@Override | ||
public void register(LiteralArgumentBuilder<CommandSource> literalArgumentBuilder) { | ||
literalArgumentBuilder.then( | ||
CommandManager.literal("add").then( | ||
CommandManager.argument("amount", FloatArgumentType.floatArg()).executes(context -> { | ||
float amount = FloatArgumentType.getFloat(context, "amount"); | ||
context.getSource().getPlayer().getEntity().hit(-amount); | ||
CraterChat.Chat.sendMessage("Added " + amount + " hp"); | ||
return 1; | ||
}) | ||
) | ||
).then( | ||
CommandManager.literal("remove").then( | ||
CommandManager.argument("amount", FloatArgumentType.floatArg()).executes(context -> { | ||
float amount = FloatArgumentType.getFloat(context, "amount"); | ||
context.getSource().getPlayer().getEntity().hit(amount); | ||
CraterChat.Chat.sendMessage("Removed " + amount + " hp"); | ||
return 1; | ||
}) | ||
) | ||
).then( | ||
CommandManager.literal("set").then( | ||
CommandManager.argument("amount", FloatArgumentType.floatArg()).executes(context -> { | ||
float amount = FloatArgumentType.getFloat(context, "amount"); | ||
context.getSource().getPlayer().getEntity().hitpoints = amount; | ||
CraterChat.Chat.sendMessage("Set hp to " + amount); | ||
return 1; | ||
}) | ||
) | ||
).then( | ||
CommandManager.literal("get").executes((context) -> { | ||
CraterChat.Chat.sendMessage("You currently have " + context.getSource().getPlayer().getEntity().hitpoints + " hp"); | ||
return 1; | ||
}) | ||
); | ||
} | ||
|
||
@Override | ||
public @NotNull String getName() { | ||
return "hp"; | ||
} | ||
|
||
@Override | ||
public @Nullable String getDescription() { | ||
return "Add, remove, set or get the player's hp"; | ||
} | ||
|
||
@Override | ||
public String getPossibleArguments() { | ||
return "add|remove|set|get <amount>"; | ||
} | ||
|
||
@Override | ||
public List<String> getAliases() { | ||
return List.of("health"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/insertsoda/craterchat/commands/KillCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.insertsoda.craterchat.commands; | ||
|
||
import com.insertsoda.craterchat.api.v1.Command; | ||
import com.insertsoda.craterchat.api.v1.CommandSource; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class KillCommand implements Command { | ||
|
||
@Override | ||
public void register(LiteralArgumentBuilder<CommandSource> literalArgumentBuilder) { | ||
literalArgumentBuilder.executes(context -> { | ||
context.getSource().getPlayer().getEntity().hitpoints = 0; | ||
return 1; | ||
}); | ||
} | ||
|
||
@Override | ||
public @NotNull String getName() { | ||
return "kill"; | ||
} | ||
|
||
@Override | ||
public @Nullable String getDescription() { | ||
return "Kills the player"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters