net.minecraft.client.multiplayer.ServerData Java Examples

The following examples show how to use net.minecraft.client.multiplayer.ServerData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SlimeChunksModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void receivePacket(EventReceivePacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (event.getPacket() instanceof SPacketChunkData) {
            final SPacketChunkData packet = (SPacketChunkData) event.getPacket();
            final SlimeChunk chunk = new SlimeChunk(packet.getChunkX() * 16, packet.getChunkZ() * 16);

            final ServerData serverData = Minecraft.getMinecraft().getCurrentServerData();
            if (serverData != null) {
                final WorldManager.WorldData worldData = Seppuku.INSTANCE.getWorldManager().find(serverData.serverIP);
                if (worldData != null) {
                    if (!this.slimeChunkList.contains(chunk) && this.isSlimeChunk(worldData.getSeed(), packet.getChunkX(), packet.getChunkZ())) {
                        this.slimeChunkList.add(chunk);
                    }
                }
            }
        }
    }
}
 
Example #2
Source File: MixinGuiConnecting.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());

    this.drawDefaultBackground();

    RenderUtils.drawLoadingCircle(scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 70);

    String ip = "Unknown";

    final ServerData serverData = mc.getCurrentServerData();
    if(serverData != null)
        ip = serverData.serverIP;

    Fonts.font40.drawCenteredString("Connecting to", scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 110, 0xFFFFFF, true);
    Fonts.font35.drawCenteredString(ip, scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 120, 0x5281FB, true);

    super.drawScreen(mouseX, mouseY, partialTicks);
}
 
Example #3
Source File: WindowCheckVanish.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void run() {
    //YouAlwaysWinClickGui.log("[PacketQueryCV] Updating");
    ServerData serverData = Wrapper.INSTANCE.mc().func_147104_D();
    if (serverData == null) {
        lastCvResult = -2;
        cvThreadStarted.set(false);
        return;
    }
    ServerAddress address = ServerAddress.func_78860_a(serverData.serverIP);
    try {
        ServerListPing17 pinger = new ServerListPing17();
        //pinger.setAddress(new InetSocketAddress("n5.streamcraft.net", 25666));
        pinger.setAddress(new InetSocketAddress(address.getIP(), address.getPort()));
        StatusResponse response = pinger.fetchData();
        lastCvResult = response.getPlayers().getOnline();
        //YouAlwaysWinClickGui.log("[PacketQueryCV] Updated");
    } catch (Exception e) {
        lastCvResult = -1;
        //YouAlwaysWinClickGui.log("[PacketQueryCV] Error on updating: " + e.getMessage());
    }
    cvThreadStarted.set(false);
}
 
Example #4
Source File: MixinGuiConnecting.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());

    this.drawDefaultBackground();

    RenderUtils.drawLoadingCircle(scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 70);

    String ip = "Unknown";

    final ServerData serverData = mc.getCurrentServerData();
    if(serverData != null)
        ip = serverData.serverIP;

    Fonts.font40.drawCenteredString("Connecting to", scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 110, 0xFFFFFF, true);
    Fonts.font35.drawCenteredString(ip, scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 120, 0x5281FB, true);

    super.drawScreen(mouseX, mouseY, partialTicks);
}
 
Example #5
Source File: InstantMessage.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onPacketIn(PacketEvent.Incoming.Pre event) {
  if (event.getPacket() instanceof SPacketLoginSuccess) {
    
    if (MC.currentScreen instanceof GuiConnecting) {
      
      ServerData serverData = MC.getCurrentServerData();
      String serverName = serverData != null ? serverData.serverName : "Unknown";
      String serverIP = serverData != null ? serverData.serverIP : "";
      
      GuiConnecting_networkManager.get(MC.currentScreen)
          .sendPacket(
              new CPacketChatMessage(
                  message
                      .get()
                      .replace("{SRVNAME}", serverName)
                      .replace("{IP}", serverIP)
                      .replace("{NAME}", MC.getSession().getUsername())));
    } else {
      getLog().warn("Did not send message as current screen is not GuiConnecting");
    }
  }
}
 
Example #6
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void loadServerList(List<ServerData> servers, Minecraft mc) {
    try {
        servers.clear();
        NBTTagCompound nbttagcompound = CompressedStreamTools
            .read(new File(mc.mcDataDir, "servers.dat"));

        if (nbttagcompound == null) return;

        NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10);

        int bound = nbttaglist.tagCount();
        for (int i = 0; i < bound; i++) {
            ServerData serverDataFromNBTCompound = ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i));
            servers.add(serverDataFromNBTCompound);
        }
    } catch (Exception exception) {
        Hyperium.LOGGER.error("Failed to load server list", exception);
    }
}
 
Example #7
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void saveServerList(List<ServerData> servers, Minecraft mc) {
    try {
        NBTTagList nbttaglist = new NBTTagList();

        for (ServerData server : servers) {
            NBTTagCompound nbtCompound = server.getNBTCompound();
            nbttaglist.appendTag(nbtCompound);
        }

        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setTag("servers", nbttaglist);
        CompressedStreamTools.safeWrite(nbttagcompound, new File(mc.mcDataDir, "servers.dat"));
    } catch (Exception exception) {
        Hyperium.LOGGER.error("Save server list error", exception);
    }
}
 
Example #8
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ServerData getServerData(List<ServerData> servers, int index) {
    try {
        return servers.get(index);
    } catch (Exception e) {
        Hyperium.LOGGER.error("Failed to get server data", e);
    }

    return null;
}
 
Example #9
Source File: WindowCheckVanish.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void draw(int x, int y) {
    super.draw(x, y);
    if (cvLastUpdate > 160) {
        cvLastUpdate = 0;
        if (!cvThreadStarted.get()) {
            cvThreadStarted.set(true);
            cvRequester = new CVServerRequester();
            cvRequester.start();
        }
    }
    if (lpLastUpdate > 160) {
        lpLastUpdate = 0;
        if (!lpThreadStarted.get()) {
            lpThreadStarted.set(true);
            lpRequester = new LPServerRequester();
            lpRequester.start();
        }
    }
    if (this.isOpen()) {
        tabList = Wrapper.INSTANCE.player().sendQueue.playerInfoList.size();
        ServerData serverData = Wrapper.INSTANCE.mc().func_147104_D();
        if (serverData == null) {
            Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("You are in singleplayer", this.getClientX() + 1, this.getClientY() + 1, GLUtils.getColor(255, 255, 255));
            return;
        }
        if (tabList < lastCvResult || tabList < lastLpResult) {
            super.setColor(255,0,0);
        } else {
            super.setColor(96,96,96);
        }
        Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("Server IP: " + serverData.serverIP, this.getClientX() + 1, this.getClientY() + 1, GLUtils.getColor(255, 255, 255));
        Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("TAB-List: " + String.valueOf(tabList), this.getClientX() + 1, this.getClientY() + 13, GLUtils.getColor(255, 255, 255));
        Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("PacketQuery: " + (lastCvResult < 0 ? (lastCvResult == -1 ? "Error" : "Not working") : String.valueOf(lastCvResult)) + (cvThreadStarted.get() ? " [U]" : ""), this.getClientX() + 1, this.getClientY() + 25, GLUtils.getColor(255, 255, 255));
        Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("Legacy: " + (lastLpResult < 0 ? (lastLpResult == -1 ? "Error" : "Not working") : String.valueOf(lastLpResult)) + (lpThreadStarted.get() ? " [U]" : ""), this.getClientX() + 1, this.getClientY() + 37, GLUtils.getColor(255, 255, 255));
    }
}
 
Example #10
Source File: WindowCheckVanish.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
    //YouAlwaysWinClickGui.log("[LegacyPingCV] Updating");
    ServerData serverData = Wrapper.INSTANCE.mc().func_147104_D();
    if (serverData == null) {
        lastLpResult = -2;
        lpThreadStarted.set(false);
        return;
    }
    ServerAddress address = ServerAddress.func_78860_a(serverData.serverIP);
    try {
        String[] data;
        //clientSocket.connect(new InetSocketAddress("n5.streamcraft.net", 25666), 7000);
        try (Socket clientSocket = new Socket()) {
            //clientSocket.connect(new InetSocketAddress("n5.streamcraft.net", 25666), 7000);
            clientSocket.connect(new InetSocketAddress(address.getIP(), address.getPort()), 7000);
            clientSocket.setSoTimeout(7000);
            DataOutputStream dos = new DataOutputStream(clientSocket.getOutputStream());
            BufferedReader br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            dos.write(payload, 0, payload.length);
            data = br.readLine().split("\u0000\u0000\u0000");
        }
        if (data.length < 2) {
            lastLpResult = -2;
            lpThreadStarted.set(false);
            return;
        }
        lastLpResult = Integer.valueOf(data[data.length - 2].replace("\u0000", ""));
        //YouAlwaysWinClickGui.log("[LegacyPingCV] Updated");
    } catch (Exception e) {
        lastLpResult = -1;
        //YouAlwaysWinClickGui.log("[LegacyPingCV] Error on updating: " + e.getMessage());
    }
    lpThreadStarted.set(false);
}
 
Example #11
Source File: HypixelDetector.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@InvokeEvent
public void serverJoinEvent(ServerJoinEvent event) {
    hypixel = HYPIXEL_PATTERN.matcher(event.getServer()).find();

    Multithreading.runAsync(() -> {
        // Wait a while until the player isn't null, signifying the joining process is complete
        int tries = 0;
        while (Minecraft.getMinecraft().thePlayer == null) {
            tries++;
            if (tries > 20 * 10) {
                return;
            }
            try {
                Thread.sleep(50L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        if (hypixel) { // If player is online recognized Hypixel IP
            EventBus.INSTANCE.post(new JoinHypixelEvent(ServerVerificationMethod.IP));
        } else { // Double check the player isn't online Hypixel
            if (Minecraft.getMinecraft().getCurrentServerData() != null) {
                ServerData serverData = Minecraft.getMinecraft().getCurrentServerData();

                if (serverData != null && serverData.serverMOTD != null && serverData.serverMOTD.toLowerCase().contains("hypixel network")) { // Check MOTD for Hypixel
                    hypixel = true;
                    EventBus.INSTANCE.post(new JoinHypixelEvent(ServerVerificationMethod.MOTD));
                }
            }
        }
    });
}
 
Example #12
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void set(List<ServerData> servers, int index, ServerData server) {
    try {
        servers.set(index, server);
    } catch (Exception e) {
        Hyperium.LOGGER.error("Failed to set server data", e);
    }
}
 
Example #13
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void swapServers(List<ServerData> servers, Minecraft mc, int pos1, int pos2) {
    try {
        ServerData serverdata = getServerData(servers, pos1);
        servers.set(pos1, getServerData(servers, pos2));
        servers.set(pos2, serverdata);
        saveServerList(servers, mc);
    } catch (Exception e) {
        Hyperium.LOGGER.error("Failed to swap servers", e);
    }
}
 
Example #14
Source File: GuiTravelStandby.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@Override
public void updateScreen()
{
    super.updateScreen();

    m_ticks++;
    if( m_ticks == 30 )
    {
        ServerData serverData = new ServerData( "qCraft Transfer", m_destination.getAddress() );
        FMLClientHandler.instance().setupServerList();
        FMLClientHandler.instance().connectToServer( new GuiMainMenu(), serverData );
    }
}
 
Example #15
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void addServerData(List<ServerData> servers, ServerData index) {
    try {
        servers.add(index);
    } catch (Exception e) {
        Hyperium.LOGGER.error("Failed to add server data", e);
    }
}
 
Example #16
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void removeServerData(List<ServerData> servers, int index) {
    try {
        servers.remove(index);
    } catch (Exception e) {
        Hyperium.LOGGER.error("Failed to remove server data", e);
    }
}
 
Example #17
Source File: HyperiumServerList.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void saveSingleServer(ServerData serverData) {
    ServerList serverlist = new ServerList(Minecraft.getMinecraft());
    serverlist.loadServerList();

    for (int i = 0; i < serverlist.countServers(); ++i) {
        ServerData serverdata = serverlist.getServerData(i);

        if (serverdata.serverName.equals(serverData.serverName) && serverdata.serverIP.equals(serverData.serverIP)) {
            serverlist.func_147413_a(i, serverData);
            break;
        }
    }

    serverlist.saveServerList();
}
 
Example #18
Source File: LoginReplyHandler.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handle(LoginReplyPacket loginReplyPacket) {
    ServerData currentServerData = Minecraft.getMinecraft().getCurrentServerData();
    if (currentServerData != null) {
        NettyClient client = NettyClient.getClient();
        if (client != null) {
            client.write(UpdateLocationPacket.build("Other"));
        }
    }

    if (loginReplyPacket.isAdmin()) {
        Hyperium.INSTANCE.getHandlers().getHyperiumCommandHandler().registerCommand(new BaseCommand() {
            @Override
            public String getName() {
                return "hyperiumadmin";
            }

            @Override
            public String getUsage() {
                return "/hyperiumadmin";
            }

            @Override
            public void onExecute(String[] args) {
                if (args.length == 1 && args[0].equalsIgnoreCase("show_messages")) SHOW_MESSAGES = !SHOW_MESSAGES;
                StringBuilder builder = new StringBuilder();
                Iterator<String> iterator = Arrays.stream(args).iterator();
                while (iterator.hasNext()) {
                    builder.append(iterator.next());
                    if (iterator.hasNext()) builder.append(" ");
                }

                NettyClient.getClient().dispatchCommand(builder.toString());

            }
        });

    }

}
 
Example #19
Source File: ConnectCommand.java    From ClientBase with MIT License 5 votes vote down vote up
@Override
public void run(String alias, @NotNull String[] args) {
    if (args.length != 1) {
        throw new CommandException("Usage: ." + alias + " <server-address>");
    }

    // See https://github.com/Wurst-Imperium/Wurst-MC-1.12/blob/master/shared-src/net/wurstclient/bot/commands/JoinCmd.java
    Minecraft.getMinecraft().addScheduledTask(() -> Minecraft.getMinecraft().displayGuiScreen(new GuiConnecting(new GuiMainMenu(), Minecraft.getMinecraft(),
            new ServerData("", args[0], false))));
}
 
Example #20
Source File: ActionConnectToServer.java    From Custom-Main-Menu with MIT License 5 votes vote down vote up
@Override
public void perform(Object source, GuiCustom menu)
{
	ServerData serverData = new ServerData(this.serverName, this.ip, false);
	FMLClientHandler.instance().setupServerList();
	FMLClientHandler.instance().connectToServer(menu, serverData);
}
 
Example #21
Source File: ServerUtils.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public static String getRemoteIp() {
    String serverIp = "Singleplayer";

    if (mc.theWorld.isRemote) {
        final ServerData serverData = mc.getCurrentServerData();
        if(serverData != null)
            serverIp = serverData.serverIP;
    }

    return serverIp;
}
 
Example #22
Source File: ServerScraperScreen.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void ping(String ip, int port) {
	server = new ServerData(ip, ip + ":" + port, false);
	System.out.println("Starting Ping " + ip + ":" + port);
	new Thread(() -> {
		ServerPinger pinger = new ServerPinger();
		try {
			pinger.ping(server);
		} catch (Exception e) {
			failed = true;
		}
		pinger.clearPendingNetworks();
		done = true;
		System.out.println("Finished Ping " + ip + ":" + port + " > " + failed);
	}).start();
}
 
Example #23
Source File: MessageSyncPlantJson.java    From AgriCraft with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public final String getServerId() {
    final ServerData data = Minecraft.getMinecraft().getCurrentServerData();
    return "server_" + data.serverIP.replaceAll("\\.", "-").replaceAll(":", "_");
}
 
Example #24
Source File: MessageSyncSoilJson.java    From AgriCraft with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public final String getServerId() {
    final ServerData data = Minecraft.getMinecraft().getCurrentServerData();
    return "server_" + data.serverIP.replaceAll("\\.", "-").replaceAll(":", "_");
}
 
Example #25
Source File: AutoReconnectMod.java    From ForgeHax with MIT License 4 votes vote down vote up
private void reconnect() {
  ServerData data = getLastConnectedServerData();
  if (data != null) {
    FMLClientHandler.instance().showGuiScreen(new GuiConnecting(parent, MC, data));
  }
}
 
Example #26
Source File: AutoReconnectMod.java    From ForgeHax with MIT License 4 votes vote down vote up
public ServerData getLastConnectedServerData() {
  return lastConnectedServer != null ? lastConnectedServer : MC.getCurrentServerData();
}
 
Example #27
Source File: AutoReconnectMod.java    From ForgeHax with MIT License 4 votes vote down vote up
public void updateLastConnectedServer() {
  ServerData data = MC.getCurrentServerData();
  if (data != null) {
    lastConnectedServer = data;
  }
}
 
Example #28
Source File: MessageSyncMutationJson.java    From AgriCraft with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public final String getServerId() {
    final ServerData data = Minecraft.getMinecraft().getCurrentServerData();
    return "server_" + data.serverIP.replaceAll("\\.", "-").replaceAll(":", "_");
}
 
Example #29
Source File: GuiHyperiumScreenMainMenu.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void actionPerformed(GuiButton button) {
    switch (button.id) {
        case 0:
            Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new GuiSelectWorld(this));
            break;

        case 1:
            Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new GuiMultiplayer(this));
            break;

        case 2:
            if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) {
                GuiMultiplayer guiMultiplayer = new GuiMultiplayer(new GuiMainMenu());
                guiMultiplayer.setWorldAndResolution(Minecraft.getMinecraft(), width, height);
                ((IMixinGuiMultiplayer) guiMultiplayer).makeDirectConnect();
                ServerData data = new ServerData("customServer", Settings.SERVER_IP, false);
                ((IMixinGuiMultiplayer) guiMultiplayer).setIp(data);
                guiMultiplayer.confirmClicked(true, 0);
            } else {
                Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new CreateServerButton(this));
            }
            break;


        case 3:
            HyperiumMainGui.INSTANCE.show();
            break;

        case 4:
            Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new GuiOptions(this, mc.gameSettings));
            break;

        case 5:
            if (Settings.CONFIRM_QUIT) {
                Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new GuiConfirmQuit());
            } else {
                mc.shutdown();
            }
            break;

        case 6:
            HyperiumMainGui.INSTANCE.setTab(1);
            Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(HyperiumMainGui.INSTANCE);
            break;

        case 7:
            mc.displayGuiScreen(new ChangeBackgroundGui(this));
            break;
    }
}
 
Example #30
Source File: MixinGuiMultiplayer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void setIp(ServerData ip) {
    selectedServer = ip;
}