mirror of
https://github.com/plexusorg/Plex.git
synced 2024-06-28 08:50:40 +00:00
0b5425b8d2
- Add update checking - World generation is broken - Won't compile unless 1.18.2 is in your local Maven repository - No longer need MiniMessage bundled in Plex - Customizable namehistory - Set comments in config.yml if they're missing
48 lines
1.3 KiB
Java
48 lines
1.3 KiB
Java
package dev.plex.util;
|
|
|
|
import dev.plex.PlexBase;
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.InputStreamReader;
|
|
import java.net.URL;
|
|
import java.net.URLConnection;
|
|
import org.bukkit.ChatColor;
|
|
|
|
public class UpdateChecker extends PlexBase
|
|
{
|
|
private final String currentVersion = plugin.getDescription().getVersion();
|
|
|
|
public boolean check()
|
|
{
|
|
try
|
|
{
|
|
String versionLink = "https://plex.us.org/updater/check/";
|
|
URL url = new URL(versionLink);
|
|
URLConnection con = url.openConnection();
|
|
InputStreamReader isr = new InputStreamReader(con.getInputStream());
|
|
BufferedReader reader = new BufferedReader(isr);
|
|
if (!reader.ready())
|
|
{
|
|
return false;
|
|
}
|
|
String newVersion = reader.readLine();
|
|
reader.close();
|
|
|
|
if (!newVersion.equals(currentVersion))
|
|
{
|
|
PlexLog.log(ChatColor.RED + "There is a new version of Plex available: " + newVersion);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (IOException e)
|
|
{
|
|
PlexLog.error("There was an error checking for updates!");
|
|
return false;
|
|
}
|
|
}
|
|
}
|