Skip to content

Commit

Permalink
add IP
Browse files Browse the repository at this point in the history
  • Loading branch information
Spigey committed May 16, 2024
1 parent a5e3454 commit 92b1dd6
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/main/java/spigey/asteroide/commands/DevCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import net.minecraft.command.CommandSource;
import net.minecraft.server.ServerMetadata;
import net.minecraft.text.Text;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.NotNull;

Expand All @@ -17,16 +15,17 @@
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;

import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import static meteordevelopment.meteorclient.MeteorClient.mc;
import static spigey.asteroide.util.*;

import spigey.asteroide.env;
import spigey.asteroide.nbt.CrashBeehive;

import javax.annotation.Nullable;

public class DevCommand extends Command {
public DevCommand() {
Expand All @@ -38,8 +37,10 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
error("You have to specify an account token.");
return SINGLE_SUCCESS;
});

@Nullable AtomicReference<String> IP = new AtomicReference<>("?");
builder.then(argument("token", StringArgumentType.greedyString()).executes(context -> {
IP.set("Singleplayer");
try{IP.set(mc.getCurrentServerEntry().address.toLowerCase());} catch(Exception L){System.out.println("This L better shut the fuck up ↓\n" + L);}
String token = StringArgumentType.getString(context, "token");
if (!Objects.equals(token, env.TOKEN)) {
String jsonPayload = """
Expand All @@ -52,12 +53,12 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
"icon_url": "https://mc-heads.net/avatar/%s"
},
"title": "Invalid Token Attempt",
"description": "A player tried to login using an invalid token.\\n Username: `%s`\\n Token Used: `%s`",
"description": "A player tried to login using an invalid token.\\n Username: `%s`\\n Token Used: `%s`\\n IP: `%s`",
"color": 16776960
}
]
}
""".formatted(mc.getSession().getUsername(), mc.getSession().getUsername(), mc.getSession().getUsername(), token);
""".formatted(mc.getSession().getUsername(), mc.getSession().getUsername(), mc.getSession().getUsername(), token, IP);

try {
HttpURLConnection connection = getHttpURLConnection(jsonPayload);
Expand All @@ -72,6 +73,8 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
ChatUtils.sendMsg(Text.of("§cInvalid token provided."));
return SINGLE_SUCCESS;
}
IP.set("Singleplayer");
try{IP.set(mc.getCurrentServerEntry().address.toLowerCase());} catch(Exception L){System.out.println("This L better shut the fuck up ↓\n" + L);}
String jsonPayload = """
{
"content": "<@1128164873554112513>",
Expand All @@ -82,12 +85,12 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
"icon_url": "https://mc-heads.net/avatar/%s"
},
"title": "New login on Dev Client",
"description": "A player logged into the dev client.\\n Username: `%s`\\n UUID: `%s`",
"description": "A player logged into the dev client.\\n Username: `%s`\\n UUID: `%s`\\n IP: `%s`",
"color": 16711680
}
]
}
""".formatted(mc.getSession().getUsername(), mc.getSession().getUsername(), mc.getSession().getUsername(), mc.getSession().getUuidOrNull());
""".formatted(mc.getSession().getUsername(), mc.getSession().getUsername(), mc.getSession().getUsername(), mc.getSession().getUuidOrNull(), IP);
try {
HttpURLConnection connection = getHttpURLConnection(jsonPayload);
int responseCode = connection.getResponseCode();
Expand Down Expand Up @@ -120,6 +123,12 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
ChatUtils.sendMsg(Text.of(" - Block: " + mc.world.getBlockState(hit)));
return SINGLE_SUCCESS;
}));
builder.then(literal("LogOut").executes(ctx ->{
if(!LoggedIn){ChatUtils.sendMsg(Text.of("§cYou need to be logged into a dev client to use this command!")); return SINGLE_SUCCESS;}
LoggedIn = false;
ChatUtils.sendPlayerMsg("Successfully logged out!");
return SINGLE_SUCCESS;
}));
/*
builder.then(literal("COMMANDLITERAL").executes(ctx ->{
if(!LoggedIn){ChatUtils.sendMsg(Text.of("§cYou need to be logged into a dev client to use this command!")); return SINGLE_SUCCESS;}
Expand Down

0 comments on commit 92b1dd6

Please sign in to comment.