Update Fabric to MC 1.20.5 (#3824)

This commit is contained in:
Drex 2024-04-23 22:57:20 +02:00 committed by GitHub
parent a43f4a11b0
commit 7cb60f59fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 46 additions and 19 deletions

View File

@ -29,7 +29,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

View File

@ -24,7 +24,7 @@ For more information, see the wiki article on [Why LuckPerms?](https://luckperms
LuckPerms uses Gradle to handle dependencies & building.
#### Requirements
* Java 17 JDK or newer
* Java 21 JDK or newer
* Git
#### Compiling from source

View File

@ -15,8 +15,8 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.1'
testImplementation 'org.mockito:mockito-core:4.11.0'
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
testImplementation 'org.mockito:mockito-core:5.11.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.11.0'
testImplementation 'com.h2database:h2:2.1.214'
api project(':api')

View File

@ -13,9 +13,9 @@ repositories {
dependencies {
// https://modmuss50.me/fabric.html
minecraft 'com.mojang:minecraft:1.20.4'
mappings 'net.fabricmc:yarn:1.20.4+build.1:v2'
modImplementation 'net.fabricmc:fabric-loader:0.15.1'
minecraft 'com.mojang:minecraft:1.20.5'
mappings 'net.fabricmc:yarn:1.20.5+build.1:v2'
modImplementation 'net.fabricmc:fabric-loader:0.15.10'
Set<String> apiModules = [
'fabric-api-base',
@ -25,7 +25,7 @@ dependencies {
]
apiModules.forEach {
modImplementation(fabricApi.module(it, '0.91.2+1.20.4'))
modImplementation(fabricApi.module(it, '0.97.6+1.20.5'))
}
include(modImplementation('me.lucko:fabric-permissions-api:0.3.1'))

View File

@ -33,6 +33,7 @@ import me.lucko.luckperms.fabric.mixin.ServerCommandSourceAccessor;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.luckperms.api.util.Tristate;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.server.command.CommandOutput;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
@ -117,6 +118,6 @@ public class FabricSenderFactory extends SenderFactory<LPFabricPlugin, ServerCom
}
public static Text toNativeText(Component component) {
return Text.Serialization.fromJsonTree(GsonComponentSerializer.gson().serializeToTree(component));
return Text.Serialization.fromJsonTree(GsonComponentSerializer.gson().serializeToTree(component), DynamicRegistryManager.EMPTY);
}
}

View File

@ -31,9 +31,13 @@ import me.lucko.luckperms.common.plugin.scheduler.SchedulerTask;
import me.lucko.luckperms.fabric.LPFabricPlugin;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.luckperms.api.messenger.IncomingMessageConsumer;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
@ -43,7 +47,7 @@ import java.util.Collection;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public class PluginMessageMessenger extends AbstractPluginMessageMessenger implements ServerPlayNetworking.PlayChannelHandler {
public class PluginMessageMessenger extends AbstractPluginMessageMessenger implements ServerPlayNetworking.PlayPayloadHandler<PluginMessageMessenger.PluginMessagePayload> {
private static final Identifier CHANNEL = new Identifier(AbstractPluginMessageMessenger.CHANNEL);
private final LPFabricPlugin plugin;
@ -54,7 +58,9 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
}
public void init() {
ServerPlayNetworking.registerGlobalReceiver(CHANNEL, this);
PayloadTypeRegistry.playS2C().register(PluginMessagePayload.ID, PluginMessagePayload.CODEC);
PayloadTypeRegistry.playC2S().register(PluginMessagePayload.ID, PluginMessagePayload.CODEC);
ServerPlayNetworking.registerGlobalReceiver(PluginMessagePayload.ID, this);
}
@Override
@ -77,9 +83,7 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
return;
}
PacketByteBuf packetBuf = PacketByteBufs.create();
packetBuf.writeBytes(buf);
ServerPlayNetworking.send(p, CHANNEL, packetBuf);
ServerPlayNetworking.send(p, new PluginMessagePayload(buf));
SchedulerTask t = taskRef.getAndSet(null);
if (t != null) {
@ -90,10 +94,32 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
}
@Override
public void receive(MinecraftServer server, ServerPlayerEntity entity, ServerPlayNetworkHandler netHandler, PacketByteBuf packetBuf, PacketSender packetSender) {
byte[] buf = new byte[packetBuf.readableBytes()];
packetBuf.readBytes(buf);
public void receive(PluginMessagePayload payload, ServerPlayNetworking.Context context) {
handleIncomingMessage(payload.data);
}
handleIncomingMessage(buf);
public static class PluginMessagePayload implements CustomPayload {
public static final CustomPayload.Id<PluginMessagePayload> ID = new CustomPayload.Id<>(CHANNEL);
public static final PacketCodec<RegistryByteBuf, PluginMessagePayload> CODEC = PacketCodec.of(PluginMessagePayload::write, PluginMessagePayload::new).cast();
private final byte[] data;
private PluginMessagePayload(byte[] data) {
this.data = data;
}
private PluginMessagePayload(PacketByteBuf buf) {
this.data = new byte[buf.readableBytes()];
buf.readBytes(this.data);
}
private void write(PacketByteBuf buf) {
buf.writeBytes(this.data);
}
@Override
public Id<PluginMessagePayload> getId() {
return ID;
}
}
}

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME