Fix
This commit is contained in:
parent
f58590e137
commit
68aa0e3104
|
@ -15,6 +15,7 @@ import net.silentclient.client.event.impl.ConnectToServerEvent;
|
||||||
import net.silentclient.client.event.impl.ServerLeaveEvent;
|
import net.silentclient.client.event.impl.ServerLeaveEvent;
|
||||||
import net.silentclient.client.event.impl.SingleplayerJoinEvent;
|
import net.silentclient.client.event.impl.SingleplayerJoinEvent;
|
||||||
import net.silentclient.client.gui.GuiError;
|
import net.silentclient.client.gui.GuiError;
|
||||||
|
import net.silentclient.client.gui.GuiNews;
|
||||||
import net.silentclient.client.gui.clickgui.ClickGUI;
|
import net.silentclient.client.gui.clickgui.ClickGUI;
|
||||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||||
import net.silentclient.client.gui.util.BackgroundPanorama;
|
import net.silentclient.client.gui.util.BackgroundPanorama;
|
||||||
|
@ -250,6 +251,19 @@ public class Client {
|
||||||
|
|
||||||
Client.logger.info("STARTING > launching-detector");
|
Client.logger.info("STARTING > launching-detector");
|
||||||
Requests.post("https://api.silentclient.net/_next/launch_v2", new JSONObject().put("branch", getBuildData().getBranch()).toString());
|
Requests.post("https://api.silentclient.net/_next/launch_v2", new JSONObject().put("branch", getBuildData().getBranch()).toString());
|
||||||
|
|
||||||
|
logger.info("STARTING > news");
|
||||||
|
String content = Requests.get("https://api.silentclient.net/_next/news/latest");
|
||||||
|
|
||||||
|
if(content != null) {
|
||||||
|
try {
|
||||||
|
NewsResponse newsResponse = getGson().fromJson(content, NewsResponse.class);
|
||||||
|
|
||||||
|
GuiNews.news = newsResponse;
|
||||||
|
} catch (Exception err) {
|
||||||
|
logger.catching(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch(Exception err) {
|
} catch(Exception err) {
|
||||||
logger.info("STARTING > ERROR: " + err.getMessage());
|
logger.info("STARTING > ERROR: " + err.getMessage());
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
@ -6,6 +6,10 @@ import net.minecraft.util.ResourceLocation;
|
||||||
public class StaticResourceLocation {
|
public class StaticResourceLocation {
|
||||||
private ResourceLocation location;
|
private ResourceLocation location;
|
||||||
|
|
||||||
|
public StaticResourceLocation(ResourceLocation location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
public StaticResourceLocation(String path) {
|
public StaticResourceLocation(String path) {
|
||||||
this.location = new ResourceLocation(path);
|
this.location = new ResourceLocation(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.silentclient.client.gui.minecraft.GuiMainMenu;
|
||||||
import net.silentclient.client.gui.util.RenderUtil;
|
import net.silentclient.client.gui.util.RenderUtil;
|
||||||
import net.silentclient.client.utils.SCTextureManager;
|
import net.silentclient.client.utils.SCTextureManager;
|
||||||
import net.silentclient.client.utils.TimerUtils;
|
import net.silentclient.client.utils.TimerUtils;
|
||||||
|
import net.silentclient.client.utils.types.NewsResponse;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -29,6 +30,7 @@ public class GuiNews extends GuiScreen {
|
||||||
private TimerUtils logoTimer = new TimerUtils();
|
private TimerUtils logoTimer = new TimerUtils();
|
||||||
private int logoY = 0;
|
private int logoY = 0;
|
||||||
private final boolean firstTime;
|
private final boolean firstTime;
|
||||||
|
public static NewsResponse news;
|
||||||
|
|
||||||
public GuiNews() {
|
public GuiNews() {
|
||||||
this.firstTime = false;
|
this.firstTime = false;
|
||||||
|
@ -40,11 +42,11 @@ public class GuiNews extends GuiScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
if(image == null && !loading) {
|
if(image == null && !loading && news != null) {
|
||||||
loading = true;
|
loading = true;
|
||||||
(new Thread("NewsThread") {
|
(new Thread("NewsThread") {
|
||||||
public void run() {
|
public void run() {
|
||||||
GuiNews.image = SCTextureManager.getImage("https://i.imgur.com/jdEAKN6.png");
|
GuiNews.image = SCTextureManager.getImage(news.getItem().getCover());
|
||||||
GuiNews.loading = false;
|
GuiNews.loading = false;
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
@ -60,7 +62,7 @@ public class GuiNews extends GuiScreen {
|
||||||
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
if(imageLocation != null) {
|
if(imageLocation != null) {
|
||||||
RenderUtil.drawImage(imageLocation, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168);
|
RenderUtil.drawImage(imageLocation, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
@ -94,11 +96,11 @@ public class GuiNews extends GuiScreen {
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
if(MouseUtils.isInside(mouseX, mouseY, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168)) {
|
if(MouseUtils.isInside(mouseX, mouseY, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168) && news != null) {
|
||||||
try {
|
try {
|
||||||
Class<?> oclass = Class.forName("java.awt.Desktop");
|
Class<?> oclass = Class.forName("java.awt.Desktop");
|
||||||
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
|
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
|
||||||
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://silentclient.net/news/latest")});
|
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://silentclient.net/news/" + GuiNews.news.getItem().id)});
|
||||||
} catch (Throwable err) {
|
} catch (Throwable err) {
|
||||||
err.printStackTrace();
|
err.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,6 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback
|
||||||
float f = 1.8F - MathHelper.abs(MathHelper.sin((float)(Minecraft.getSystemTime() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F);
|
float f = 1.8F - MathHelper.abs(MathHelper.sin((float)(Minecraft.getSystemTime() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F);
|
||||||
f = f * 100.0F / (float)(this.fontRendererObj.getStringWidth(this.splashText) + 32);
|
f = f * 100.0F / (float)(this.fontRendererObj.getStringWidth(this.splashText) + 32);
|
||||||
GlStateManager.scale(f, f, f);
|
GlStateManager.scale(f, f, f);
|
||||||
// this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, -256);
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
String s = "Silent Client 1.8.9";
|
String s = "Silent Client 1.8.9";
|
||||||
|
|
||||||
|
@ -332,7 +331,9 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback
|
||||||
|
|
||||||
Client.getInstance().getSilentFontRenderer().drawString(s, 2, this.height - 14, 14, SilentFontRenderer.FontType.TITLE);
|
Client.getInstance().getSilentFontRenderer().drawString(s, 2, this.height - 14, 14, SilentFontRenderer.FontType.TITLE);
|
||||||
|
|
||||||
RenderUtil.drawImage(new ResourceLocation(Client.getInstance().getAccount().discord_id != null ? "silentclient/promo/latest.png" : "silentclient/images/discord.png"), this.width - 73, this.height - 42, 71, 40);
|
if(GuiNews.imageLocation != null) {
|
||||||
|
RenderUtil.drawImage(new ResourceLocation(Client.getInstance().getAccount().discord_id != null ? GuiNews.imageLocation.getResourcePath() : "silentclient/images/discord.png"), this.width - 73, this.height - 42, 71, 40, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.openGLWarning1 != null && this.openGLWarning1.length() > 0)
|
if (this.openGLWarning1 != null && this.openGLWarning1.length() > 0)
|
||||||
{
|
{
|
||||||
|
@ -351,11 +352,11 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback
|
||||||
{
|
{
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
if(MouseUtils.isInside(mouseX, mouseY, this.width - 73, this.height - 42, 71, 40)) {
|
if(MouseUtils.isInside(mouseX, mouseY, this.width - 73, this.height - 42, 71, 40) && GuiNews.news != null) {
|
||||||
try {
|
try {
|
||||||
Class<?> oclass = Class.forName("java.awt.Desktop");
|
Class<?> oclass = Class.forName("java.awt.Desktop");
|
||||||
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
|
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
|
||||||
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(Client.getInstance().getAccount().discord_id != null ? "https://silentclient.net/news/latest" : "https://silentclient.net/news/4")});
|
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(Client.getInstance().getAccount().discord_id != null ? "https://silentclient.net/news/" + + GuiNews.news.getItem().id : "https://silentclient.net/news/4")});
|
||||||
} catch (Throwable err) {
|
} catch (Throwable err) {
|
||||||
err.printStackTrace();
|
err.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -572,7 +572,7 @@ public class RenderUtil {
|
||||||
if(mip) {
|
if(mip) {
|
||||||
Client.getInstance().getTextureManager().bindTextureMipmapped(image);
|
Client.getInstance().getTextureManager().bindTextureMipmapped(image);
|
||||||
} else {
|
} else {
|
||||||
((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).waitBindTexture(new StaticResourceLocation(image.getResourcePath()), new StaticResourceLocation("silentclient/transparent.png"));
|
((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).waitBindTexture(new StaticResourceLocation(image), new StaticResourceLocation("silentclient/transparent.png"));
|
||||||
}
|
}
|
||||||
Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, (float) 0.0f, (float) 0.0f, (int) width, (int) height, (float) width, (float) height);
|
Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, (float) 0.0f, (float) 0.0f, (int) width, (int) height, (float) width, (float) height);
|
||||||
GL11.glDepthMask((boolean) true);
|
GL11.glDepthMask((boolean) true);
|
||||||
|
|
|
@ -8,7 +8,9 @@ import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
import net.silentclient.client.Client;
|
||||||
import net.silentclient.client.mixin.accessors.TextureManagerAccessor;
|
import net.silentclient.client.mixin.accessors.TextureManagerAccessor;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -181,10 +183,14 @@ public class SCTextureManager
|
||||||
|
|
||||||
public static BufferedImage getImage(String paramString) {
|
public static BufferedImage getImage(String paramString) {
|
||||||
try {
|
try {
|
||||||
URL uRL = new URL(paramString);
|
final URL url = new URL(paramString);
|
||||||
return ImageIO.read(uRL);
|
final HttpsURLConnection connection = (HttpsURLConnection) url
|
||||||
} catch (IOException iOException) {
|
.openConnection();
|
||||||
iOException.printStackTrace();
|
connection.setRequestProperty("User-Agent", "SilentClient");
|
||||||
|
connection.disconnect();
|
||||||
|
return ImageIO.read(connection.getInputStream());
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Client.logger.catching(exception);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package net.silentclient.client.utils.types;
|
||||||
|
|
||||||
|
public class NewsResponse {
|
||||||
|
public NewsItem news;
|
||||||
|
|
||||||
|
public NewsItem getItem() {
|
||||||
|
return news;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NewsItem {
|
||||||
|
public int id;
|
||||||
|
public String cover;
|
||||||
|
|
||||||
|
public String getCover() {
|
||||||
|
return "https://cdn.silentclient.net/assets" + cover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue