Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Merge branch 'master' of https://github.com/MylesIsCool/ViaVersion into 1.11-DEV
Dieser Commit ist enthalten in:
Commit
725ab0f713
@ -21,6 +21,7 @@ import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
import us.myles.ViaVersion.api.command.ViaVersionCommand;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.boss.ViaBossBar;
|
||||
import us.myles.ViaVersion.classgenerator.ClassGenerator;
|
||||
import us.myles.ViaVersion.commands.ViaCommandHandler;
|
||||
@ -60,7 +61,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null;
|
||||
|
||||
if (protocolSupport) {
|
||||
getLogger().info("Patching to prevent concurrency issues...");
|
||||
getLogger().info("Hooking into ProtocolSupport, to prevent issues!");
|
||||
try {
|
||||
patchLists();
|
||||
} catch (Exception e) {
|
||||
@ -84,7 +85,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
}
|
||||
|
||||
} 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();
|
||||
// Check if there are any pipes to this version
|
||||
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()) {
|
||||
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();
|
||||
@ -151,7 +152,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
||||
@ -222,7 +223,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
try {
|
||||
Object connection = getServerConnection();
|
||||
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;
|
||||
}
|
||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||
@ -256,7 +257,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
}
|
||||
System.setProperty("ViaVersion", getDescription().getVersion());
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
@ -265,7 +266,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
public void patchLists() throws Exception {
|
||||
Object connection = getServerConnection();
|
||||
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;
|
||||
}
|
||||
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);
|
||||
throw new Exception("Unable to inject, due to " + bootstrapAcceptor.getClass().getName() + ", try without the plugin " + yaml.getName() + "?");
|
||||
} 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) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -345,7 +346,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((ViaVersionInitializer) oldInit).getOriginal());
|
||||
}
|
||||
} 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();
|
||||
@ -357,7 +358,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
pair.getKey().set(pair.getValue(), ((ListWrapper) o).getOriginalList());
|
||||
}
|
||||
} 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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ public class ViaCommandHandler implements ViaVersionCommand, CommandExecutor, Ta
|
||||
registerSubCommand(new ListSubCmd());
|
||||
registerSubCommand(new PPSSubCmd());
|
||||
registerSubCommand(new DebugSubCmd());
|
||||
registerSubCommand(new DumpSubCmd());
|
||||
registerSubCommand(new DisplayLeaksSubCmd());
|
||||
registerSubCommand(new DontBugMeSubCmd());
|
||||
registerSubCommand(new AutoTeamSubCmd());
|
||||
|
@ -0,0 +1,91 @@
|
||||
package us.myles.ViaVersion.commands.defaultsubs;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.command.ViaSubCommand;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.dump.DumpTemplate;
|
||||
import us.myles.ViaVersion.dump.PluginInfo;
|
||||
import us.myles.ViaVersion.dump.VersionInfo;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DumpSubCmd extends ViaSubCommand {
|
||||
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "dump";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Dump information about your server, this is helpful if you report bugs.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final CommandSender sender, String[] args) {
|
||||
VersionInfo version = new VersionInfo(
|
||||
Bukkit.getServer().getVersion(),
|
||||
Bukkit.getServer().getBukkitVersion(),
|
||||
System.getProperty("java.version"),
|
||||
System.getProperty("os.name"),
|
||||
ProtocolRegistry.SERVER_PROTOCOL,
|
||||
ProtocolRegistry.getSupportedVersions());
|
||||
|
||||
List<PluginInfo> plugins = new ArrayList<>();
|
||||
for (Plugin p : Bukkit.getPluginManager().getPlugins())
|
||||
plugins.add(new PluginInfo(p.isEnabled(), p.getDescription().getName(), p.getDescription().getVersion(), p.getDescription().getMain(), p.getDescription().getAuthors()));
|
||||
|
||||
final DumpTemplate template = new DumpTemplate(version, plugins);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously((ViaVersionPlugin) ViaVersion.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
HttpURLConnection con = (HttpURLConnection) new URL("http://hastebin.com/documents").openConnection();
|
||||
|
||||
con.setRequestProperty("Content-Type", "text/plain");
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
|
||||
OutputStream out = con.getOutputStream();
|
||||
out.write(gson.toJson(template).getBytes(Charset.forName("UTF-8")));
|
||||
out.close();
|
||||
|
||||
JsonObject output = gson.fromJson(new InputStreamReader(con.getInputStream()), JsonObject.class);
|
||||
con.getInputStream().close();
|
||||
|
||||
if (!output.has("key"))
|
||||
throw new InvalidObjectException("Key is not given in Hastebin output");
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "We've made a dump with useful information, report your issue and provide this url: " + getUrl(output.get("key").getAsString()));
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
|
||||
((ViaVersionPlugin) ViaVersion.getInstance()).getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Hastebin", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getUrl(String id) {
|
||||
return String.format("http://hastebin.com/%s.json", id);
|
||||
}
|
||||
}
|
13
src/main/java/us/myles/ViaVersion/dump/DumpTemplate.java
Normale Datei
13
src/main/java/us/myles/ViaVersion/dump/DumpTemplate.java
Normale Datei
@ -0,0 +1,13 @@
|
||||
package us.myles.ViaVersion.dump;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DumpTemplate {
|
||||
private VersionInfo versions;
|
||||
private List<PluginInfo> plugins;
|
||||
}
|
16
src/main/java/us/myles/ViaVersion/dump/PluginInfo.java
Normale Datei
16
src/main/java/us/myles/ViaVersion/dump/PluginInfo.java
Normale Datei
@ -0,0 +1,16 @@
|
||||
package us.myles.ViaVersion.dump;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PluginInfo {
|
||||
private boolean enabled;
|
||||
private String name;
|
||||
private String version;
|
||||
private String main;
|
||||
private List<String> authors;
|
||||
}
|
18
src/main/java/us/myles/ViaVersion/dump/VersionInfo.java
Normale Datei
18
src/main/java/us/myles/ViaVersion/dump/VersionInfo.java
Normale Datei
@ -0,0 +1,18 @@
|
||||
package us.myles.ViaVersion.dump;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class VersionInfo {
|
||||
private String version;
|
||||
private String bukkitVersion;
|
||||
private String javaVersion;
|
||||
private String operatingSystem;
|
||||
private int serverProtocol;
|
||||
private Set<Integer> enabledPipelines;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class PaperPatch extends ViaListener {
|
||||
/*
|
||||
This patch is applied when Paper is detected.
|
||||
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.
|
||||
*/
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class UpdateUtil {
|
||||
public final static String PREFIX = ChatColor.GREEN + "" + ChatColor.BOLD + "[ViaVersion] " + ChatColor.GREEN;
|
||||
private final static String URL = "http://api.spiget.org/v2/resources/";
|
||||
private final static int PLUGIN = 19254;
|
||||
private final static String LATEST_VERSION = "/versions/latest";
|
||||
private final static String LATEST_VERSION = "/versions/latest";
|
||||
|
||||
public static void sendUpdateMessage(final UUID uuid, final Plugin plugin) {
|
||||
new BukkitRunnable() {
|
||||
@ -82,13 +82,17 @@ public class UpdateUtil {
|
||||
try {
|
||||
current = new Version(ViaVersion.getInstance().getVersion());
|
||||
} 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);
|
||||
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) {
|
||||
return "You are running a newer version than is released!";
|
||||
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 null;
|
||||
}
|
||||
|
@ -2,21 +2,26 @@ package us.myles.ViaVersion.update;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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) {
|
||||
if (value == 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");
|
||||
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("\\.");
|
||||
parts = new int[split.length];
|
||||
|
||||
for (int i = 0; i < split.length; i += 1)
|
||||
parts[i] = Integer.parseInt(split[i]);
|
||||
tag = matcher.group("tag") == null ? "" : matcher.group("tag");
|
||||
}
|
||||
|
||||
public static int compare(Version verA, Version verB) {
|
||||
@ -33,6 +38,12 @@ public class Version implements Comparable<Version> {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -47,7 +58,7 @@ public class Version implements Comparable<Version> {
|
||||
for (int i = 0; i < parts.length; i += 1)
|
||||
split[i] = String.valueOf(parts[i]);
|
||||
|
||||
return StringUtils.join(split, ".");
|
||||
return StringUtils.join(split, ".") + (tag.length() != 0 ? "-" + tag : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,4 +70,8 @@ public class Version implements Comparable<Version> {
|
||||
public boolean equals(Object that) {
|
||||
return that instanceof Version && equals(this, (Version) that);
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren