mirror of
https://github.com/Miasmusa/Shadow.git
synced 2024-11-14 19:04:54 -05:00
the crash reporting
This commit is contained in:
parent
e00698489c
commit
027d336566
4 changed files with 51 additions and 11 deletions
|
@ -31,6 +31,8 @@ import java.awt.Font;
|
|||
import java.awt.FontFormatException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -46,11 +48,22 @@ public class ShadowMain implements ModInitializer {
|
|||
public static ShadowMain INSTANCE;
|
||||
public static Thread MODULE_FTTICKER;
|
||||
public static Thread FAST_TICKER;
|
||||
private static final String REPORT_WEBHOOK_URL = "https://discord.com/api/webhooks/965394668391120946/67JFtMRmSACbpwIa-TG6r8GzMKVYw-wchXUJA_L-mJ_jTzwOucO7SgdKddvUxy0WNTht";
|
||||
|
||||
public static void log(Level level, String message) {
|
||||
LOGGER.log(level, "[" + MOD_NAME + "] " + message);
|
||||
}
|
||||
|
||||
public static void sendCrashReport(String reportData) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
|
||||
String fmt = sdf.format(System.currentTimeMillis());
|
||||
try {
|
||||
Utils.sendDiscordFile(REPORT_WEBHOOK_URL,String.format("Crash report submitted by **%s** (**%s**) at `%s` (h\\\\:m\\\\:s d/m/y) <@&965396880286707732>", client.getSession().getUsername(), client.getSession().getUuid(),fmt),"crash.txt",reportData.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
INSTANCE = this;
|
||||
|
@ -156,4 +169,4 @@ public class ShadowMain implements ModInitializer {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
|
||||
package net.shadow.client.feature.command.impl;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.text.Text;
|
||||
import io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess;
|
||||
import net.shadow.client.feature.command.Command;
|
||||
import net.shadow.client.helper.util.Utils;
|
||||
|
||||
public class Test extends Command {
|
||||
public Test() {
|
||||
|
@ -19,9 +14,6 @@ public class Test extends Command {
|
|||
|
||||
@Override
|
||||
public void onExecute(String[] args) {
|
||||
Utils.TickManager.runOnNextRender(() -> {
|
||||
GenericContainerScreenHandler gcsh = new GenericContainerScreenHandler(ScreenHandlerType.GENERIC_9X5, client.player.currentScreenHandler.syncId, client.player.getInventory(), new SimpleInventory(46), 5);
|
||||
client.setScreen(new GenericContainerScreen(gcsh, client.player.getInventory(), Text.of("REAL")));
|
||||
});
|
||||
UnsafeAccess.UNSAFE.throwException(new ClassFormatError("AMONG US SUSSY!!!"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,11 +38,13 @@ import java.awt.Color;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -61,6 +63,31 @@ public class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
public static void sendDiscordFile(String url, String msgContent, String filename, byte[] file) throws IOException, InterruptedException {
|
||||
long e = System.currentTimeMillis();
|
||||
byte[] body1 = ("----" + e + "\n" +
|
||||
"Content-Disposition: form-data; name=\"file\"; filename=\"" + filename + "\"\n" +
|
||||
"Content-Type: text/plain\n\n").getBytes(StandardCharsets.UTF_8);
|
||||
byte[] body2 = ("\n" +
|
||||
"----" + e + "\n" +
|
||||
"Content-Disposition: form-data; name=\"payload_json\"\n" +
|
||||
"\n" +
|
||||
"{\"content\":\""+msgContent+"\",\"tts\":false}\n" +
|
||||
"----" + e + "--\n").getBytes(StandardCharsets.UTF_8);
|
||||
byte[] finalBody = new byte[body1.length + file.length + body2.length];
|
||||
System.arraycopy(body1, 0, finalBody, 0, body1.length);
|
||||
System.arraycopy(file, 0, finalBody, body1.length, file.length);
|
||||
System.arraycopy(body2, 0, finalBody, body1.length + file.length, body2.length);
|
||||
HttpClient real = HttpClient.newBuilder().build();
|
||||
HttpRequest req = HttpRequest.newBuilder()
|
||||
.POST(HttpRequest.BodyPublishers.ofByteArray(finalBody))
|
||||
.uri(URI.create(url))
|
||||
.header("User-Agent", "your mother")
|
||||
.header("Content-Type", "multipart/form-data; boundary=--" + e).build();
|
||||
System.out.println(real.send(req, HttpResponse.BodyHandlers.ofString()).body());
|
||||
}
|
||||
|
||||
|
||||
public static void setClientTps(float tps) {
|
||||
IRenderTickCounterAccessor accessor = ((IRenderTickCounterAccessor) ((IMinecraftClientAccessor) ShadowMain.client).getRenderTickCounter());
|
||||
accessor.setTickTime(1000f / tps);
|
||||
|
|
|
@ -7,6 +7,7 @@ package net.shadow.client.mixin;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.RunArgs;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.shadow.client.ShadowMain;
|
||||
import net.shadow.client.feature.module.ModuleRegistry;
|
||||
import net.shadow.client.feature.module.impl.world.FastUse;
|
||||
|
@ -14,6 +15,7 @@ import net.shadow.client.helper.event.EventType;
|
|||
import net.shadow.client.helper.event.Events;
|
||||
import net.shadow.client.helper.event.events.base.NonCancellableEvent;
|
||||
import net.shadow.client.helper.manager.ConfigManager;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -53,4 +55,10 @@ public class MinecraftClientMixin {
|
|||
return this.itemUseCooldown;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method="printCrashReport",at=@At("HEAD"))
|
||||
private static void addCrashReport(CrashReport report, CallbackInfo ci) {
|
||||
ShadowMain.sendCrashReport(report.asString());
|
||||
ShadowMain.log(Level.INFO, "Crash report submitted to discord");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue