feat: add Fabric 1.20.1/6 support

dependabot/gradle/org.projectlombok-lombok-1.18.34
William 5 months ago
parent e5c8975339
commit e1e39927f3
No known key found for this signature in database

@ -18,10 +18,10 @@ jobs:
steps: steps:
- name: 'Checkout for CI 🛎️' - name: 'Checkout for CI 🛎️'
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: 'Set up JDK 17 📦' - name: 'Set up JDK 21 📦'
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:
java-version: '17' java-version: '21'
distribution: 'temurin' distribution: 'temurin'
- name: 'Build with Gradle 🏗️' - name: 'Build with Gradle 🏗️'
uses: gradle/gradle-build-action@v3 uses: gradle/gradle-build-action@v3

@ -15,10 +15,10 @@ jobs:
steps: steps:
- name: 'Checkout for CI 🛎️' - name: 'Checkout for CI 🛎️'
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: 'Set up JDK 17 📦' - name: 'Set up JDK 21 📦'
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:
java-version: '17' java-version: '21'
distribution: 'temurin' distribution: 'temurin'
- name: 'Build with Gradle 🏗️' - name: 'Build with Gradle 🏗️'
uses: gradle/gradle-build-action@v3 uses: gradle/gradle-build-action@v3

@ -17,16 +17,17 @@
Uniform _currently_ targets the following platforms, (in addition to `uniform-common` which you can compile against in multi-platform plugins): Uniform _currently_ targets the following platforms, (in addition to `uniform-common` which you can compile against in multi-platform plugins):
| Platform | Artifact | Version | Java | | Platform | Artifact | Minecraft | Java |
|----------------|--------------------|------------|:-----:| |---------------|-------------------------|:----------:|:-----:|
| Paper | `uniform-paper` | \>`1.20.4` | >`17` | | Paper | `uniform-paper` | \>`1.20.4` | >`17` |
| Velocity | `uniform-velocity` | \>`3.3.0` | >`17` | | Velocity | `uniform-velocity` | \>`3.3.0` | >`17` |
| Fabric 1.20.1 | `uniform-fabric-1.20.1` | =`1.20.1` | >`17` |
| Fabric 1.20.6 | `uniform-fabric-1.20.6` | =`1.20.6` | >`21` |
Uniform _plans_ to support the following platforms: Uniform _plans_ to support the following platforms:
| Platform | Version | Java | | Platform | Version | Java |
|----------------|------------|:-----:| |----------------|------------|:-----:|
| Fabric | =`1.20.6` | >`21` |
| Spigot† | \>`1.17.1` | >`17` | | Spigot† | \>`1.17.1` | >`17` |
† Brigadier commands are wrapped into non-brigadier Bukkit plugin commands for legacy Spigot support. † Brigadier commands are wrapped into non-brigadier Bukkit plugin commands for legacy Spigot support.

@ -59,6 +59,7 @@ allprojects {
mavenCentral() mavenCentral()
maven { url 'https://repo.papermc.io/repository/maven-public/' } maven { url 'https://repo.papermc.io/repository/maven-public/' }
maven { url 'https://libraries.minecraft.net/' } maven { url 'https://libraries.minecraft.net/' }
maven { url 'https://maven.fabricmc.net/' }
} }
dependencies { dependencies {

@ -39,4 +39,5 @@ public record ArgumentElement<S, T>(@NotNull String name, @NotNull ArgumentType<
if (this.suggestionProvider != null) builder.suggests(this.suggestionProvider); if (this.suggestionProvider != null) builder.suggests(this.suggestionProvider);
return builder; return builder;
} }
} }

@ -32,4 +32,5 @@ public record LiteralElement<S>(@NotNull String name) implements CommandElement<
public ArgumentBuilder<S, ?> toBuilder() { public ArgumentBuilder<S, ?> toBuilder() {
return LiteralArgumentBuilder.literal(this.name); return LiteralArgumentBuilder.literal(this.name);
} }
} }

@ -0,0 +1,19 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'java-library'
id 'maven-publish'
}
dependencies {
api project(path: ':common')
minecraft 'com.mojang:minecraft:1.20.1'
mappings 'net.fabricmc:yarn:1.20.1+build.10:v2'
modCompileOnly 'net.fabricmc:fabric-loader:0.15.11'
modCompileOnly 'net.fabricmc.fabric-api:fabric-api:0.92.2+1.20.1'
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
}

@ -0,0 +1,70 @@
/*
* This file is part of Uniform, licensed under the GNU General Public License v3.0.
*
* Copyright (c) Tofaa2
* Copyright (c) William278 <will27528@gmail.com>
* Copyright (c) contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.william278.uniform.fabric;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.william278.uniform.Command;
import net.william278.uniform.element.ArgumentElement;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("unused")
public class FabricCommand extends Command<ServerCommandSource> {
public FabricCommand(@NotNull String name, @NotNull String... aliases) {
super(name, aliases);
}
protected static ArgumentElement<ServerCommandSource, Item> itemArg(String name) {
return registryArg(name, Registries.ITEM);
}
protected static ArgumentElement<ServerCommandSource, Block> blockArg(String name) {
return registryArg(name, Registries.BLOCK);
}
protected static <T> ArgumentElement<ServerCommandSource, T> registryArg(String name, Registry<T> registry) {
return new ArgumentElement<>(name, reader -> {
String itemId = reader.readString();
final Identifier id;
try {
id = Identifier.tryParse(itemId);
} catch (InvalidIdentifierException e) {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(reader);
}
if (registry.getOrEmpty(id).isEmpty()) {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(reader);
}
return registry.get(id);
}, (context, builder) -> {
registry.getIds().forEach(id -> builder.suggest(id.toString()));
return builder.buildFuture();
});
}
}

@ -0,0 +1,70 @@
/*
* This file is part of Uniform, licensed under the GNU General Public License v3.0.
*
* Copyright (c) Tofaa2
* Copyright (c) William278 <will27528@gmail.com>
* Copyright (c) contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.william278.uniform.fabric;
import com.google.common.collect.Sets;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* A class for registering commands with the Fabric (1.20.1) server
*
* @since 1.0
*/
public final class FabricUniform {
private static FabricUniform INSTANCE;
private final Set<FabricCommand> commands = Sets.newHashSet();
private FabricUniform() {
CommandRegistrationCallback.EVENT.register((dispatcher, registry, environment) ->
commands.forEach(command -> dispatcher.register(command.build().createBuilder()))
);
}
/**
* Get the FabricUniform instance for registering commands
*
* @return The FabricUniform instance
* @since 1.0
*/
@NotNull
public static FabricUniform getInstance() {
return INSTANCE != null ? INSTANCE : (INSTANCE = new FabricUniform());
}
/**
* Register a command to be added to the server's command manager
*
* @param commands The commands to register
* @since 1.0
*/
public void register(@NotNull FabricCommand... commands) {
Collections.addAll(this.commands, commands);
}
}

@ -0,0 +1,19 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'java-library'
id 'maven-publish'
}
dependencies {
api project(path: ':common')
minecraft 'com.mojang:minecraft:1.20.6'
mappings 'net.fabricmc:yarn:1.20.6+build.3:v2'
modCompileOnly 'net.fabricmc:fabric-loader:0.15.11'
modCompileOnly 'net.fabricmc.fabric-api:fabric-api:0.100.0+1.20.6'
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
}

@ -0,0 +1,70 @@
/*
* This file is part of Uniform, licensed under the GNU General Public License v3.0.
*
* Copyright (c) Tofaa2
* Copyright (c) William278 <will27528@gmail.com>
* Copyright (c) contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.william278.uniform.fabric;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.william278.uniform.Command;
import net.william278.uniform.element.ArgumentElement;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("unused")
public class FabricCommand extends Command<ServerCommandSource> {
public FabricCommand(@NotNull String name, @NotNull String... aliases) {
super(name, aliases);
}
protected static ArgumentElement<ServerCommandSource, Item> itemArg(String name) {
return registryArg(name, Registries.ITEM);
}
protected static ArgumentElement<ServerCommandSource, Block> blockArg(String name) {
return registryArg(name, Registries.BLOCK);
}
protected static <T> ArgumentElement<ServerCommandSource, T> registryArg(String name, Registry<T> registry) {
return new ArgumentElement<>(name, reader -> {
String itemId = reader.readString();
final Identifier id;
try {
id = Identifier.tryParse(itemId);
} catch (InvalidIdentifierException e) {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(reader);
}
if (registry.getOrEmpty(id).isEmpty()) {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(reader);
}
return registry.get(id);
}, (context, builder) -> {
registry.getIds().forEach(id -> builder.suggest(id.toString()));
return builder.buildFuture();
});
}
}

@ -0,0 +1,70 @@
/*
* This file is part of Uniform, licensed under the GNU General Public License v3.0.
*
* Copyright (c) Tofaa2
* Copyright (c) William278 <will27528@gmail.com>
* Copyright (c) contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.william278.uniform.fabric;
import com.google.common.collect.Sets;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* A class for registering commands with the Fabric (1.20.6) server
*
* @since 1.0
*/
public final class FabricUniform {
private static FabricUniform INSTANCE;
private final Set<FabricCommand> commands = Sets.newHashSet();
private FabricUniform() {
CommandRegistrationCallback.EVENT.register((dispatcher, registry, environment) ->
commands.forEach(command -> dispatcher.register(command.build().createBuilder()))
);
}
/**
* Get the FabricUniform instance for registering commands
*
* @return The FabricUniform instance
* @since 1.0
*/
@NotNull
public static FabricUniform getInstance() {
return INSTANCE != null ? INSTANCE : (INSTANCE = new FabricUniform());
}
/**
* Register a command to be added to the server's command manager
*
* @param commands The commands to register
* @since 1.0
*/
public void register(@NotNull FabricCommand... commands) {
Collections.addAll(this.commands, commands);
}
}

@ -1,14 +1,24 @@
pluginManagement { pluginManagement {
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
maven { url 'https://maven.fabricmc.net/' }
} }
} }
rootProject.name = 'Uniform' rootProject.name = 'Uniform'
include( include(
'common', 'common',
// Server Plugins
'paper', 'paper',
// Proxy Plugins
'velocity', 'velocity',
// Fabric Server-Side Mods
'fabric-1.20.1',
'fabric-1.20.6',
// Example plugin
'example-plugin' 'example-plugin'
) )
Loading…
Cancel
Save