mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 18:46:15 +00:00
refactor: make .username set <username> only a string instead of a greedy string so we can set our username to an empty string for the funnies
This commit is contained in:
parent
88cca61fe2
commit
c5fbd67510
1 changed files with 5 additions and 6 deletions
|
|
@ -4,8 +4,7 @@ import com.mojang.brigadier.Command;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.*;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
|
||||
|
|
@ -35,8 +34,8 @@ public class UsernameCommand {
|
|||
.then(
|
||||
literal("set")
|
||||
.then(
|
||||
argument("username", greedyString())
|
||||
.executes(c -> updateUsername(c))
|
||||
argument("username", string())
|
||||
.executes(UsernameCommand::updateUsername)
|
||||
)
|
||||
)
|
||||
.then(
|
||||
|
|
@ -53,7 +52,7 @@ public class UsernameCommand {
|
|||
return updateSession(context, session);
|
||||
}
|
||||
|
||||
public static int updateSession(CommandContext<FabricClientCommandSource> context, Session session) throws CommandSyntaxException {
|
||||
public static int updateSession(CommandContext<FabricClientCommandSource> context, Session session) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
final MinecraftClient client = source.getClient();
|
||||
|
|
@ -62,7 +61,7 @@ public class UsernameCommand {
|
|||
|
||||
// TODO: Put this in a separate class
|
||||
final ServerInfo info = client.getCurrentServerEntry();
|
||||
client.world.disconnect();
|
||||
if (client.world != null) client.world.disconnect();
|
||||
client.disconnect();
|
||||
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false, null);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue