From 898cb60072b1e3fb4a161b021108873413355f6c Mon Sep 17 00:00:00 2001 From: Kamesuta Date: Sun, 28 Jan 2018 06:06:08 +0900 Subject: [PATCH] start and login --- .../net/teamfruit/serverobserver/Compat.java | 25 ++-- .../resources/META-INF/serverobserver_at.cfg | 3 +- .../net/teamfruit/serverobserver/Compat.java | 25 ++-- .../resources/META-INF/serverobserver_at.cfg | 3 +- .../net/teamfruit/serverobserver/Compat.java | 25 ++-- .../resources/META-INF/serverobserver_at.cfg | 3 +- .../net/teamfruit/serverobserver/Compat.java | 21 +-- .../resources/META-INF/serverobserver_at.cfg | 3 +- .../net/teamfruit/serverobserver/Compat.java | 25 ++-- .../resources/META-INF/serverobserver_at.cfg | 3 +- .../net/teamfruit/serverobserver/Compat.java | 25 ++-- .../resources/META-INF/serverobserver_at.cfg | 3 +- .../resources/META-INF/serverobserver_at.cfg | 3 +- .../net/teamfruit/serverobserver/Config.java | 2 + .../serverobserver/DefaultServerList.java | 1 - .../teamfruit/serverobserver/GuiHandler.java | 122 ++++++++++++------ .../net/teamfruit/serverobserver/ICompat.java | 23 ++-- .../assets/serverobserver/lang/en_US.lang | 2 + .../assets/serverobserver/lang/ja_JP.lang | 2 + 19 files changed, 194 insertions(+), 125 deletions(-) diff --git a/1.10.2/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.10.2/src/main/java/net/teamfruit/serverobserver/Compat.java index a74bd02..a7e9580 100644 --- a/1.10.2/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.10.2/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,6 +1,7 @@ package net.teamfruit.serverobserver; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; import javax.annotation.Nonnull; @@ -12,11 +13,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; @@ -77,6 +78,11 @@ public void setPinged(final ServerData serverData, final boolean pinged) { serverData.pinged = pinged; } + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + @Override public String getDefaultSound() { return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); @@ -92,29 +98,24 @@ public void selectServer(final GuiMultiplayer mpgui, final int index) { mpgui.selectServer(index); } - @Override - public int countServers(final GuiMultiplayer mpgui) { - return mpgui.getServerList().countServers(); - } - @Override public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { return mpgui.getServerList().getServerData(index); } @Override - public IGuiListEntry getListEntry(final GuiMultiplayer mpgui, final int index) { - return mpgui.serverListSelector.getListEntry(index); + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); } @Override - public ServerData getServerData(final ServerListEntryNormal entry) { - return entry.getServerData(); + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); } @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; } public static class SkeletonButton extends GuiButton { diff --git a/1.10.2/src/main/resources/META-INF/serverobserver_at.cfg b/1.10.2/src/main/resources/META-INF/serverobserver_at.cfg index ce2687a..1e5ce1e 100644 --- a/1.10.2/src/main/resources/META-INF/serverobserver_at.cfg +++ b/1.10.2/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,4 +1,5 @@ public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer \ No newline at end of file +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.11.2/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.11.2/src/main/java/net/teamfruit/serverobserver/Compat.java index a74bd02..a7e9580 100644 --- a/1.11.2/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.11.2/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,6 +1,7 @@ package net.teamfruit.serverobserver; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; import javax.annotation.Nonnull; @@ -12,11 +13,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; @@ -77,6 +78,11 @@ public void setPinged(final ServerData serverData, final boolean pinged) { serverData.pinged = pinged; } + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + @Override public String getDefaultSound() { return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); @@ -92,29 +98,24 @@ public void selectServer(final GuiMultiplayer mpgui, final int index) { mpgui.selectServer(index); } - @Override - public int countServers(final GuiMultiplayer mpgui) { - return mpgui.getServerList().countServers(); - } - @Override public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { return mpgui.getServerList().getServerData(index); } @Override - public IGuiListEntry getListEntry(final GuiMultiplayer mpgui, final int index) { - return mpgui.serverListSelector.getListEntry(index); + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); } @Override - public ServerData getServerData(final ServerListEntryNormal entry) { - return entry.getServerData(); + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); } @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; } public static class SkeletonButton extends GuiButton { diff --git a/1.11.2/src/main/resources/META-INF/serverobserver_at.cfg b/1.11.2/src/main/resources/META-INF/serverobserver_at.cfg index ce2687a..1e5ce1e 100644 --- a/1.11.2/src/main/resources/META-INF/serverobserver_at.cfg +++ b/1.11.2/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,4 +1,5 @@ public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer \ No newline at end of file +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.12.2/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.12.2/src/main/java/net/teamfruit/serverobserver/Compat.java index a0fdca2..296f2af 100644 --- a/1.12.2/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.12.2/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,6 +1,7 @@ package net.teamfruit.serverobserver; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; import javax.annotation.Nonnull; @@ -12,11 +13,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; @@ -77,6 +78,11 @@ public void setPinged(final ServerData serverData, final boolean pinged) { serverData.pinged = pinged; } + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + @Override public String getDefaultSound() { return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); @@ -92,29 +98,24 @@ public void selectServer(final GuiMultiplayer mpgui, final int index) { mpgui.selectServer(index); } - @Override - public int countServers(final GuiMultiplayer mpgui) { - return mpgui.getServerList().countServers(); - } - @Override public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { return mpgui.getServerList().getServerData(index); } @Override - public IGuiListEntry getListEntry(final GuiMultiplayer mpgui, final int index) { - return mpgui.serverListSelector.getListEntry(index); + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); } @Override - public ServerData getServerData(final ServerListEntryNormal entry) { - return entry.getServerData(); + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); } @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; } public static class SkeletonButton extends GuiButton { diff --git a/1.12.2/src/main/resources/META-INF/serverobserver_at.cfg b/1.12.2/src/main/resources/META-INF/serverobserver_at.cfg index ce2687a..1e5ce1e 100644 --- a/1.12.2/src/main/resources/META-INF/serverobserver_at.cfg +++ b/1.12.2/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,4 +1,5 @@ public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer \ No newline at end of file +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.7.10/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.7.10/src/main/java/net/teamfruit/serverobserver/Compat.java index dbe5cac..759dbb4 100644 --- a/1.7.10/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.7.10/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,6 +1,7 @@ package net.teamfruit.serverobserver; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; import javax.annotation.Nonnull; @@ -11,11 +12,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; @@ -75,6 +76,11 @@ public void setPinged(final ServerData serverData, final boolean pinged) { serverData.field_78841_f = pinged; } + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.func_146789_i().func_147224_a(serverData); + } + private final String defaultSound = "minecraft:random.orb"; @Override @@ -93,8 +99,8 @@ public void selectServer(final GuiMultiplayer mpgui, final int index) { } @Override - public int countServers(final GuiMultiplayer mpgui) { - return mpgui.func_146795_p().countServers(); + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.func_146795_p(); } @Override @@ -103,13 +109,8 @@ public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { } @Override - public IGuiListEntry getListEntry(final GuiMultiplayer mpgui, final int index) { - return mpgui.field_146803_h.getListEntry(index); - } - - @Override - public ServerData getServerData(final ServerListEntryNormal entry) { - return entry.func_148296_a(); + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.field_148302_b; } @Override diff --git a/1.7.10/src/main/resources/META-INF/serverobserver_at.cfg b/1.7.10/src/main/resources/META-INF/serverobserver_at.cfg index ce2687a..1e5ce1e 100644 --- a/1.7.10/src/main/resources/META-INF/serverobserver_at.cfg +++ b/1.7.10/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,4 +1,5 @@ public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer \ No newline at end of file +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.8.9/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.8.9/src/main/java/net/teamfruit/serverobserver/Compat.java index 6ba96f3..1449308 100644 --- a/1.8.9/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.8.9/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,6 +1,7 @@ package net.teamfruit.serverobserver; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; import javax.annotation.Nonnull; @@ -11,11 +12,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; @@ -74,6 +75,11 @@ public void setPinged(final ServerData serverData, final boolean pinged) { serverData.field_78841_f = pinged; } + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + private final String defaultSound = "minecraft:random.orb"; @Override @@ -91,29 +97,24 @@ public void selectServer(final GuiMultiplayer mpgui, final int index) { mpgui.selectServer(index); } - @Override - public int countServers(final GuiMultiplayer mpgui) { - return mpgui.getServerList().countServers(); - } - @Override public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { return mpgui.getServerList().getServerData(index); } @Override - public IGuiListEntry getListEntry(final GuiMultiplayer mpgui, final int index) { - return mpgui.serverListSelector.getListEntry(index); + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); } @Override - public ServerData getServerData(final ServerListEntryNormal entry) { - return entry.getServerData(); + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); } @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.field_148302_b; } public static class SkeletonButton extends GuiButton { diff --git a/1.8.9/src/main/resources/META-INF/serverobserver_at.cfg b/1.8.9/src/main/resources/META-INF/serverobserver_at.cfg index ce2687a..1e5ce1e 100644 --- a/1.8.9/src/main/resources/META-INF/serverobserver_at.cfg +++ b/1.8.9/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,4 +1,5 @@ public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer \ No newline at end of file +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.9.4/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.9.4/src/main/java/net/teamfruit/serverobserver/Compat.java index a74bd02..a7e9580 100644 --- a/1.9.4/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.9.4/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,6 +1,7 @@ package net.teamfruit.serverobserver; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; import javax.annotation.Nonnull; @@ -12,11 +13,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; @@ -77,6 +78,11 @@ public void setPinged(final ServerData serverData, final boolean pinged) { serverData.pinged = pinged; } + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + @Override public String getDefaultSound() { return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); @@ -92,29 +98,24 @@ public void selectServer(final GuiMultiplayer mpgui, final int index) { mpgui.selectServer(index); } - @Override - public int countServers(final GuiMultiplayer mpgui) { - return mpgui.getServerList().countServers(); - } - @Override public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { return mpgui.getServerList().getServerData(index); } @Override - public IGuiListEntry getListEntry(final GuiMultiplayer mpgui, final int index) { - return mpgui.serverListSelector.getListEntry(index); + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); } @Override - public ServerData getServerData(final ServerListEntryNormal entry) { - return entry.getServerData(); + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); } @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; } public static class SkeletonButton extends GuiButton { diff --git a/1.9.4/src/main/resources/META-INF/serverobserver_at.cfg b/1.9.4/src/main/resources/META-INF/serverobserver_at.cfg index ce2687a..1e5ce1e 100644 --- a/1.9.4/src/main/resources/META-INF/serverobserver_at.cfg +++ b/1.9.4/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,4 +1,5 @@ public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer \ No newline at end of file +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/common/src/main/resources/META-INF/serverobserver_at.cfg b/common/src/main/resources/META-INF/serverobserver_at.cfg index ce2687a..1e5ce1e 100644 --- a/common/src/main/resources/META-INF/serverobserver_at.cfg +++ b/common/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,4 +1,5 @@ public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer \ No newline at end of file +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/src/main/java/net/teamfruit/serverobserver/Config.java b/src/main/java/net/teamfruit/serverobserver/Config.java index 6d95cb1..ab805ce 100644 --- a/src/main/java/net/teamfruit/serverobserver/Config.java +++ b/src/main/java/net/teamfruit/serverobserver/Config.java @@ -23,6 +23,7 @@ public class Config { public final ConfigProperty notificationSound; public final ConfigProperty notificationPitch; public final ConfigProperty startWithMultiplayerMenu; + public final ConfigProperty startAndConnect; public final ConfigProperty targetServerName; public final ConfigProperty targetServerIP; @@ -50,6 +51,7 @@ private Config(final @Nonnull File staticFile, final @Nonnull File dynamicFile, this.config.getCategory("Miscellaneous").setLanguageKey("serverobserver.config.miscellaneous").setComment("Miscellaneous"); this.startWithMultiplayerMenu = this.config.propertyBoolean(this.config.get("Miscellaneous", "StartWithMultiplayerMenu", false, "After game initialized, show multiplayer menu").setLanguageKey("serverobserver.config.miscellaneous.startwithmultiplayermenu").setRequiresMcRestart(true)); + this.startAndConnect = this.config.propertyBoolean(this.config.get("Miscellaneous", "StartAndConnect", false, "After game initialized, connect to the server").setLanguageKey("serverobserver.config.miscellaneous.startandconnect").setRequiresMcRestart(true)); // init dynamic config this.dynamicconfig = new ConfigBase(dynamicFile, version); diff --git a/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java b/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java index e42f6db..b6a0773 100644 --- a/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java +++ b/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java @@ -22,7 +22,6 @@ public ServerListModel loadModel(final File file) { } public static class ServerListModel { - public ServerModel autologin; public List servers; } diff --git a/src/main/java/net/teamfruit/serverobserver/GuiHandler.java b/src/main/java/net/teamfruit/serverobserver/GuiHandler.java index 32f46a2..1e070a7 100644 --- a/src/main/java/net/teamfruit/serverobserver/GuiHandler.java +++ b/src/main/java/net/teamfruit/serverobserver/GuiHandler.java @@ -2,6 +2,7 @@ import java.awt.Color; import java.io.File; +import java.net.UnknownHostException; import java.util.List; import java.util.Set; @@ -9,6 +10,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.math.NumberUtils; import org.lwjgl.util.Timer; @@ -18,11 +20,9 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.ServerList; import net.minecraft.client.resources.I18n; @@ -51,6 +51,8 @@ public interface SkeletonButtonDrawInside { void drawInside(GuiButton button, final Minecraft mc, final int mouseX, final int mouseY, final int x, final int y); } + private boolean isFirstOpen = true; + @CoreEvent public void open(final InitGuiEvent.Post e) { this.manualOpen = this.manual; @@ -76,17 +78,24 @@ public void open(final InitGuiEvent.Post e) { mpgui.drawString(font, "...", x+4+font.getStringWidth(text), y+12, Color.GRAY.getRGB()); } })); - selectTarget(mpgui, this.target.getIP()); + selectTarget(mpgui, this.target.getServerIP()); reset(Config.getConfig().durationPing); } else if (screen instanceof GuiDisconnected) { final GuiDisconnected dcgui = (GuiDisconnected) screen; - if (this.target.getIP()!=null) + if (this.target.getServerIP()!=null) buttons.add( this.disableBackButton = new GuiButton(DISABLE_BACK_BUTTON_ID, dcgui.width/2-100, this.compat.getHeight(dcgui), I18n.format("serverobserver.gui.backandstop", 0f))); reset(Config.getConfig().durationDisconnected); } else if (screen instanceof GuiMainMenu) { + if (this.isFirstOpen) + if (Config.getConfig().startAndConnect.get()) { + final ServerData server = this.target.get(null); + if (server!=null) + this.compat.connectToServer(new GuiMultiplayer(screen), server); + } else if (Config.getConfig().startWithMultiplayerMenu.get()) + this.mc.displayGuiScreen(new GuiMultiplayer(screen)); for (final GuiButton button : buttons) if (button.id==2) this.mainMenuButtonMulti = button; @@ -94,6 +103,7 @@ public void open(final InitGuiEvent.Post e) { reset(Config.getConfig().durationMainMenu); } this.manual = false; + this.isFirstOpen = false; } @CoreEvent @@ -105,7 +115,7 @@ public void draw(final DrawScreenEvent.Post e) { this.disableBackButton.displayString = I18n.format("serverobserver.gui.backandstop.time", I18n.format("serverobserver.gui.backandstop"), timeremain()); } else if (gui instanceof GuiMainMenu) { final GuiButton button = this.mainMenuButtonMulti; - if (button!=null&&this.target.getIP()!=null&&!this.manualOpen) + if (button!=null&&this.target.getServerIP()!=null&&!this.manualOpen) button.displayString = I18n.format("serverobserver.gui.maintomulti.time", I18n.format("menu.multiplayer"), timeremain()); } } @@ -147,12 +157,6 @@ public void init(final File root) { if (dirty) list.saveServerList(); } - final ServerModel server = model.autologin; - if (server!=null) { - this.targetServerStatus = null; - this.autologin.set(true); - this.target.set(new ServerData(server.serverName, server.serverIP, false)); - } } } } @@ -169,9 +173,13 @@ public void action(final ActionPerformedEvent.Post e) { final int id = this.compat.getButton(e).id; if (screen instanceof GuiMultiplayer&&id==BUTTON_ID) { final GuiMultiplayer mpgui = (GuiMultiplayer) screen; - final ServerData server = getServerData(mpgui, this.compat.getSelected(mpgui)); + final ServerList serverList = this.compat.getServerList(mpgui); + final int serverindex = this.compat.getSelected(mpgui); + ServerData server = null; + if (0<=serverindex&&serverindex=10) + } else if (screen instanceof GuiMainMenu) + if (this.target.getServerIP()!=null&&!this.manualOpen&&Config.getConfig().durationDisconnected.get()>=10) if (this.timer.getTime()>0) - this.mc.displayGuiScreen(new GuiMultiplayer(mmgui)); - } + this.mc.displayGuiScreen(new GuiMultiplayer(screen)); } private void reset(final ConfigProperty time) { @@ -316,21 +331,54 @@ private void selectTarget(final GuiMultiplayer mpgui, final String serverIP) { } private int getTarget(final GuiMultiplayer mpgui, final String serverIP) { - final int count = this.compat.countServers(mpgui); - for (int i = 0; i=0) + server = serverList.getServerData(serverIndex); + if (server!=null) + return server; + } + if (name==null) + name = ip; + final ServerData server = new ServerData(name, ip, false); + if (doPing) + ping(mpgui, server); + return server; + } + + private void ping(final GuiMultiplayer mpgui, final ServerData serverData) { + if (!this.compat.getPinged(serverData)) { + this.compat.setPinged(serverData, true); + serverData.pingToServer = -2L; + serverData.serverMOTD = ""; + serverData.populationInfo = ""; + this.compat.getThreadPool().submit(() -> { + try { + this.compat.ping(mpgui, serverData); + } catch (final UnknownHostException unknownhostexception) { + serverData.pingToServer = -1L; + serverData.serverMOTD = "\u00a74Can\'t resolve hostname"; + } catch (final Exception exception) { + serverData.pingToServer = -1L; + serverData.serverMOTD = "\u00a74Can\'t connect to server."; + } + }); + } } } \ No newline at end of file diff --git a/src/main/java/net/teamfruit/serverobserver/ICompat.java b/src/main/java/net/teamfruit/serverobserver/ICompat.java index 538e03a..1160f8a 100644 --- a/src/main/java/net/teamfruit/serverobserver/ICompat.java +++ b/src/main/java/net/teamfruit/serverobserver/ICompat.java @@ -1,16 +1,18 @@ package net.teamfruit.serverobserver; import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; + +import javax.annotation.Nonnull; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiListExtended.IGuiListEntry; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; @@ -32,11 +34,13 @@ public interface ICompat { int getSelected(GuiMultiplayer mpgui); - void connectToServer(GuiMultiplayer mpgui, ServerData serverData); + void connectToServer(GuiMultiplayer mpgui, @Nonnull ServerData serverData); + + boolean getPinged(@Nonnull ServerData serverData); - boolean getPinged(ServerData serverData); + void setPinged(@Nonnull ServerData serverData, boolean pinged); - void setPinged(ServerData serverData, boolean pinged); + void ping(GuiMultiplayer mpgui, @Nonnull ServerData serverData) throws Exception; String getDefaultSound(); @@ -44,14 +48,13 @@ public interface ICompat { void selectServer(GuiMultiplayer mpgui, int index); - int countServers(GuiMultiplayer mpgui); - + @Deprecated ServerData getServerData(GuiMultiplayer mpgui, int index); - IGuiListEntry getListEntry(GuiMultiplayer mpgui, int index); - - ServerData getServerData(ServerListEntryNormal entry); + ServerList getServerList(GuiMultiplayer mpgui); GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside); + ThreadPoolExecutor getThreadPool(); + } \ No newline at end of file diff --git a/src/main/resources/assets/serverobserver/lang/en_US.lang b/src/main/resources/assets/serverobserver/lang/en_US.lang index 713960c..ed8a5c0 100644 --- a/src/main/resources/assets/serverobserver/lang/en_US.lang +++ b/src/main/resources/assets/serverobserver/lang/en_US.lang @@ -36,6 +36,8 @@ serverobserver.config.miscellaneous=Miscellaneous serverobserver.config.miscellaneous.tooltip=Miscellaneous serverobserver.config.miscellaneous.startwithmultiplayermenu=Start with Multiplayer menu serverobserver.config.miscellaneous.startwithmultiplayermenu.tooltip=After game initialized, show multiplayer menu +serverobserver.config.miscellaneous.startandconnect=Start and connect to the server +serverobserver.config.miscellaneous.startandconnect.tooltip=After game initialized, connect to the server serverobserver.config.status=Status serverobserver.config.status.tooltip=Current Status serverobserver.config.status.initservers=Initialize server list diff --git a/src/main/resources/assets/serverobserver/lang/ja_JP.lang b/src/main/resources/assets/serverobserver/lang/ja_JP.lang index cf0f89d..b0275d3 100644 --- a/src/main/resources/assets/serverobserver/lang/ja_JP.lang +++ b/src/main/resources/assets/serverobserver/lang/ja_JP.lang @@ -36,6 +36,8 @@ serverobserver.config.miscellaneous=その他 serverobserver.config.miscellaneous.tooltip=その他設定 serverobserver.config.miscellaneous.startwithmultiplayermenu=マルチプレイ画面から開始 serverobserver.config.miscellaneous.startwithmultiplayermenu.tooltip=起動したあと、マルチプレイ画面を表示します。 +serverobserver.config.miscellaneous.startandconnect=起動後サーバーへ接続 +serverobserver.config.miscellaneous.startandconnect.tooltip=起動したあと、サーバーへ接続します。 serverobserver.config.status=ステータス serverobserver.config.status.tooltip=現在の状態 serverobserver.config.status.initservers=サーバーリストを初期化