mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 21:06:16 +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.CommandDispatcher;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
|
||||||
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
import static com.mojang.brigadier.arguments.StringArgumentType.*;
|
||||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
|
||||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||||
|
|
||||||
|
|
@ -35,8 +34,8 @@ public class UsernameCommand {
|
||||||
.then(
|
.then(
|
||||||
literal("set")
|
literal("set")
|
||||||
.then(
|
.then(
|
||||||
argument("username", greedyString())
|
argument("username", string())
|
||||||
.executes(c -> updateUsername(c))
|
.executes(UsernameCommand::updateUsername)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
|
|
@ -53,7 +52,7 @@ public class UsernameCommand {
|
||||||
return updateSession(context, session);
|
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 FabricClientCommandSource source = context.getSource();
|
||||||
|
|
||||||
final MinecraftClient client = source.getClient();
|
final MinecraftClient client = source.getClient();
|
||||||
|
|
@ -62,7 +61,7 @@ public class UsernameCommand {
|
||||||
|
|
||||||
// TODO: Put this in a separate class
|
// TODO: Put this in a separate class
|
||||||
final ServerInfo info = client.getCurrentServerEntry();
|
final ServerInfo info = client.getCurrentServerEntry();
|
||||||
client.world.disconnect();
|
if (client.world != null) client.world.disconnect();
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false, null);
|
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false, null);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue