mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-07 17:07:59 +01:00
parent
22c2a4abcc
commit
f38c393d6f
@ -88,20 +88,15 @@ public final class SpigotUpdater extends Updater {
|
||||
}
|
||||
}
|
||||
|
||||
private static final String PROTOCOL = "https://";
|
||||
private static final String RESOURCE_URL = PROTOCOL + "www.spigotmc.org/resources/protocollib.1997/";
|
||||
private static final String API_URL = PROTOCOL + "www.spigotmc.org/api/general.php";
|
||||
private static final String ACTION = "POST";
|
||||
|
||||
private static final int ID = 1997;
|
||||
private static final byte[] API_KEY = ("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=" + ID).getBytes(Charsets.UTF_8);
|
||||
private static final String RESOURCE_URL = "https://www.spigotmc.org/resources/protocollib.1997/";
|
||||
private static final String UPDATE_URL = "https://api.spigotmc.org/legacy/update.php?resource=1997";
|
||||
private static final String ACTION = "GET";
|
||||
|
||||
public String getSpigotVersion() throws IOException {
|
||||
try (Closer closer = Closer.create()) {
|
||||
HttpURLConnection con = (HttpURLConnection) new URL(API_URL).openConnection();
|
||||
HttpURLConnection con = (HttpURLConnection) new URL(UPDATE_URL).openConnection();
|
||||
con.setDoOutput(true);
|
||||
con.setRequestMethod(ACTION);
|
||||
con.getOutputStream().write(API_KEY);
|
||||
|
||||
InputStreamReader isr = closer.register(new InputStreamReader(con.getInputStream()));
|
||||
BufferedReader br = closer.register(new BufferedReader(isr));
|
||||
|
@ -12,6 +12,8 @@ import java.util.logging.Logger;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.comphenix.protocol.updater.Updater.UpdateType;
|
||||
|
||||
@ -23,14 +25,14 @@ public class UpdaterTest {
|
||||
private static final int BUKKIT_DEV_ID = 45564;
|
||||
private static Plugin plugin;
|
||||
|
||||
// @BeforeClass
|
||||
@BeforeClass
|
||||
public static void preparePlugin() {
|
||||
Server server = mock(Server.class);
|
||||
when(server.getUpdateFolder()).thenReturn(null);
|
||||
|
||||
plugin = mock(Plugin.class);
|
||||
String version = System.getProperty("projectVersion");
|
||||
if (version == null) version = "4.2.1";
|
||||
if (version == null) version = "4.4.0";
|
||||
when(plugin.getDescription()).thenReturn(new PluginDescriptionFile("ProtocolLib", version, null));
|
||||
when(plugin.getLogger()).thenReturn(Logger.getLogger("ProtocolLib"));
|
||||
when(plugin.getDataFolder()).thenReturn(null);
|
||||
|
Loading…
Reference in New Issue
Block a user