mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
1a1422fd41
We have so many random strings around at the moment this will be better for now
61 lines
No EOL
3.2 KiB
Diff
61 lines
No EOL
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
|
Date: Sun, 28 Dec 2014 16:28:21 -0600
|
|
Subject: [PATCH] Check PaperSpigot versions
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
@@ -0,0 +0,0 @@ public class VersionCommand extends BukkitCommand {
|
|
private void obtainVersion() {
|
|
String version = Bukkit.getVersion();
|
|
if (version == null) version = "Custom";
|
|
- if (version.startsWith("git-Spigot-")) {
|
|
+ // PaperSpigot start
|
|
+ if (version.startsWith("git-PaperSpigot-")) {
|
|
+ String[] parts = version.substring("git-PaperSpigot-".length()).split("[-\\s]");
|
|
+ int paperSpigotVersions = getDistance("paperspigot", parts[0]);
|
|
+ if (paperSpigotVersions == -1) {
|
|
+ setVersionMessage("Error obtaining version information");
|
|
+ } else {
|
|
+ if (paperSpigotVersions == 0) {
|
|
+ setVersionMessage("You are running the latest version");
|
|
+ } else {
|
|
+ setVersionMessage("You are " + paperSpigotVersions + " version(s) behind");
|
|
+ }
|
|
+ }
|
|
+ } else if (version.startsWith("git-Spigot-")) {
|
|
+ // PaperSpigot end
|
|
String[] parts = version.substring("git-Spigot-".length()).split("-");
|
|
int cbVersions = getDistance("craftbukkit", parts[1].substring(0, parts[1].indexOf(' ')));
|
|
int spigotVersions = getDistance("spigot", parts[0]);
|
|
@@ -0,0 +0,0 @@ public class VersionCommand extends BukkitCommand {
|
|
}
|
|
}
|
|
|
|
- private static int getDistance(String repo, String hash) {
|
|
+ private static int getDistance(String repo, String currentVerInt) { // PaperSpigot
|
|
try {
|
|
BufferedReader reader = Resources.asCharSource(
|
|
- new URL("https://hub.spigotmc.org/stash/rest/api/1.0/projects/SPIGOT/repos/" + repo + "/commits?since=" + URLEncoder.encode(hash, "UTF-8") + "&withCounts=true"),
|
|
+ new URL("https://ci.destroystokyo.com/job/PaperSpigot/lastSuccessfulBuild/buildNumber"), // PaperSpigot
|
|
Charsets.UTF_8
|
|
).openBufferedStream();
|
|
try {
|
|
- JSONObject obj = (JSONObject) new JSONParser().parse(reader);
|
|
- return ((Number) obj.get("totalCount")).intValue();
|
|
- } catch (ParseException ex) {
|
|
- ex.printStackTrace();
|
|
+ // PaperSpigot start
|
|
+ int newVer = Integer.decode(reader.readLine());
|
|
+ int currentVer = Integer.decode(currentVerInt);
|
|
+ return newVer - currentVer;
|
|
+ } catch (NumberFormatException ex) {
|
|
+ //ex.printStackTrace();
|
|
+ // PaperSpigot end
|
|
return -1;
|
|
} finally {
|
|
reader.close();
|
|
--
|