mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
move to paper-adapters
This commit is contained in:
parent
28d5db622b
commit
dd745b901f
5 changed files with 41 additions and 13 deletions
|
@ -7,6 +7,9 @@ dependencies {
|
||||||
implementation(variantOf(libs.adapters.spigot) {
|
implementation(variantOf(libs.adapters.spigot) {
|
||||||
classifier("all") // otherwise the unshaded jar is used without the shaded NMS implementations
|
classifier("all") // otherwise the unshaded jar is used without the shaded NMS implementations
|
||||||
})
|
})
|
||||||
|
implementation(variantOf(libs.adapters.paper) {
|
||||||
|
classifier("all") // otherwise the unshaded jar is used without the shaded NMS implementations
|
||||||
|
})
|
||||||
|
|
||||||
implementation(libs.commodore)
|
implementation(libs.commodore)
|
||||||
|
|
||||||
|
@ -34,6 +37,12 @@ application {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
||||||
|
|
||||||
|
// Prevents Paper 1.20.5+ from remapping Geyser
|
||||||
|
manifest {
|
||||||
|
attributes["paperweight-mappings-namespace"] = "mojang"
|
||||||
|
}
|
||||||
|
|
||||||
archiveBaseName.set("Geyser-Spigot")
|
archiveBaseName.set("Geyser-Spigot")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.geysermc.geyser.Constants;
|
import org.geysermc.geyser.Constants;
|
||||||
import org.geysermc.geyser.GeyserBootstrap;
|
import org.geysermc.geyser.GeyserBootstrap;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
|
import org.geysermc.geyser.adapters.paper.PaperAdapters;
|
||||||
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
|
@ -244,16 +245,27 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||||
|
|
||||||
if (Boolean.parseBoolean(System.getProperty("Geyser.UseDirectAdapters", "true"))) {
|
if (Boolean.parseBoolean(System.getProperty("Geyser.UseDirectAdapters", "true"))) {
|
||||||
try {
|
try {
|
||||||
String version = Bukkit.getBukkitVersion().split("-")[0];
|
boolean isPaper = false;
|
||||||
String nmsVersion = "v" + version.replace(".", "_");
|
try {
|
||||||
SpigotAdapters.registerWorldAdapter(nmsVersion);
|
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
String nmsVersion = name.substring(name.lastIndexOf('.') + 1);
|
||||||
|
SpigotAdapters.registerWorldAdapter(nmsVersion);
|
||||||
|
geyserLogger.debug("Using spigot NMS adapter for nms version: " + nmsVersion);
|
||||||
|
} catch (Exception e) { // Likely running on Paper 1.20.5+
|
||||||
|
//noinspection deprecation
|
||||||
|
int protocolVersion = Bukkit.getUnsafe().getProtocolVersion();
|
||||||
|
PaperAdapters.registerClosestWorldAdapter(protocolVersion);
|
||||||
|
isPaper = true;
|
||||||
|
geyserLogger.debug("Using paper world adapter for protocol version: " + protocolVersion);
|
||||||
|
}
|
||||||
|
|
||||||
if (isViaVersion && isViaVersionNeeded()) {
|
if (isViaVersion && isViaVersionNeeded()) {
|
||||||
this.geyserWorldManager = new GeyserSpigotLegacyNativeWorldManager(this);
|
this.geyserWorldManager = new GeyserSpigotLegacyNativeWorldManager(this, isPaper);
|
||||||
} else {
|
} else {
|
||||||
// No ViaVersion
|
// No ViaVersion
|
||||||
this.geyserWorldManager = new GeyserSpigotNativeWorldManager(this);
|
this.geyserWorldManager = new GeyserSpigotNativeWorldManager(this, isPaper);
|
||||||
}
|
}
|
||||||
geyserLogger.debug("Using NMS adapter: " + this.geyserWorldManager.getClass() + ", " + nmsVersion);
|
geyserLogger.debug("Using world manager of type: " + this.geyserWorldManager.getClass().getSimpleName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (geyserConfig.isDebugMode()) {
|
if (geyserConfig.isDebugMode()) {
|
||||||
geyserLogger.debug("Error while attempting to find NMS adapter. Most likely, this can be safely ignored. :)");
|
geyserLogger.debug("Error while attempting to find NMS adapter. Most likely, this can be safely ignored. :)");
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class GeyserSpigotLegacyNativeWorldManager extends GeyserSpigotNativeWorl
|
||||||
|
|
||||||
private final Int2IntMap oldToNewBlockId;
|
private final Int2IntMap oldToNewBlockId;
|
||||||
|
|
||||||
public GeyserSpigotLegacyNativeWorldManager(GeyserSpigotPlugin plugin) {
|
public GeyserSpigotLegacyNativeWorldManager(GeyserSpigotPlugin plugin, boolean isPaper) {
|
||||||
super(plugin);
|
super(plugin, isPaper);
|
||||||
IntList allBlockStates = adapter.getAllBlockStates();
|
IntList allBlockStates = adapter.getAllBlockStates();
|
||||||
oldToNewBlockId = new Int2IntOpenHashMap(allBlockStates.size());
|
oldToNewBlockId = new Int2IntOpenHashMap(allBlockStates.size());
|
||||||
ProtocolVersion serverVersion = plugin.getServerProtocolVersion();
|
ProtocolVersion serverVersion = plugin.getServerProtocolVersion();
|
||||||
|
|
|
@ -26,20 +26,26 @@
|
||||||
package org.geysermc.geyser.platform.spigot.world.manager;
|
package org.geysermc.geyser.platform.spigot.world.manager;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.geysermc.geyser.adapters.WorldAdapter;
|
||||||
|
import org.geysermc.geyser.adapters.paper.PaperAdapters;
|
||||||
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
||||||
import org.geysermc.geyser.adapters.spigot.SpigotWorldAdapter;
|
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
public class GeyserSpigotNativeWorldManager extends GeyserSpigotWorldManager {
|
public class GeyserSpigotNativeWorldManager extends GeyserSpigotWorldManager {
|
||||||
protected final SpigotWorldAdapter adapter;
|
protected final WorldAdapter<World> adapter;
|
||||||
|
|
||||||
public GeyserSpigotNativeWorldManager(Plugin plugin) {
|
public GeyserSpigotNativeWorldManager(Plugin plugin, boolean isPaper) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
adapter = SpigotAdapters.getWorldAdapter();
|
if (isPaper) {
|
||||||
|
adapter = PaperAdapters.getWorldAdapter();
|
||||||
|
} else {
|
||||||
|
adapter = SpigotAdapters.getWorldAdapter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,7 @@ jline = "3.21.0"
|
||||||
terminalconsoleappender = "1.2.0"
|
terminalconsoleappender = "1.2.0"
|
||||||
folia = "1.19.4-R0.1-SNAPSHOT"
|
folia = "1.19.4-R0.1-SNAPSHOT"
|
||||||
viaversion = "4.9.2"
|
viaversion = "4.9.2"
|
||||||
adapters = "1.11-SNAPSHOT"
|
adapters = "1.12-SNAPSHOT"
|
||||||
commodore = "2.2"
|
commodore = "2.2"
|
||||||
bungeecord = "a7c6ede"
|
bungeecord = "a7c6ede"
|
||||||
velocity = "3.1.1"
|
velocity = "3.1.1"
|
||||||
|
@ -100,6 +100,7 @@ fabric-permissions = { group = "me.lucko", name = "fabric-permissions-api", vers
|
||||||
neoforge-minecraft = { group = "net.neoforged", name = "neoforge", version.ref = "neoforge-minecraft" }
|
neoforge-minecraft = { group = "net.neoforged", name = "neoforge", version.ref = "neoforge-minecraft" }
|
||||||
|
|
||||||
adapters-spigot = { group = "org.geysermc.geyser.adapters", name = "spigot-all", version.ref = "adapters" }
|
adapters-spigot = { group = "org.geysermc.geyser.adapters", name = "spigot-all", version.ref = "adapters" }
|
||||||
|
adapters-paper = { group = "org.geysermc.geyser.adapters", name = "paper-all", version.ref = "adapters" }
|
||||||
bungeecord-proxy = { group = "com.github.SpigotMC.BungeeCord", name = "bungeecord-proxy", version.ref = "bungeecord" }
|
bungeecord-proxy = { group = "com.github.SpigotMC.BungeeCord", name = "bungeecord-proxy", version.ref = "bungeecord" }
|
||||||
checker-qual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerframework" }
|
checker-qual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerframework" }
|
||||||
commodore = { group = "me.lucko", name = "commodore", version.ref = "commodore" }
|
commodore = { group = "me.lucko", name = "commodore", version.ref = "commodore" }
|
||||||
|
|
Loading…
Reference in a new issue