generated from MeteorDevelopment/meteor-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayerInfo.java
More file actions
63 lines (52 loc) · 2.33 KB
/
PlayerInfo.java
File metadata and controls
63 lines (52 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package huhncode.lucid.lucidaddon.modules;
import huhncode.lucid.lucidaddon.LucidAddon;
import meteordevelopment.meteorclient.events.game.SendMessageEvent;
import meteordevelopment.meteorclient.gui.GuiThemes;
import meteordevelopment.meteorclient.gui.screens.WidgetScreen; // Use WidgetScreen
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class PlayerInfo extends Module {
public PlayerInfo() {
super(LucidAddon.CATEGORY, "player-info", "Displays a GUI with information about a player.");
}
@EventHandler
private void onChatMessage(SendMessageEvent event) {
if (!event.message.startsWith(".info ")) return;
String playerName = event.message.substring(6).trim();
PlayerListEntry player = mc.getNetworkHandler().getPlayerList().stream()
.filter(p -> p.getProfile().getName().equalsIgnoreCase(playerName))
.findFirst()
.orElse(null);
if (player == null) {
info("Player not found: " + playerName);
return;
}
// Show the custom WidgetScreen GUI
mc.execute(() -> mc.setScreen(new PlayerInfoScreen(player)));
event.cancel();
}
private static class PlayerInfoScreen extends WidgetScreen { // WidgetScreen instead of WScreen
private final PlayerListEntry player;
public PlayerInfoScreen(PlayerListEntry player) {
this.player = player;
}
@Override
public void init() {
// Initialize the GUI and widgets
WVerticalList list = new WVerticalList();
list.add(theme.label(Text.of("Player name: " + player.getProfile().getName())));
list.add(theme.label(Text.of("Ping: " + player.getLatency() + " ms")));
// More information can be added here
this.add(list); // Add the widget
}
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
super.render(matrices, mouseX, mouseY, delta);
}
}
}