feat: full 1.19.3 support

ok this is SO weird. protocollib appears to have absolutly NO trouble modifing (via reflection) a IMMUTABLE list??
the code is so messy right now but i'll clean it up later, let's say it works for now.
this commit also breaks all the other versions due to the way i get the internals soooooo.....
This commit is contained in:
aro 2023-01-21 12:11:11 +01:00
parent be83496494
commit 4c2135ac32
7 changed files with 219 additions and 5 deletions

View file

@ -78,6 +78,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
<repository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
@ -160,6 +164,12 @@
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>17</maven.compiler.target>

View file

@ -36,6 +36,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
<repository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
@ -111,6 +115,12 @@
<artifactId>yamlconfig</artifactId>
<version>1.1.1</version>
</dependency>
<!-- ProtocolLib -->
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>

View file

@ -1,8 +1,11 @@
package net.artelnatif.nicko;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import de.studiocode.invui.gui.structure.Structure;
import de.studiocode.invui.item.builder.ItemBuilder;
import de.studiocode.invui.item.impl.SimpleItem;
import net.artelnatif.nicko.bungee.BungeeCordSupport;
import net.artelnatif.nicko.bungee.NickoBungee;
import net.artelnatif.nicko.command.NickoCommand;
import net.artelnatif.nicko.config.NickoConfiguration;
@ -17,7 +20,6 @@ import net.artelnatif.nicko.mojang.MojangAPI;
import net.artelnatif.nicko.placeholder.PlaceHolderHook;
import net.artelnatif.nicko.pluginchannel.PluginMessageHandler;
import net.artelnatif.nicko.storage.PlayerDataStore;
import net.artelnatif.nicko.bungee.BungeeCordSupport;
import org.bukkit.Material;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginDescriptionFile;
@ -36,6 +38,7 @@ public class NickoBukkit extends JavaPlugin {
private MojangAPI mojangAPI;
private PlayerDataStore dataStore;
private LocaleFileManager localeFileManager;
private ProtocolManager protocolManager;
public NickoBukkit() { this.unitTesting = false; }
@ -94,6 +97,7 @@ public class NickoBukkit extends JavaPlugin {
saveDefaultConfig();
config = new NickoConfiguration(this);
dataStore = new PlayerDataStore(this);
protocolManager = ProtocolLibrary.getProtocolManager();
getLogger().info("Loading internals...");
if (getInternals() == null) {
@ -163,6 +167,10 @@ public class NickoBukkit extends JavaPlugin {
return localeFileManager;
}
public ProtocolManager getProtocolManager() {
return protocolManager;
}
public boolean isUnitTesting() {
return unitTesting;
}

View file

@ -0,0 +1,10 @@
package net.artelnatif.nicko.impl;
import com.comphenix.protocol.ProtocolManager;
import net.artelnatif.nicko.NickoBukkit;
public interface InternalsProtocolLib extends Internals {
default ProtocolManager getProtocolLib() {
return NickoBukkit.getInstance().getProtocolManager();
}
}

View file

@ -6,12 +6,17 @@ import java.lang.reflect.InvocationTargetException;
public class InternalsProvider {
private static Internals internals;
private static boolean protocolLib = true;
static {
try {
final String packageName = Internals.class.getPackage().getName();
final String bukkitVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
final String fullClassName = packageName + "." + bukkitVersion;
String fullClassName = packageName + "." + bukkitVersion;
if (protocolLib) {
System.out.println("USING PROTOCOLLIB HACK");
fullClassName += "_P";
}
internals = (Internals) Class.forName(fullClassName).getConstructors()[0].newInstance();
} catch (InvocationTargetException | ClassNotFoundException | InstantiationException | IllegalAccessException |
ClassCastException exception) {