Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get rung command #498

Merged
merged 13 commits into from
Nov 16, 2023
32 changes: 32 additions & 0 deletions src/main/java/com/mraof/minestuck/command/GetRungCommand.java
GideonHead marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mraof.minestuck.command;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.context.CommandContextBuilder;
import com.mraof.minestuck.player.PlayerSavedData;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;

import static org.stringtemplate.v4.compiler.STLexer.str;

public class GetRungCommand
{
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
{
dispatcher.register(Commands.literal("getrung").then(Commands.argument("target", EntityArgument.player())
.executes(GetRungCommand::executeGetRung)));
}

public static int executeGetRung(CommandContext<CommandSourceStack> context)
{
ServerPlayer player = context.getSource().getPlayer();
GideonHead marked this conversation as resolved.
Show resolved Hide resolved
String playerName = player.getScoreboardName();
Integer rungInt = PlayerSavedData.getData(player).getEcheladder().getRung();

context.getSource().sendSuccess(() -> Component.literal(playerName + "'s Current Echeladder Rung is " + rungInt.toString()), false);
return rungInt;
}
}
1 change: 1 addition & 0 deletions src/main/java/com/mraof/minestuck/command/MSCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static void serverStarting(RegisterCommandsEvent event)
SburbPredefineCommand.register(dispatcher);
SburbConnectionCommand.register(dispatcher);
SetRungCommand.register(dispatcher);
GetRungCommand.register(dispatcher);
ConsortReplyCommand.register(dispatcher);
PorkhollowCommand.register(dispatcher);
DebugLandsCommand.register(dispatcher);
Expand Down
Loading