2014-12-28 22:37:21 +00:00
|
|
|
From 17906168cc148f5e0159b13415a6c6be73e07475 Mon Sep 17 00:00:00 2001
|
2014-12-27 23:21:50 +00:00
|
|
|
From: Zach Brown <Zbob750@live.com>
|
2014-12-28 22:37:21 +00:00
|
|
|
Date: Sun, 28 Dec 2014 16:28:21 -0600
|
2014-12-27 23:21:50 +00:00
|
|
|
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
|
2014-12-28 22:37:21 +00:00
|
|
|
index b55abdb..61f7443 100644
|
2014-12-27 23:21:50 +00:00
|
|
|
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
2014-12-28 22:37:21 +00:00
|
|
|
@@ -185,7 +185,22 @@ public class VersionCommand extends BukkitCommand {
|
2014-12-27 23:21:50 +00:00
|
|
|
private void obtainVersion() {
|
|
|
|
String version = Bukkit.getVersion();
|
|
|
|
if (version == null) version = "Custom";
|
|
|
|
- if (version.startsWith("git-Spigot-")) {
|
2014-12-28 22:37:21 +00:00
|
|
|
+ // PaperSpigot start
|
2014-12-27 23:21:50 +00:00
|
|
|
+ if (version.startsWith("git-PaperSpigot-")) {
|
|
|
|
+ String[] parts = version.substring("git-PaperSpigot-".length()).split("-");
|
2014-12-28 22:37:21 +00:00
|
|
|
+ int cbVersions = getDistance("craftbukkit", parts[1].substring(0, parts[1].indexOf(' ')));
|
2014-12-27 23:21:50 +00:00
|
|
|
+ int paperSpigotVersions = getDistance("paperspigot", parts[0]);
|
2014-12-28 22:37:21 +00:00
|
|
|
+ if (cbVersions == -1 || paperSpigotVersions == -1) {
|
2014-12-27 23:21:50 +00:00
|
|
|
+ setVersionMessage("Error obtaining version information");
|
2014-12-28 22:37:21 +00:00
|
|
|
+ } else {
|
|
|
|
+ if (cbVersions == 0 && paperSpigotVersions == 0) {
|
2014-12-27 23:21:50 +00:00
|
|
|
+ setVersionMessage("You are running the latest version");
|
2014-12-28 22:37:21 +00:00
|
|
|
+ } else {
|
2014-12-27 23:21:50 +00:00
|
|
|
+ setVersionMessage("You are " + (cbVersions + paperSpigotVersions) + " version(s) behind");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (version.startsWith("git-Spigot-")) {
|
|
|
|
+ // PaperSpigot end
|
|
|
|
String[] parts = version.substring("git-Spigot-".length()).split("-");
|
2014-12-28 22:37:21 +00:00
|
|
|
int cbVersions = getDistance("craftbukkit", parts[1].substring(0, parts[1].indexOf(' ')));
|
2014-12-27 23:21:50 +00:00
|
|
|
int spigotVersions = getDistance("spigot", parts[0]);
|
2014-12-28 22:37:21 +00:00
|
|
|
@@ -235,7 +250,7 @@ public class VersionCommand extends BukkitCommand {
|
2014-12-27 23:21:50 +00:00
|
|
|
private static int getDistance(String repo, String hash) {
|
|
|
|
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://hub.spigotmc.org/stash/rest/api/1.0/projects/PAPER/repos/" + repo + "/commits?since=" + URLEncoder.encode(hash, "UTF-8") + "&withCounts=true"), // PaperSpigot
|
|
|
|
Charsets.UTF_8
|
|
|
|
).openBufferedStream();
|
|
|
|
try {
|
|
|
|
--
|
|
|
|
1.9.5.msysgit.0
|
|
|
|
|