Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Implement isSpigot() in the API and make it so xray does not activate if they do not use spigot.
Dieser Commit ist enthalten in:
Ursprung
bcc994b0dd
Commit
3ddc43bf7b
@ -47,11 +47,14 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
|||||||
private ViaCommandHandler commandHandler;
|
private ViaCommandHandler commandHandler;
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
private boolean compatSpigotBuild = false;
|
private boolean compatSpigotBuild = false;
|
||||||
|
private boolean spigot = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
ViaVersion.setInstance(this);
|
ViaVersion.setInstance(this);
|
||||||
|
// Config magic
|
||||||
generateConfig();
|
generateConfig();
|
||||||
|
// Handle reloads
|
||||||
if (System.getProperty("ViaVersion") != null) {
|
if (System.getProperty("ViaVersion") != null) {
|
||||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||||
getLogger().severe("ViaVersion is already loaded, we're going to kick all the players... because otherwise we'll crash because of ProtocolLib.");
|
getLogger().severe("ViaVersion is already loaded, we're going to kick all the players... because otherwise we'll crash because of ProtocolLib.");
|
||||||
@ -64,6 +67,12 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Spigot detector
|
||||||
|
try {
|
||||||
|
Class.forName("org.spigotmc.SpigotConfig");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
spigot = false;
|
||||||
|
}
|
||||||
// Check if it's a spigot build with a protocol mod
|
// Check if it's a spigot build with a protocol mod
|
||||||
try {
|
try {
|
||||||
compatSpigotBuild = ReflectionUtil.nms("PacketEncoder").getDeclaredField("version") != null;
|
compatSpigotBuild = ReflectionUtil.nms("PacketEncoder").getDeclaredField("version") != null;
|
||||||
@ -105,6 +114,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
|||||||
|
|
||||||
// Register Protocol Listeners
|
// Register Protocol Listeners
|
||||||
ProtocolRegistry.registerListeners();
|
ProtocolRegistry.registerListeners();
|
||||||
|
|
||||||
|
// Warn them if they have anti-xray on and they aren't using spigot
|
||||||
|
if(isAntiXRay() && !spigot){
|
||||||
|
getLogger().info("You have anti-xray on in your config, since you're not using spigot it won't fix xray!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -366,6 +380,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
|||||||
return ProtocolRegistry.getSupportedVersions();
|
return ProtocolRegistry.getSupportedVersions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSpigot() {
|
||||||
|
return this.spigot;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCheckForUpdates() {
|
public boolean isCheckForUpdates() {
|
||||||
return getConfig().getBoolean("checkforupdates", true);
|
return getConfig().getBoolean("checkforupdates", true);
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,12 @@ public interface ViaVersionAPI {
|
|||||||
* @return a list of protocol versions
|
* @return a list of protocol versions
|
||||||
*/
|
*/
|
||||||
SortedSet<Integer> getSupportedVersions();
|
SortedSet<Integer> getSupportedVersions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if the server uses spigot
|
||||||
|
*
|
||||||
|
* Note: Will only work after ViaVersion load
|
||||||
|
* @return True if spigot
|
||||||
|
*/
|
||||||
|
boolean isSpigot();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,8 @@ public class ClientChunks extends StoredObject {
|
|||||||
int[] zcoords = mapChunkBulkRef.getFieldValue("b", packet, int[].class);
|
int[] zcoords = mapChunkBulkRef.getFieldValue("b", packet, int[].class);
|
||||||
Object[] chunkMaps = mapChunkBulkRef.getFieldValue("c", packet, Object[].class);
|
Object[] chunkMaps = mapChunkBulkRef.getFieldValue("c", packet, Object[].class);
|
||||||
|
|
||||||
if (ViaVersion.getConfig().isAntiXRay()) { //Spigot anti-xray patch
|
if (ViaVersion.getConfig().isAntiXRay() && ViaVersion.getInstance().isSpigot()) { //Spigot anti-xray patch
|
||||||
|
try {
|
||||||
Object world = mapChunkBulkRef.getFieldValue("world", packet, Object.class);
|
Object world = mapChunkBulkRef.getFieldValue("world", packet, Object.class);
|
||||||
|
|
||||||
for (int i = 0; i < xcoords.length; ++i) {
|
for (int i = 0; i < xcoords.length; ++i) {
|
||||||
@ -63,6 +64,9 @@ public class ClientChunks extends StoredObject {
|
|||||||
|
|
||||||
obfuscateRef.invoke(antiXrayInstance, xcoords[i], zcoords[i], b, a, world);
|
obfuscateRef.invoke(antiXrayInstance, xcoords[i], zcoords[i], b, a, world);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// not spigot, or it failed.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < chunkMaps.length; i++) {
|
for (int i = 0; i < chunkMaps.length; i++) {
|
||||||
int x = xcoords[i];
|
int x = xcoords[i];
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren