1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
package kr.syeyoung.dungeonsguide;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
import java.io.IOException;
public class YoMamaOutdated {
Logger logger = LogManager.getLogger("YoMamaOutdated");
public boolean isUsingOutdatedDg = true;
String outdatedMessage;
public YoMamaOutdated() {
MinecraftForge.EVENT_BUS.register(this);
this.check();
}
void check() {
isUsingOutdatedDg = false;
// try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
// HttpGet httpget = new HttpGet( "https://dungeonsguide.kingstefan26.workers.dev/outdated");
// Header[] haeders = {new BasicHeader("User-Agent", "DungeonsGuide/" + Main.VERSION)};
// httpget.setHeaders(haeders);
// HttpResponse httpresponse = httpclient.execute(httpget);
//
// if (httpresponse.getStatusLine().getStatusCode() != 200) {
// outdatedMessage = IOUtils.toString(httpresponse.getEntity().getContent(), StandardCharsets.UTF_8);
// }else {
// isUsingOutdatedDg = false;
// }
//
// } catch (Exception ignored) {
// }
}
private boolean showedError = false;
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
if (!showedError && isUsingOutdatedDg) {
showedError = true;
GuiScreen ogGui = event.gui;
event.gui = new GuiScreen() {
@Override
public void initGui() {
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
this.buttonList.add(new GuiButton(0, sr.getScaledWidth()/2-100,sr.getScaledHeight()-70 ,"Close Minecraft"));
this.buttonList.add(new GuiButton(1, sr.getScaledWidth()/2-100,sr.getScaledHeight()-40 ,"Ignore"));
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button);
if (button.id == 0) {
FMLCommonHandler.instance().exitJava(-1,true);
} else if (button.id == 1) {
Minecraft.getMinecraft().displayGuiScreen(ogGui);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawBackground(1);
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
String text = "This DungeonsGuide installation seems to be invalid";
fontRenderer.drawString(text, (sr.getScaledWidth()-fontRenderer.getStringWidth(text))/2,40,0xFFFF0000);
String text1 = "Message from our server:";
fontRenderer.drawString(text1, (sr.getScaledWidth()-fontRenderer.getStringWidth(text1))/2, (int) (40+fontRenderer.FONT_HEIGHT*1.5),0xFFFF0000);
int tenth = sr.getScaledWidth() / 10;
Gui.drawRect(tenth, 70,sr.getScaledWidth()-tenth, sr.getScaledHeight()-80, 0xFF5B5B5B);
clip(sr, tenth, 70,sr.getScaledWidth()-2*tenth, sr.getScaledHeight()-150);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
fontRenderer.drawString(outdatedMessage, tenth+2,fontRenderer.FONT_HEIGHT + 72, 0xFFFFFFFF);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
super.drawScreen(mouseX, mouseY, partialTicks);
}
public void clip(ScaledResolution resolution, int x, int y, int width, int height) {
if (width < 0 || height < 0) return;
int scale = resolution.getScaleFactor();
GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale);
}
};
}
}
}
|