Skip to content

Commit

Permalink
merge private to public
Browse files Browse the repository at this point in the history
  • Loading branch information
TudbuT committed Dec 24, 2020
1 parent 84a6532 commit 08926ed
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/java/tudbut/mod/client/yac/events/FMLEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
import tudbut.mod.client.yac.YAC;
import tudbut.mod.client.yac.mods.ChatColor;
import tudbut.mod.client.yac.mods.ChatSuffix;
import tudbut.mod.client.yac.mods.TPAParty;
import tudbut.mod.client.yac.utils.ChatUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

public class FMLEventHandler {

private int chatHelper = 0;
Expand Down Expand Up @@ -83,6 +90,38 @@ public void onServerChat(ClientChatReceivedEvent event) {
}
}

@SubscribeEvent
public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
try {
URL updateCheckURL = new URL("https://raw.githubusercontent.com/TudbuT/yacpub/master/version.txt");
InputStream stream = updateCheckURL.openConnection().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

String s;
StringBuilder builder = new StringBuilder();
while ((s = reader.readLine()) != null) {
builder.append(s);
}

s = builder.toString();
if (!s.equals(YAC.VERSION)) {
ChatUtils.print(
"§a§lA new YAC version was found! Current: " +
YAC.VERSION +
", New: " +
s +
"! Please consider updating at " +
"https://github.com/TudbuT/yacpub/releases/tag/" +
s
);
}
}
catch (IOException e) {
ChatUtils.print("Unable to check for a new version!");
e.printStackTrace();
}
}

@SubscribeEvent
public void onJoin(EntityJoinWorldEvent event) {
YAC.player = Minecraft.getMinecraft().player;
Expand Down

0 comments on commit 08926ed

Please sign in to comment.