Skip to content

Commit 7c29285

Browse files
committed
there mr crosby
1 parent a817a17 commit 7c29285

3 files changed

Lines changed: 63 additions & 6 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3+
* Copyright (c) Meteor Development.
4+
*/
5+
6+
package meteordevelopment.meteorclient.commands.arguments;
7+
8+
import com.mojang.brigadier.StringReader;
9+
import com.mojang.brigadier.arguments.ArgumentType;
10+
import com.mojang.brigadier.context.CommandContext;
11+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
12+
import com.mojang.brigadier.suggestion.Suggestions;
13+
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
14+
import meteordevelopment.meteorclient.systems.modules.Modules;
15+
import meteordevelopment.meteorclient.systems.modules.render.LogoutSpots;
16+
import net.minecraft.commands.SharedSuggestionProvider;
17+
18+
import java.util.Collection;
19+
import java.util.List;
20+
import java.util.concurrent.CompletableFuture;
21+
22+
public class LogoutPlayerArgumentType implements ArgumentType<String> {
23+
private static final LogoutPlayerArgumentType INSTANCE = new LogoutPlayerArgumentType();
24+
25+
private static final Collection<String> EXAMPLES = List.of("seasnail8169", "MineGame159");
26+
27+
public static LogoutPlayerArgumentType create() {
28+
return INSTANCE;
29+
}
30+
31+
public static String get(CommandContext<?> context) {
32+
return context.getArgument("name", String.class);
33+
}
34+
35+
private LogoutPlayerArgumentType() {
36+
}
37+
38+
@Override
39+
public String parse(StringReader reader) throws CommandSyntaxException {
40+
return reader.readString();
41+
}
42+
43+
@Override
44+
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
45+
LogoutSpots logoutSpots = Modules.get().get(LogoutSpots.class);
46+
return SharedSuggestionProvider.suggest(logoutSpots.getLoggedOutPlayerNames(), builder);
47+
}
48+
49+
@Override
50+
public Collection<String> getExamples() {
51+
return EXAMPLES;
52+
}
53+
}

src/main/java/meteordevelopment/meteorclient/commands/commands/LogoutCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
package meteordevelopment.meteorclient.commands.commands;
77

8-
import com.mojang.brigadier.arguments.StringArgumentType;
98
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
109
import meteordevelopment.meteorclient.commands.Command;
10+
import meteordevelopment.meteorclient.commands.arguments.LogoutPlayerArgumentType;
1111
import meteordevelopment.meteorclient.systems.modules.Modules;
1212
import meteordevelopment.meteorclient.systems.modules.render.LogoutSpots;
1313
import meteordevelopment.meteorclient.utils.player.ChatUtils;
@@ -25,18 +25,18 @@ public void build(LiteralArgumentBuilder<ClientSuggestionProvider> builder) {
2525
builder.then(literal("clear")
2626
.executes(_ -> {
2727
logoutSpots.clearLogoutSpots();
28-
28+
2929
ChatUtils.info("Cleared all logout spots");
3030
return SINGLE_SUCCESS;
3131
})
3232
);
3333

3434
builder.then(literal("remove")
35-
.then(argument("name", StringArgumentType.word())
35+
.then(argument("name", LogoutPlayerArgumentType.create())
3636
.executes(context -> {
37-
String playerName = StringArgumentType.getString(context, "name");
37+
String playerName = LogoutPlayerArgumentType.get(context);
3838
boolean removed = logoutSpots.removeLogoutSpot(playerName);
39-
39+
4040
if (removed) {
4141
ChatUtils.info("Removed logout spot for player: " + playerName);
4242
} else {

src/main/java/meteordevelopment/meteorclient/systems/modules/render/LogoutSpots.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void onActivate() {
140140
public void onDeactivate() {
141141
if (clearOnDeactivate.get()) clearLogoutSpots();
142142
}
143-
143+
144144
private void updateLastPlayers() {
145145
lastPlayers.clear();
146146
for (Entity entity : mc.level.entitiesForRendering()) {
@@ -226,6 +226,10 @@ public boolean removeLogoutSpot(String playerName) {
226226
return players.removeIf(entry -> entry.name.equalsIgnoreCase(playerName));
227227
}
228228

229+
public List<String> getLoggedOutPlayerNames() {
230+
return players.stream().map(entry -> entry.name).toList();
231+
}
232+
229233
private static final Vector3d pos = new Vector3d();
230234

231235
private class Entry {

0 commit comments

Comments
 (0)