mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-02-17 12:01:26 +01:00
Moved the compatibility API to its own module.
This commit is contained in:
parent
07eb0d5710
commit
a818050daf
26
Core/pom.xml
26
Core/pom.xml
@ -119,14 +119,16 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14.4</version>
|
||||
</dependency-->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Need to include all NMS modules here -->
|
||||
<!-- Note when adding a new module: include the class in NmsManager -->
|
||||
<dependency>
|
||||
@ -279,18 +281,6 @@
|
||||
<version>1.7.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.myles.viaversion-bukkit</groupId>
|
||||
<artifactId>ViaVersion</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>protocolsupport</groupId>
|
||||
<artifactId>ProtocolSupport</artifactId>
|
||||
<version>4.29</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
|
34
compatibility/pom.xml
Normal file
34
compatibility/pom.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.4.54</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.myles.viaversion-bukkit</groupId>
|
||||
<artifactId>ViaVersion</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>protocolsupport</groupId>
|
||||
<artifactId>ProtocolSupport</artifactId>
|
||||
<version>4.29</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.core.compatibility;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
@ -34,8 +34,8 @@ public class ClientVersion {
|
||||
* Do Not Use: This is handled by SongodaCore.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onLoginProtocol(Player p) {
|
||||
Bukkit.getScheduler().runTaskLater(SongodaCore.getHijackedPlugin(), () -> {
|
||||
public static void onLoginProtocol(Player p, JavaPlugin plugin) {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if (p.isOnline()) {
|
||||
final int version = protocolsupport.api.ProtocolSupportAPI.getProtocolVersion(p).getId();
|
||||
players.put(p.getUniqueId(), protocolToVersion(version));
|
||||
@ -47,8 +47,8 @@ public class ClientVersion {
|
||||
* Do Not Use: This is handled by SongodaCore.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onLoginVia(Player p) {
|
||||
Bukkit.getScheduler().runTaskLater(SongodaCore.getHijackedPlugin(), () -> {
|
||||
public static void onLoginVia(Player p, JavaPlugin plugin) {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if (p.isOnline()) {
|
||||
final int version = us.myles.ViaVersion.api.Via.getAPI().getPlayerVersion(p.getUniqueId());
|
||||
players.put(p.getUniqueId(), protocolToVersion(version));
|
||||
@ -94,6 +94,9 @@ public class ClientVersion {
|
||||
return ServerVersion.V1_15;
|
||||
case 735:
|
||||
case 736:
|
||||
case 751:
|
||||
case 753:
|
||||
case 754:
|
||||
return ServerVersion.V1_16;
|
||||
}
|
||||
return version > 498 ? ServerVersion.getServerVersion() : ServerVersion.UNKNOWN;
|
@ -1,6 +1,5 @@
|
||||
package com.songoda.core.compatibility;
|
||||
|
||||
import com.songoda.core.utils.NMSUtils;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -127,13 +126,14 @@ public enum CompatibleBiome {
|
||||
compatibleBiomes.add(biome);
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_15)) {
|
||||
Class<?> classBiomeBase = NMSUtils.getNMSClass("BiomeBase"),
|
||||
classCraftChunk = NMSUtils.getCraftClass("CraftChunk"),
|
||||
classCraftBlock = NMSUtils.getCraftClass("block.CraftBlock"),
|
||||
classChunk = NMSUtils.getNMSClass("Chunk"),
|
||||
classBiomeStorage = NMSUtils.getNMSClass("BiomeStorage"),
|
||||
classIRegistry = NMSUtils.getNMSClass("IRegistry");
|
||||
try {
|
||||
Class<?> classBiomeBase = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".BiomeBase"),
|
||||
classCraftChunk = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".CraftChunk"),
|
||||
classCraftBlock = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".block.CraftBlock"),
|
||||
classChunk = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".Chunk"),
|
||||
classBiomeStorage = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".BiomeStorage"),
|
||||
classIRegistry = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".IRegistry");
|
||||
|
||||
methodBiomeToBiomeBase = isAbove1_16_R1 ? classCraftBlock.getMethod("biomeToBiomeBase", classIRegistry, Biome.class)
|
||||
: classCraftBlock.getMethod("biomeToBiomeBase", Biome.class);
|
||||
methodGetHandle = classCraftChunk.getMethod("getHandle");
|
||||
@ -149,7 +149,7 @@ public enum CompatibleBiome {
|
||||
fieldStorageRegistry = classBiomeStorage.getDeclaredField("g");
|
||||
}
|
||||
fieldStorageRegistry.setAccessible(true);
|
||||
} catch (NoSuchMethodException | NoSuchFieldException e) {
|
||||
} catch (NoSuchMethodException | NoSuchFieldException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.songoda.core.compatibility;
|
||||
|
||||
import com.songoda.core.utils.NMSUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -115,10 +114,10 @@ public enum CompatibleHand {
|
||||
|
||||
if (cb_CraftPlayer == null) {
|
||||
try {
|
||||
cb_CraftPlayer = NMSUtils.getCraftClass("entity.CraftPlayer");
|
||||
Class<?> mc_EntityLiving = NMSUtils.getNMSClass("EntityLiving");
|
||||
Class<?> cb_ItemStack = NMSUtils.getCraftClass("inventory.CraftItemStack");
|
||||
Class<?> mc_ItemStack = NMSUtils.getNMSClass("ItemStack");
|
||||
cb_CraftPlayer = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".entity.CraftPlayer");
|
||||
Class<?> mc_EntityLiving = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".EntityLiving");
|
||||
Class<?> cb_ItemStack = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getServerVersionString() + ".inventory.CraftItemStack");
|
||||
Class<?> mc_ItemStack = Class.forName("net.minecraft.server." + ServerVersion.getServerVersionString() + ".ItemStack");
|
||||
getHandle = cb_CraftPlayer.getMethod("getHandle");
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
playBreak = mc_EntityLiving.getDeclaredMethod("a", mc_ItemStack, int.class); //Consistent from 1.16-1.13
|
||||
@ -126,7 +125,7 @@ public enum CompatibleHand {
|
||||
playBreak = mc_EntityLiving.getDeclaredMethod("b", mc_ItemStack); //Consistent from 1.12-1.8
|
||||
playBreak.setAccessible(true);
|
||||
asNMSCopy = cb_ItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user