Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add server_info command #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/de/damcraft/serverseeker/ServerSeeker.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.Gson;
import com.mojang.logging.LogUtils;
import de.damcraft.serverseeker.commands.ServerInfoCommand;
import de.damcraft.serverseeker.country.Countries;
import de.damcraft.serverseeker.country.Country;
import de.damcraft.serverseeker.country.CountrySetting;
Expand All @@ -12,6 +13,7 @@
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.addons.GithubRepo;
import meteordevelopment.meteorclient.addons.MeteorAddon;
import meteordevelopment.meteorclient.commands.Commands;
import meteordevelopment.meteorclient.gui.utils.SettingsWidgetFactory;
import meteordevelopment.meteorclient.systems.hud.Hud;
import meteordevelopment.meteorclient.systems.modules.Category;
Expand Down Expand Up @@ -47,6 +49,7 @@ public void onInitialize() {

Modules.get().add( new BungeeSpoofModule() );
Hud.get().register(HistoricPlayersHud.INFO);
Commands.add( new ServerInfoCommand() );

SettingsWidgetFactory.registerCustomFactory(CountrySetting.class, (theme) -> (table, setting) -> {
CountrySetting.countrySettingW(table, (CountrySetting) setting, theme);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.damcraft.serverseeker.commands;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import de.damcraft.serverseeker.gui.ServerInfoScreen;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.command.CommandSource;

import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import static meteordevelopment.meteorclient.MeteorClient.mc;

public class ServerInfoCommand extends Command {
public ServerInfoCommand() {
super("server_info", "Get Info about a server", "si");
}

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(ctx -> {
if (mc.getCurrentServerEntry() == null) {
error("Failed to get current server entry. Are you playing on a singleplayer world?");
return SINGLE_SUCCESS;
}
String addr = mc.getCurrentServerEntry().address;
Utils.screenToOpen = new ServerInfoScreen(addr);
return SINGLE_SUCCESS;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.List;

import static de.damcraft.serverseeker.ServerSeeker.gson;
import static meteordevelopment.meteorclient.MeteorClient.mc;

public class ServerInfoScreen extends WindowScreen {
private final String serverIp;

Expand Down Expand Up @@ -108,6 +110,7 @@ public void initWidgets() {
playersTable.add(theme.label(lastSeenFormatted + " ")).expandX();
playersTable.row();
}
if (mc.player != null) return;
WButton joinServerButton = add(theme.button("Join this Server")).expandX().widget();
joinServerButton.action = ()
-> ConnectScreen.connect(new TitleScreen(), MinecraftClient.getInstance(), new ServerAddress(hap.getHost(), hap.getPort()), new ServerInfo("a", hap.toString(), ServerInfo.ServerType.OTHER), false);
Expand Down