Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,5 @@ gradle-app.setting
# End of https://www.toptal.com/developers/gitignore/api/git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode,gradle
.paper-nms
*.iml
run/
.idea/runConfigurations/
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

allprojects {
group = "org.geysermc.geyser.adapters"
version = "1.16-SNAPSHOT"
version = "1.17-SNAPSHOT"
description = "Adapters for Geyser"
}
7 changes: 6 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ plugins {
}

dependencies {
implementation("io.papermc.paperweight:paperweight-userdev:1.7.7")
implementation("io.papermc.paperweight:paperweight-userdev:2.0.0-beta.18")
implementation("com.github.johnrengelman", "shadow", "8.1.1")
implementation("architectury-plugin:architectury-plugin.gradle.plugin:3.4-SNAPSHOT")
implementation("dev.architectury:architectury-loom:1.10-SNAPSHOT")
}

repositories {
gradlePluginPortal()
maven("https://maven.fabricmc.net/")
maven("https://maven.architectury.dev/")
maven("https://maven.neoforged.net/releases/")
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/adapters.base-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ tasks {

dependencies {
compileOnly("com.nukkitx.fastutil:fastutil-int-object-maps:8.3.1")
compileOnly("org.incendo:cloud-core:2.0.0-rc.2")
compileOnly("net.kyori:adventure-api:4.24.0")
compileOnly("net.kyori:adventure-text-serializer-gson:4.24.0")
}

repositories {
Expand Down
66 changes: 66 additions & 0 deletions buildSrc/src/main/kotlin/adapters.modded-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.task.RemapJarTask

/*
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

plugins {
id("adapters.publish-conventions")
id("architectury-plugin")
id("dev.architectury.loom")
}

project.configurations {
create("shadowCommon") {
isCanBeResolved = true
isCanBeConsumed = true
isCanBeDeclared = true
isTransitive = false
}
}

loom {
silentMojangMappingsLicense()
}

tasks.compileJava {
options.encoding = "UTF-8"
}

val shadowJar = tasks.named<ShadowJar>("shadowJar") {
configurations = listOf(project.configurations.getByName("shadowCommon"))
archiveClassifier = "dev-shadow"
}

tasks.named<RemapJarTask>("remapJar") {
injectAccessWidener = true
dependsOn(shadowJar)
inputFile.set(shadowJar.get().archiveFile)
}

repositories {
maven("https://maven.fabricmc.net/")
maven("https://maven.neoforged.net/releases/")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ publishing {
/**
* Subprojects are prefixed with the name of the parent project. e.g. "spigot-all"
* Projects at the root level use the originalId. e.g. "common"
*
* e.g. for modded platforms "modded-v1_20_6-fabric"
*/
fun Project.determineArtifactId(originalId: String): String {
if (project.parent != null && project.parent != rootProject) {
if (project.parent!!.parent != null && project.parent!!.parent != rootProject) {
return "${project.parent!!.parent!!.name}-${project.parent!!.name}-${project.name}"
}
return "${project.parent!!.name}-${project.name}"
}
return originalId
Expand Down
93 changes: 93 additions & 0 deletions buildSrc/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

import gradle.kotlin.dsl.accessors._3f80d1312ff9f42b2eab22e9378c2e48.*
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.expand
import org.gradle.kotlin.dsl.withType
import org.gradle.language.jvm.tasks.ProcessResources

/*
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

fun Project.minecraftVersion(version: String, type: String): Map<String, String> {
return this.minecraftVersion(version, type, HashMap())
}

fun Project.minecraftVersion(version: String, type: String, bonusData: Map<String, String>): Map<String, String> {
val metaProperties = HashMap<String, String>()
metaProperties["id"] = "geyser_modded_${type}_adapters_v${version.replace('.', '_')}"
metaProperties["minecraft_version"] = version

val fabricLoaderVersion = "0.17.2"

dependencies {
minecraft("com.mojang:minecraft:$version")
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
}

architectury {
minecraft = version
platformSetupLoomIde()
}

metaProperties.putAll(bonusData)
metaProperties.putAll(
mapOf(
"name" to "Geyser Mod Adapter (${type})",
"description" to "An adapter to access version-specific data in modded versions of Minecraft.",
"author" to "GeyserMC",
"website" to "https://geysermc.org",
"license" to "MIT",
"version" to this.version.toString()
)
)

return metaProperties
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.adapters;

import org.geysermc.geyser.adapters.command.CommandSenderDefinition;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.SenderMapper;

import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

public abstract class CommandManagerAdapter<S, P> {
public abstract <T> CommandManager<T> getCommandManager(
Function<CommandSenderDefinition, T> converter,
CommandSourceConverter<T, S, P> sourceConverter,
Consumer<String> logger
);

public abstract CommandSenderDefinition getCommandSenderDefinition(P handle, Consumer<String> logger);

public interface CommandSourceConverter<T, S, P> {
SenderMapper<S, T> getSenderMapper(
Class<S> senderClass,
Function<UUID, P> playerLookup,
Function<P, S> senderLookup,
Supplier<S> consoleLookup,
Function<S, T> commandSourceLookup
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.adapters;

public final class PlatformAdapters {
private PlatformAdapters() {} // never to be

private static CommandManagerAdapter<?, ?> COMMAND_MANAGER_ADAPTER;

public static CommandManagerAdapter<?, ?> getCommandManagerAdapter() {
return COMMAND_MANAGER_ADAPTER;
}

public static void setCommandManagerAdapter(CommandManagerAdapter<?, ?> commandManagerAdapter) {
if (COMMAND_MANAGER_ADAPTER != null) throw new IllegalStateException("CommandManagerAdapter has already been registered.");
COMMAND_MANAGER_ADAPTER = commandManagerAdapter;
}

private static WorldAdapter<?> WORLD_ADAPTER;

public static WorldAdapter<?> getWorldAdapter() {
return WORLD_ADAPTER;
}

public static void setWorldAdapter(WorldAdapter<?> worldAdapter) {
if (COMMAND_MANAGER_ADAPTER != null) throw new IllegalStateException("WorldAdapter has already been registered.");
WORLD_ADAPTER = worldAdapter;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.adapters.command;

import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;

import java.util.UUID;
import java.util.function.Consumer;

public interface CommandSenderDefinition {
String name();

void sendMessage(String message);

void sendMessage(Component message, Consumer<Component> superDefinition);

boolean isConsole();

@Nullable UUID playerUuid();

Object handle();
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.parallel=true
org.gradle.parallel=true
# Decompiling 15 versions of Minecraft, not a good idea.
org.gradle.workers.max=4
org.gradle.jvmargs=-Xmx2048m
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading