mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
Created 1.18 R1 (plugin's native version) nms package.
Created 1.18 R1 handling of sending player abilities packet and tested on spigot. Documented force_protocolib config.
This commit is contained in:
parent
6c5eab6fff
commit
0f2a295039
15 changed files with 201 additions and 67 deletions
|
|
@ -8,7 +8,9 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
// Spigot api
|
||||
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
||||
|
||||
// Protocolib
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,14 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.packet
|
||||
|
||||
// ProtocoLib not installed and not in a supported version: We do nothing
|
||||
class NoPacketManager: AbstractPacketManager()
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class NoPacketManager: PacketManager {
|
||||
|
||||
override val canSetInstantBuild: Boolean
|
||||
get() = false
|
||||
|
||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
||||
// ProtocoLib not installed and not in a supported version: We do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.packet
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
abstract class PacketManagerBase() : PacketManager, Listener {
|
||||
|
||||
abstract class AbstractPacketManager : PacketManager {
|
||||
override val canSetInstantBuild: Boolean
|
||||
get() = false
|
||||
|
||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
||||
// Default empty.
|
||||
// Default implementation is empty.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.packet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PacketManagerSelector {
|
||||
|
||||
private PacketManagerSelector(){}
|
||||
|
||||
public static @NotNull PacketManager selectPacketManager(boolean forceProtocolib){
|
||||
// Try to find version
|
||||
if(forceProtocolib){
|
||||
PacketManager protocolibPacketManager = getProtocolibIfPresent();
|
||||
if(protocolibPacketManager != null) return protocolibPacketManager;
|
||||
}
|
||||
|
||||
PacketManager versionSpecificManager = getVersionSpecificManager();
|
||||
if(versionSpecificManager != null) return versionSpecificManager;
|
||||
|
||||
if(!forceProtocolib){
|
||||
PacketManager protocolibPacketManager = getProtocolibIfPresent();
|
||||
if(protocolibPacketManager != null) return protocolibPacketManager;
|
||||
}
|
||||
return new NoPacketManager();
|
||||
}
|
||||
|
||||
private static @Nullable PacketManager getProtocolibIfPresent(){
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) return new ProtocoLibWrapper();
|
||||
return null;
|
||||
}
|
||||
|
||||
private static @Nullable PacketManager getVersionSpecificManager() {
|
||||
|
||||
|
||||
//TODO depending on version. find the manager !
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue