Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Sync with master
Dieser Commit ist enthalten in:
Commit
198a24371c
@ -33,10 +33,7 @@ import us.myles.ViaVersion.util.ReflectionUtil;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
@ -96,6 +93,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
|||||||
getLogger().warning("ViaVersion will not function on the current protocol.");
|
getLogger().warning("ViaVersion will not function on the current protocol.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ProtocolRegistry.refreshVersions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -363,6 +361,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
|||||||
return compatSpigotBuild;
|
return compatSpigotBuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<Integer> getSupportedVersions() {
|
||||||
|
return ProtocolRegistry.getSupportedVersions();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCheckForUpdates() {
|
public boolean isCheckForUpdates() {
|
||||||
return getConfig().getBoolean("checkforupdates", true);
|
return getConfig().getBoolean("checkforupdates", true);
|
||||||
}
|
}
|
||||||
@ -447,6 +450,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
|||||||
return getConfig().getBoolean("anti-xray-patch", true);
|
return getConfig().getBoolean("anti-xray-patch", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSendSupportedVersions() {
|
||||||
|
return getConfig().getBoolean("send-supported-versions", false);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAutoTeam() {
|
public boolean isAutoTeam() {
|
||||||
// Collision has to be enabled first
|
// Collision has to be enabled first
|
||||||
return isPreventCollision() && getConfig().getBoolean("auto-team", true);
|
return isPreventCollision() && getConfig().getBoolean("auto-team", true);
|
||||||
|
@ -7,6 +7,7 @@ import us.myles.ViaVersion.api.boss.BossColor;
|
|||||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||||
import us.myles.ViaVersion.api.command.ViaVersionCommand;
|
import us.myles.ViaVersion.api.command.ViaVersionCommand;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface ViaVersionAPI {
|
public interface ViaVersionAPI {
|
||||||
@ -109,4 +110,11 @@ public interface ViaVersionAPI {
|
|||||||
* @return True if it is
|
* @return True if it is
|
||||||
*/
|
*/
|
||||||
boolean isCompatSpigotBuild();
|
boolean isCompatSpigotBuild();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the supported protocol versions
|
||||||
|
*
|
||||||
|
* @return a list of protocol versions
|
||||||
|
*/
|
||||||
|
SortedSet<Integer> getSupportedVersions();
|
||||||
}
|
}
|
||||||
|
@ -149,4 +149,11 @@ public interface ViaVersionConfig {
|
|||||||
* @return A boolean
|
* @return A boolean
|
||||||
*/
|
*/
|
||||||
boolean isAntiXRay();
|
boolean isAntiXRay();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send supported versions in the status response packet
|
||||||
|
*
|
||||||
|
* @return If true, enabled
|
||||||
|
*/
|
||||||
|
boolean isSendSupportedVersions();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package us.myles.ViaVersion.api.protocol;
|
package us.myles.ViaVersion.api.protocol;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import us.myles.ViaVersion.api.Pair;
|
import us.myles.ViaVersion.api.Pair;
|
||||||
import us.myles.ViaVersion.protocols.base.BaseProtocol;
|
import us.myles.ViaVersion.protocols.base.BaseProtocol;
|
||||||
@ -11,14 +13,16 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_9_1.Protocol1_9TO1_9_1;
|
|||||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3.ProtocolSnapshotTo1_9_3;
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3.ProtocolSnapshotTo1_9_3;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ProtocolRegistry {
|
public class ProtocolRegistry {
|
||||||
|
public static final Protocol BASE_PROTOCOL = new BaseProtocol();
|
||||||
public static int SERVER_PROTOCOL = -1;
|
public static int SERVER_PROTOCOL = -1;
|
||||||
// Input Version -> Output Version & Protocol (Allows fast lookup)
|
// Input Version -> Output Version & Protocol (Allows fast lookup)
|
||||||
private static Map<Integer, Map<Integer, Protocol>> registryMap = new HashMap<>();
|
private static Map<Integer, Map<Integer, Protocol>> registryMap = new ConcurrentHashMap<>();
|
||||||
private static Map<Pair<Integer, Integer>, List<Pair<Integer, Protocol>>> pathCache = new HashMap<>();
|
private static Map<Pair<Integer, Integer>, List<Pair<Integer, Protocol>>> pathCache = new ConcurrentHashMap<>();
|
||||||
private static List<Protocol> registerList = new ArrayList<>();
|
private static List<Protocol> registerList = Lists.newCopyOnWriteArrayList();
|
||||||
public static final Protocol BASE_PROTOCOL = new BaseProtocol();
|
private static Set<Integer> supportedVersions = Sets.newConcurrentHashSet();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Base Protocol
|
// Base Protocol
|
||||||
@ -56,11 +60,29 @@ public class ProtocolRegistry {
|
|||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("ViaVersion").isEnabled()) {
|
if (Bukkit.getPluginManager().getPlugin("ViaVersion").isEnabled()) {
|
||||||
protocol.registerListeners();
|
protocol.registerListeners();
|
||||||
|
refreshVersions();
|
||||||
} else {
|
} else {
|
||||||
registerList.add(protocol);
|
registerList.add(protocol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void refreshVersions() {
|
||||||
|
supportedVersions.clear();
|
||||||
|
|
||||||
|
supportedVersions.add(ProtocolRegistry.SERVER_PROTOCOL);
|
||||||
|
for (ProtocolVersion versions : ProtocolVersion.getProtocols()) {
|
||||||
|
List<Pair<Integer, Protocol>> paths = getProtocolPath(versions.getId(), ProtocolRegistry.SERVER_PROTOCOL);
|
||||||
|
if (paths == null) continue;
|
||||||
|
supportedVersions.add(versions.getId());
|
||||||
|
for (Pair<Integer, Protocol> path : paths)
|
||||||
|
supportedVersions.add(path.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SortedSet<Integer> getSupportedVersions() {
|
||||||
|
return Collections.unmodifiableSortedSet(new TreeSet<>(supportedVersions));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin is useful to the server.
|
* Check if this plugin is useful to the server.
|
||||||
*
|
*
|
||||||
|
@ -42,6 +42,8 @@ public class BaseProtocol extends Protocol {
|
|||||||
try {
|
try {
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(originalStatus);
|
JSONObject json = (JSONObject) new JSONParser().parse(originalStatus);
|
||||||
JSONObject version = (JSONObject) json.get("version");
|
JSONObject version = (JSONObject) json.get("version");
|
||||||
|
if (ViaVersion.getConfig().isSendSupportedVersions())
|
||||||
|
version.put("supportedVersions", ViaVersion.getInstance().getSupportedVersions());
|
||||||
if (ProtocolRegistry.SERVER_PROTOCOL == -1) {
|
if (ProtocolRegistry.SERVER_PROTOCOL == -1) {
|
||||||
Long original = (Long) version.get("protocol");
|
Long original = (Long) version.get("protocol");
|
||||||
ProtocolRegistry.SERVER_PROTOCOL = original.intValue();
|
ProtocolRegistry.SERVER_PROTOCOL = original.intValue();
|
||||||
|
@ -54,3 +54,5 @@ tracking-max-warnings: 4
|
|||||||
tracking-max-kick-msg: "You are sending too many packets, :("
|
tracking-max-kick-msg: "You are sending too many packets, :("
|
||||||
# Patch the Anti xray to work on 1.9 (If your server is 1.8) This can cost more performance, so disable it if you don't use it.
|
# Patch the Anti xray to work on 1.9 (If your server is 1.8) This can cost more performance, so disable it if you don't use it.
|
||||||
anti-xray-patch: true
|
anti-xray-patch: true
|
||||||
|
# Send the supported versions with the Status response packet
|
||||||
|
send-supported-versions: false
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren