3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-05 09:40:06 +02:00

Merge branch 'master' of https://github.com/Matsv/ViaVersion into dumpthemall

Dieser Commit ist enthalten in:
Matsv 2016-08-20 16:21:19 +02:00
Commit 0f96c24c78
4 geänderte Dateien mit 45 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -21,6 +21,7 @@ import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.api.command.ViaVersionCommand; import us.myles.ViaVersion.api.command.ViaVersionCommand;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.boss.ViaBossBar; import us.myles.ViaVersion.boss.ViaBossBar;
import us.myles.ViaVersion.classgenerator.ClassGenerator; import us.myles.ViaVersion.classgenerator.ClassGenerator;
import us.myles.ViaVersion.commands.ViaCommandHandler; import us.myles.ViaVersion.commands.ViaCommandHandler;
@ -60,7 +61,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null; protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null;
if (protocolSupport) { if (protocolSupport) {
getLogger().info("Patching to prevent concurrency issues..."); getLogger().info("Hooking into ProtocolSupport, to prevent issues!");
try { try {
patchLists(); patchLists();
} catch (Exception e) { } catch (Exception e) {
@ -84,7 +85,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
} }
} else { } else {
getLogger().severe("ViaVersion is already loaded, this should work fine... Otherwise reboot the server!!!"); getLogger().severe("ViaVersion is already loaded, this should work fine. If you get any console errors, try rebooting.");
} }
} }
@ -125,9 +126,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
gatherProtocolVersion(); gatherProtocolVersion();
// Check if there are any pipes to this version // Check if there are any pipes to this version
if (ProtocolRegistry.SERVER_PROTOCOL != -1) { if (ProtocolRegistry.SERVER_PROTOCOL != -1) {
getLogger().info("ViaVersion detected protocol version: " + ProtocolRegistry.SERVER_PROTOCOL); getLogger().info("ViaVersion detected server version: " + ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL));
if (!ProtocolRegistry.isWorkingPipe()) { if (!ProtocolRegistry.isWorkingPipe()) {
getLogger().warning("ViaVersion will not function on the current protocol."); getLogger().warning("ViaVersion does not have any compatible versions for this server version, please read our resource page carefully.");
} }
} }
ProtocolRegistry.refreshVersions(); ProtocolRegistry.refreshVersions();
@ -151,7 +152,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
@Override @Override
public void onDisable() { public void onDisable() {
getLogger().info("ViaVersion is disabling, if this is a reload it may not work."); getLogger().info("ViaVersion is disabling, if this is a reload and you experience issues consider rebooting.");
uninject(); uninject();
} }
@ -222,7 +223,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
try { try {
Object connection = getServerConnection(); Object connection = getServerConnection();
if (connection == null) { if (connection == null) {
getLogger().warning("We failed to find the ServerConnection? :( What server are you running?"); getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub.");
return; return;
} }
for (Field field : connection.getClass().getDeclaredFields()) { for (Field field : connection.getClass().getDeclaredFields()) {
@ -256,7 +257,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
} }
System.setProperty("ViaVersion", getDescription().getVersion()); System.setProperty("ViaVersion", getDescription().getVersion());
} catch (Exception e) { } catch (Exception e) {
getLogger().severe("Unable to inject handlers, are you on 1.8? "); getLogger().severe("Unable to inject ViaVersion, please post these details on our GitHub and ensure you're using a compatible server version.");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -265,7 +266,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
public void patchLists() throws Exception { public void patchLists() throws Exception {
Object connection = getServerConnection(); Object connection = getServerConnection();
if (connection == null) { if (connection == null) {
getLogger().warning("We failed to find the ServerConnection? :( What server are you running?"); getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub.");
return; return;
} }
for (Field field : connection.getClass().getDeclaredFields()) { for (Field field : connection.getClass().getDeclaredFields()) {
@ -325,12 +326,12 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
PluginDescriptionFile yaml = ReflectionUtil.get(cl, "description", PluginDescriptionFile.class); PluginDescriptionFile yaml = ReflectionUtil.get(cl, "description", PluginDescriptionFile.class);
throw new Exception("Unable to inject, due to " + bootstrapAcceptor.getClass().getName() + ", try without the plugin " + yaml.getName() + "?"); throw new Exception("Unable to inject, due to " + bootstrapAcceptor.getClass().getName() + ", try without the plugin " + yaml.getName() + "?");
} else { } else {
throw new Exception("Unable to find childHandler, weird server version? " + bootstrapAcceptor.getClass().getName()); throw new Exception("Unable to find core component 'childHandler', please check your plugins. issue: " + bootstrapAcceptor.getClass().getName());
} }
} }
} catch (Exception e) { } catch (Exception e) {
getLogger().severe("Have you got late-bind enabled with something else?"); getLogger().severe("We failed to inject ViaVersion, have you got late-bind enabled with something else?");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -345,7 +346,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((ViaVersionInitializer) oldInit).getOriginal()); ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((ViaVersionInitializer) oldInit).getOriginal());
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Failed to remove injection... reload won't work with connections sorry"); System.out.println("Failed to remove injection handler, reload won't work with connections, please reboot!");
} }
} }
injectedFutures.clear(); injectedFutures.clear();
@ -357,7 +358,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
pair.getKey().set(pair.getValue(), ((ListWrapper) o).getOriginalList()); pair.getKey().set(pair.getValue(), ((ListWrapper) o).getOriginalList());
} }
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
System.out.println("Failed to remove injection... reload might not work with connections sorry"); System.out.println("Failed to remove injection, reload won't work with connections, please reboot!");
} }
} }

Datei anzeigen

@ -18,7 +18,7 @@ public class PaperPatch extends ViaListener {
/* /*
This patch is applied when Paper is detected. This patch is applied when Paper is detected.
I'm unsure of what causes this but essentially, I'm unsure of what causes this but essentially,
placing blocks where your standing works? placing blocks where you're standing works?
If there is a better fix then we'll replace this. If there is a better fix then we'll replace this.
*/ */

Datei anzeigen

@ -82,14 +82,18 @@ public class UpdateUtil {
try { try {
current = new Version(ViaVersion.getInstance().getVersion()); current = new Version(ViaVersion.getInstance().getVersion());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return "You are using a debug/custom version, consider updating."; return "You are using a custom version, consider updating.";
} }
Version newest = new Version(newestString); Version newest = new Version(newestString);
if (current.compareTo(newest) < 0) if (current.compareTo(newest) < 0)
return "There is a newer version available: " + newest.toString(); return "There is a newer version available: " + newest.toString() + ", you're on: " + current.toString();
else if (console && current.compareTo(newest) != 0) { else if (console && current.compareTo(newest) != 0) {
if (current.getTag().toLowerCase().startsWith("dev") || current.getTag().toLowerCase().startsWith("snapshot")) {
return "You are running a development version, please report any bugs to GitHub.";
} else {
return "You are running a newer version than is released!"; return "You are running a newer version than is released!";
} }
}
return null; return null;
} }

Datei anzeigen

@ -2,21 +2,26 @@ package us.myles.ViaVersion.update;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Version implements Comparable<Version> { public class Version implements Comparable<Version> {
private int[] parts; private static Pattern semVer = Pattern.compile("(?<a>0|[1-9]\\d*)\\.(?<b>0|[1-9]\\d*)(?:\\.(?<c>0|[1-9]\\d*))?(?:-(?<tag>[A-z0-9.-]*))?");
private int[] parts = new int[3];
private String tag;
public Version(String value) { public Version(String value) {
if (value == null) if (value == null)
throw new IllegalArgumentException("Version can not be null"); throw new IllegalArgumentException("Version can not be null");
if (!value.matches("^[0-9]+(\\.[0-9]+)*$")) Matcher matcher = semVer.matcher(value);
if (!matcher.matches())
throw new IllegalArgumentException("Invalid version format"); throw new IllegalArgumentException("Invalid version format");
parts[0] = Integer.parseInt(matcher.group("a"));
parts[1] = Integer.parseInt(matcher.group("b"));
parts[2] = matcher.group("c") == null ? 0 : Integer.parseInt(matcher.group("c"));
String[] split = value.split("\\."); tag = matcher.group("tag") == null ? "" : matcher.group("tag");
parts = new int[split.length];
for (int i = 0; i < split.length; i += 1)
parts[i] = Integer.parseInt(split[i]);
} }
public static int compare(Version verA, Version verB) { public static int compare(Version verA, Version verB) {
@ -33,6 +38,12 @@ public class Version implements Comparable<Version> {
if (partA > partB) return 1; if (partA > partB) return 1;
} }
// Simple tag check
if (verA.tag.length() == 0 && verB.tag.length() > 0)
return 1;
if (verA.tag.length() > 0 && verB.tag.length() == 0)
return -1;
return 0; return 0;
} }
@ -47,7 +58,7 @@ public class Version implements Comparable<Version> {
for (int i = 0; i < parts.length; i += 1) for (int i = 0; i < parts.length; i += 1)
split[i] = String.valueOf(parts[i]); split[i] = String.valueOf(parts[i]);
return StringUtils.join(split, "."); return StringUtils.join(split, ".") + (tag.length() != 0 ? "-" + tag : "");
} }
@Override @Override
@ -59,4 +70,8 @@ public class Version implements Comparable<Version> {
public boolean equals(Object that) { public boolean equals(Object that) {
return that instanceof Version && equals(this, (Version) that); return that instanceof Version && equals(this, (Version) that);
} }
public String getTag() {
return tag;
}
} }