forked from ChomeNS/chipmunkmod
i forgot but uhh a bunch of stuff prbobaly
This commit is contained in:
parent
ce49c7238c
commit
bc35032c02
10 changed files with 47 additions and 525 deletions
|
@ -38,7 +38,7 @@ public class CommandManager {
|
|||
SayCommand.register(this.dispatcher);
|
||||
AutoSkinCommand.register(this.dispatcher);
|
||||
ReloadConfigCommand.register(this.dispatcher);
|
||||
LoopCrouchCommand.register(this.dispatcher);
|
||||
// LoopCrouchCommand.register(this.dispatcher); // ^???????????????????
|
||||
AutoDeopCommand.register(this.dispatcher);
|
||||
DebugCommand.register(this.dispatcher);
|
||||
ClearAntiChatSpamQueueCommand.register(this.dispatcher);
|
||||
|
|
|
@ -25,107 +25,4 @@ public class ValidateCommand {
|
|||
.then(literal("kittycorp").then(argument("command", greedyString()).executes(c -> kittycorp(getString(c, "command")))))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static int hbot (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.hbot;
|
||||
final String command = getString(context, "command");
|
||||
final MinecraftClient client = context.getSource().getClient();
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 10000);
|
||||
String input = command.replaceAll("&[0-9a-fklmnor]", "") + ";" + client.player.getUuidAsString() + ";" + time + ";" + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||
|
||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int sbot (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.sbot;
|
||||
final String command = getString(context, "command");
|
||||
final MinecraftClient client = context.getSource().getClient();
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 20000);
|
||||
String input = prefix + command.replaceAll("&[0-9a-fklmnorx]", "") + ";" + client.player.getName() + ";" + time + ";" + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||
|
||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int chomens (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens;
|
||||
final String command = getString(context, "command");
|
||||
final ClientPlayNetworkHandler networkHandler = context.getSource().getClient().getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 5000);
|
||||
String input = time + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
String stringHash = Hexadecimal.encode(hash).substring(0, 16);
|
||||
|
||||
String[] arguments = command.split(" ");
|
||||
networkHandler.sendChatMessage(prefix + arguments[0] + " " + stringHash + " " + String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length)));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int kittycorp (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.kittycorp;
|
||||
final String command = getString(context, "command");
|
||||
final ClientPlayNetworkHandler networkHandler = context.getSource().getClient().getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 10000);
|
||||
String input = prefix + command.replaceAll("&[0-9a-fklmnorx]", "") + ";" + time + ";" + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||
|
||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class ChatHudMixin {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
if (RainbowName.INSTANCE.enabled()) {
|
||||
if (RainbowName.INSTANCE.enabled) {
|
||||
if (message.getString().contains("Your nickname is now ") || message.getString().contains("Nickname changed.")) {
|
||||
ci.cancel();
|
||||
return;
|
||||
|
|
|
@ -7,6 +7,8 @@ import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
|||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
||||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
|
||||
import land.chipmunk.chipmunkmod.util.Executor;
|
||||
import land.chipmunk.chipmunkmod.util.Webhook;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
@ -38,43 +40,11 @@ public class ChatScreenMixin extends Screen {
|
|||
@Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true)
|
||||
public void sendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
|
||||
if(ChipmunkMod.CONFIG.testbotWebhook != null && chatText.startsWith("-")) {
|
||||
new Thread(() -> {
|
||||
Webhook webhook = new Webhook(ChipmunkMod.CONFIG.testbotWebhook);
|
||||
webhook.setUsername("ChipmunkMod");
|
||||
webhook.setContent(ChipmunkMod.CONFIG.defaultUsername);
|
||||
Executor.service.submit(() -> {
|
||||
try {
|
||||
webhook.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
if (ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && chatText.startsWith(ChipmunkMod.CONFIG.bots.testbot.prefix)) {
|
||||
ChipmunkMod.executorService.submit(() -> {
|
||||
try {
|
||||
final URL url = new URL(ChipmunkMod.CONFIG.bots.testbot.webhookUrl);
|
||||
|
||||
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("User-Agent", "ChipmunkMod");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
|
||||
final JsonObject jsonObject = new JsonObject();
|
||||
|
||||
jsonObject.addProperty("username", "ChipmunkMod UwU");
|
||||
jsonObject.addProperty("content", MinecraftClient.getInstance().getSession().getUsername());
|
||||
|
||||
final OutputStream stream = connection.getOutputStream();
|
||||
stream.write(jsonObject.toString().getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
|
||||
connection.getInputStream().close();
|
||||
connection.disconnect();
|
||||
Webhook.send(ChipmunkMod.CONFIG.testbotWebhook, ChipmunkMod.CONFIG.defaultUsername);
|
||||
} catch (IOException e) {
|
||||
ChipmunkMod.LOGGER.error("fard webhook url !!!t");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
@ -92,18 +62,28 @@ public class ChatScreenMixin extends Screen {
|
|||
|
||||
cir.setReturnValue(true);
|
||||
|
||||
if(addToHistory) {
|
||||
assert client != null;
|
||||
client.inGameHud.getChatHud().addToMessageHistory(chatText);
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
if (chatText.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
|
||||
|
||||
if (addToHistory) MinecraftClient.getInstance().inGameHud.getChatHud().addToMessageHistory(chatText);
|
||||
|
||||
cir.setReturnValue(true);
|
||||
} else if (!chatText.startsWith("/")) {
|
||||
CustomChat.INSTANCE.chat(chatText);
|
||||
|
||||
if (addToHistory) MinecraftClient.getInstance().inGameHud.getChatHud().addToMessageHistory(chatText);
|
||||
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +116,6 @@ public class ChatScreenMixin extends Screen {
|
|||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void onChatFieldUpdate(String chatText) {
|
||||
String string = this.chatField.getText();
|
||||
this.chatInputSuggestor.setWindowActive(!string.equals(this.originalChatText));
|
||||
|
|
|
@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin;
|
|||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
|
||||
|
@ -9,6 +10,7 @@ import land.chipmunk.chipmunkmod.testclient.modules.utility.AntiParticleKickModu
|
|||
import land.chipmunk.chipmunkmod.util.Chat;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
|
||||
import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
|
||||
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
|
||||
|
@ -75,7 +77,7 @@ public class ClientConnectionMixin {
|
|||
@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
|
||||
private void sendPacket (Packet<?> packet, CallbackInfo ci) {
|
||||
if (packet instanceof RequestCommandCompletionsC2SPacket t_packet) {
|
||||
if (t_packet.getPartialCommand().length() > 2048) { // o thanks fancy
|
||||
if (t_packet.getPartialCommand().length() > 2048) { // why was this comment here
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.modules.LoopCrouch;
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.client.input.KeyboardInput;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
|
@ -33,11 +32,11 @@ public class KeyboardInputMixin extends Input {
|
|||
this.movementSideways = getMovementMultiplier(this.pressingLeft, this.pressingRight);
|
||||
this.jumping = this.settings.jumpKey.isPressed();
|
||||
|
||||
// ohio code
|
||||
this.sneaking = LoopCrouch.INSTANCE.enabled() ?
|
||||
!LoopCrouch.INSTANCE.sneaking() :
|
||||
this.settings.sneakKey.isPressed();
|
||||
LoopCrouch.INSTANCE.sneaking(!LoopCrouch.INSTANCE.sneaking());
|
||||
// wtf loopcrougchs gone??????????????
|
||||
// this.sneaking = LoopCrouch.INSTANCE.enabled() ?
|
||||
// !LoopCrouch.INSTANCE.sneaking() :
|
||||
// this.settings.sneakKey.isPressed();
|
||||
// LoopCrouch.INSTANCE.sneaking(!LoopCrouch.INSTANCE.sneaking());
|
||||
|
||||
if (slowDown) {
|
||||
this.movementSideways *= f;
|
||||
|
|
|
@ -17,6 +17,6 @@ public class TextSerializerMixin {
|
|||
@Inject(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/text/MutableText;", at = @At("HEAD"), cancellable = true)
|
||||
private void testclient$preventChatOverflowExploit(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<MutableText> cir) {
|
||||
Throwable throwable = new Throwable();
|
||||
if(throwable.getStackTrace().length >= 1000 && throwable.getStackTrace()[999].getMethodName().equals("deserialize")) cir.setReturnValue(Text.literal("TestClient prevented a text overflow exploit i think ("+throwable.getStackTrace().length+")").formatted(Formatting.GOLD));
|
||||
if(throwable.getStackTrace().length >= 700) cir.setReturnValue(Text.literal("TestClient prevented a text overflow exploit i think ("+throwable.getStackTrace().length+")").formatted(Formatting.GOLD));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ public class AntiChatSpamModule extends Module {
|
|||
|
||||
|
||||
public static class ChatMessage {
|
||||
@Getter
|
||||
private final String content;
|
||||
private @Getter final String content;
|
||||
public boolean hidden = false;
|
||||
public int timer = ChipmunkMod.CONFIG.antiSpam.messageTimeInTicks;
|
||||
|
||||
|
@ -47,7 +46,7 @@ public class AntiChatSpamModule extends Module {
|
|||
for (int i = 0; i < chatMessages.size(); i++) {
|
||||
ChatMessage message = chatMessages.get(i);
|
||||
if(message == null) continue;
|
||||
int distance = ld.apply(this.content(), message.content());
|
||||
int distance = ld.apply(this.getContent(), message.getContent());
|
||||
Debug.debug("Distance: " + distance, debugLevenshteinDistanceCaller);
|
||||
if (distance <= ChipmunkMod.CONFIG.antiSpam.minimumLevenshteinDistanceToBeSpam) similarMessages++;
|
||||
// Pattern pattern = getPattern(new ComparableString(this.content()), new ComparableString(message.content()));
|
||||
|
|
|
@ -1,391 +1,39 @@
|
|||
package land.chipmunk.chipmunkmod.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
// i am sure blackilykat did not write this - chayapak
|
||||
// i am sure you did not write this either - blackilykat
|
||||
|
||||
/**
|
||||
* Class used to execute Discord Webhooks with low effort
|
||||
* unskidded 25/07/2023
|
||||
*/
|
||||
public class Webhook {
|
||||
|
||||
private final String url;
|
||||
private String content;
|
||||
private String username;
|
||||
private String avatarUrl;
|
||||
private boolean tts;
|
||||
private List<EmbedObject> embeds = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructs a new DiscordWebhook instance
|
||||
*
|
||||
* @param url The webhook URL obtained in Discord
|
||||
*/
|
||||
public Webhook(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public void setTts(boolean tts) {
|
||||
this.tts = tts;
|
||||
}
|
||||
|
||||
public void addEmbed(EmbedObject embed) {
|
||||
this.embeds.add(embed);
|
||||
}
|
||||
|
||||
public void execute() throws IOException {
|
||||
if (this.content == null && this.embeds.isEmpty()) {
|
||||
throw new IllegalArgumentException("Set content or add at least one EmbedObject");
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
json.put("content", this.content);
|
||||
json.put("username", this.username);
|
||||
json.put("avatar_url", this.avatarUrl);
|
||||
json.put("tts", this.tts);
|
||||
|
||||
if (!this.embeds.isEmpty()) {
|
||||
List<JSONObject> embedObjects = new ArrayList<>();
|
||||
|
||||
for (EmbedObject embed : this.embeds) {
|
||||
JSONObject jsonEmbed = new JSONObject();
|
||||
|
||||
jsonEmbed.put("title", embed.getTitle());
|
||||
jsonEmbed.put("description", embed.getDescription());
|
||||
jsonEmbed.put("url", embed.getUrl());
|
||||
|
||||
if (embed.getColor() != null) {
|
||||
Color color = embed.getColor();
|
||||
int rgb = color.getRed();
|
||||
rgb = (rgb << 8) + color.getGreen();
|
||||
rgb = (rgb << 8) + color.getBlue();
|
||||
|
||||
jsonEmbed.put("color", rgb);
|
||||
}
|
||||
|
||||
EmbedObject.Footer footer = embed.getFooter();
|
||||
EmbedObject.Image image = embed.getImage();
|
||||
EmbedObject.Thumbnail thumbnail = embed.getThumbnail();
|
||||
EmbedObject.Author author = embed.getAuthor();
|
||||
List<EmbedObject.Field> fields = embed.getFields();
|
||||
|
||||
if (footer != null) {
|
||||
JSONObject jsonFooter = new JSONObject();
|
||||
|
||||
jsonFooter.put("text", footer.getText());
|
||||
jsonFooter.put("icon_url", footer.getIconUrl());
|
||||
jsonEmbed.put("footer", jsonFooter);
|
||||
}
|
||||
|
||||
if (image != null) {
|
||||
JSONObject jsonImage = new JSONObject();
|
||||
|
||||
jsonImage.put("url", image.getUrl());
|
||||
jsonEmbed.put("image", jsonImage);
|
||||
}
|
||||
|
||||
if (thumbnail != null) {
|
||||
JSONObject jsonThumbnail = new JSONObject();
|
||||
|
||||
jsonThumbnail.put("url", thumbnail.getUrl());
|
||||
jsonEmbed.put("thumbnail", jsonThumbnail);
|
||||
}
|
||||
|
||||
if (author != null) {
|
||||
JSONObject jsonAuthor = new JSONObject();
|
||||
|
||||
jsonAuthor.put("name", author.getName());
|
||||
jsonAuthor.put("url", author.getUrl());
|
||||
jsonAuthor.put("icon_url", author.getIconUrl());
|
||||
jsonEmbed.put("author", jsonAuthor);
|
||||
}
|
||||
|
||||
List<JSONObject> jsonFields = new ArrayList<>();
|
||||
for (EmbedObject.Field field : fields) {
|
||||
JSONObject jsonField = new JSONObject();
|
||||
|
||||
jsonField.put("name", field.getName());
|
||||
jsonField.put("value", field.getValue());
|
||||
jsonField.put("inline", field.isInline());
|
||||
|
||||
jsonFields.add(jsonField);
|
||||
}
|
||||
|
||||
jsonEmbed.put("fields", jsonFields.toArray());
|
||||
embedObjects.add(jsonEmbed);
|
||||
}
|
||||
|
||||
json.put("embeds", embedObjects.toArray());
|
||||
}
|
||||
|
||||
URL url = new URL(this.url);
|
||||
public static void send(String surl, String message) throws IOException {
|
||||
Gson gson = new Gson();
|
||||
JsonObject obj = new JsonObject();
|
||||
URL url = new URL(surl);
|
||||
obj.addProperty("content", message);
|
||||
obj.addProperty("username", "chipmunkmod blackilykat fork (uwu)");
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("User-Agent", "Java-DiscordWebhook-BY-Gelox_");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(json.toString().getBytes());
|
||||
connection.addRequestProperty("User-Agent", "chipmunkmod blackilykat fork (uwu)");
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.setDoOutput(true);
|
||||
final OutputStream stream = connection.getOutputStream();
|
||||
stream.write(obj.toString().getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
|
||||
connection.getInputStream().close(); //I'm not sure why but it doesn't work without getting the InputStream
|
||||
connection.disconnect();
|
||||
connection.getInputStream().close();
|
||||
}
|
||||
|
||||
public static class EmbedObject {
|
||||
private String title;
|
||||
private String description;
|
||||
private String url;
|
||||
private Color color;
|
||||
|
||||
private Footer footer;
|
||||
private Thumbnail thumbnail;
|
||||
private Image image;
|
||||
private Author author;
|
||||
private List<Field> fields = new ArrayList<>();
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Footer getFooter() {
|
||||
return footer;
|
||||
}
|
||||
|
||||
public Thumbnail getThumbnail() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public List<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public EmbedObject setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setUrl(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setColor(Color color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setFooter(String text, String icon) {
|
||||
this.footer = new Footer(text, icon);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setThumbnail(String url) {
|
||||
this.thumbnail = new Thumbnail(url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setImage(String url) {
|
||||
this.image = new Image(url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setAuthor(String name, String url, String icon) {
|
||||
this.author = new Author(name, url, icon);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject addField(String name, String value, boolean inline) {
|
||||
this.fields.add(new Field(name, value, inline));
|
||||
return this;
|
||||
}
|
||||
|
||||
private class Footer {
|
||||
private String text;
|
||||
private String iconUrl;
|
||||
|
||||
private Footer(String text, String iconUrl) {
|
||||
this.text = text;
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
private String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
private String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
}
|
||||
|
||||
private class Thumbnail {
|
||||
private String url;
|
||||
|
||||
private Thumbnail(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
private String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
private class Image {
|
||||
private String url;
|
||||
|
||||
private Image(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
private String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
private class Author {
|
||||
private String name;
|
||||
private String url;
|
||||
private String iconUrl;
|
||||
|
||||
private Author(String name, String url, String iconUrl) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
private String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
}
|
||||
|
||||
private class Field {
|
||||
private String name;
|
||||
private String value;
|
||||
private boolean inline;
|
||||
|
||||
private Field(String name, String value, boolean inline) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.inline = inline;
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private boolean isInline() {
|
||||
return inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class JSONObject {
|
||||
|
||||
private final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
void put(String key, Object value) {
|
||||
if (value != null) {
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Set<Map.Entry<String, Object>> entrySet = map.entrySet();
|
||||
builder.append("{");
|
||||
|
||||
int i = 0;
|
||||
for (Map.Entry<String, Object> entry : entrySet) {
|
||||
Object val = entry.getValue();
|
||||
builder.append(quote(entry.getKey())).append(":");
|
||||
|
||||
if (val instanceof String) {
|
||||
builder.append(quote(String.valueOf(val)));
|
||||
} else if (val instanceof Integer) {
|
||||
builder.append(Integer.valueOf(String.valueOf(val)));
|
||||
} else if (val instanceof Boolean) {
|
||||
builder.append(val);
|
||||
} else if (val instanceof JSONObject) {
|
||||
builder.append(val.toString());
|
||||
} else if (val.getClass().isArray()) {
|
||||
builder.append("[");
|
||||
int len = Array.getLength(val);
|
||||
for (int j = 0; j < len; j++) {
|
||||
builder.append(Array.get(val, j).toString()).append(j != len - 1 ? "," : "");
|
||||
}
|
||||
builder.append("]");
|
||||
}
|
||||
|
||||
builder.append(++i == entrySet.size() ? "}" : ",");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String quote(String string) {
|
||||
return "\"" + string + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
"ClientConnectionMixin",
|
||||
"ClientPlayerEntityMixin",
|
||||
"ClientPlayNetworkHandlerAccessor",
|
||||
"ClientPlayNetworkHandlerInvoker",
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"MinecraftClientAccessor",
|
||||
"DecoderHandlerMixin",
|
||||
|
@ -24,7 +23,6 @@
|
|||
"IdentifierMixin",
|
||||
"KeyboardInputMixin",
|
||||
"KeyboardMixin",
|
||||
"LightmapTextureManagerMixin",
|
||||
"MinecraftClientAccessor",
|
||||
"MultiplayerScreenMixin",
|
||||
"NbtIoMixin",
|
||||
|
|
Loading…
Reference in a new issue