fabric: support Minecraft 1.20.6

This commit is contained in:
William committed 2024-05-29 23:50:03 +01:00
1 parent cca1951a7c
commit 9b323198ac
10 files changed
+109 -58

No files matched your search

+13 -1
View File
@@ -68,9 +68,21 @@ jobs:
folia
game-versions: |
1.17.1
1.18
1.18.1
1.18.2
1.19
1.19.1
1.19.2
1.19.3
1.19.4
1.20
1.20.1
1.20.2
1.20.3
1.20.4
1.20.5
1.20.6
java: 17
- name: 'Sponge: Publish to Modrinth 🧽'
uses: WiIIiam278/mc-publish@hangar
@@ -118,7 +130,7 @@ jobs:
loaders: |
fabric
game-versions: |
1.20.4
1.20.6
java: 17
- name: 'Upload GitHub Artifacts 📦'
uses: actions/upload-artifact@v4
+13 -1
View File
@@ -56,9 +56,21 @@ jobs:
folia
game-versions: |
1.17.1
1.18
1.18.1
1.18.2
1.19
1.19.1
1.19.2
1.19.3
1.19.4
1.20
1.20.1
1.20.2
1.20.3
1.20.4
1.20.5
1.20.6
java: 17
- name: 'Sponge: Publish to Modrinth 🧽'
uses: WiIIiam278/mc-publish@hangar
@@ -104,7 +116,7 @@ jobs:
loaders: |
fabric
game-versions: |
1.20.4
1.20.6
java: 17
- name: 'Upload GitHub Artifacts 📦'
uses: actions/upload-artifact@v4
+4
View File
@@ -133,6 +133,10 @@ subprojects {
archiveClassifier.set('')
}
if (['fabric'].contains(project.name)) {
compileJava.options.release.set 21
}
// API publishing
if (['common', 'bukkit', 'fabric', 'sponge'].contains(project.name)) {
java {
@@ -35,12 +35,10 @@ public class RtpCommand extends Command implements UserListTabProvider {
protected RtpCommand(@NotNull HuskHomes plugin) {
super("rtp", List.of(), "[player] [world]", plugin);
Map<String, Boolean> map = new HashMap<>();
map.put("other", true);
plugin.getWorlds().stream()
.filter(world -> !plugin.getSettings().getRtp().isWorldRtpRestricted(world))
.map(World::getName).toList().forEach(world -> map.put(world, true));
addAdditionalPermissions(map);
addAdditionalPermissions(Map.of(
"other", true
));
}
@Override
+1 -1
View File
@@ -25,7 +25,7 @@ dependencies {
'fabric-dimensions-v1',
]
fabricApiModules.forEach {
modImplementation(fabricApi.module(it, fabric_api_version))
modCompileOnly(fabricApi.module(it, fabric_api_version))
}
modImplementation include("net.kyori:adventure-platform-fabric:${adventure_platform_fabric_version}")
modImplementation include("me.lucko:fabric-permissions-api:${fabric_permissions_api_version}")
@@ -21,24 +21,18 @@ package net.william278.huskhomes;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import io.netty.buffer.ByteBufUtil;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import net.william278.desertwell.util.Version;
import net.william278.huskhomes.command.Command;
import net.william278.huskhomes.command.FabricCommand;
@@ -55,6 +49,7 @@ import net.william278.huskhomes.listener.EventListener;
import net.william278.huskhomes.listener.FabricEventListener;
import net.william278.huskhomes.manager.Manager;
import net.william278.huskhomes.network.Broker;
import net.william278.huskhomes.network.FabricPluginMessage;
import net.william278.huskhomes.network.PluginMessageBroker;
import net.william278.huskhomes.network.RedisBroker;
import net.william278.huskhomes.position.World;
@@ -88,7 +83,7 @@ import java.util.stream.Collectors;
@Setter
@NoArgsConstructor
public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes, FabricTask.Supplier,
FabricEventDispatcher, FabricSafetyResolver, ServerPlayNetworking.PlayChannelHandler {
FabricEventDispatcher, FabricSafetyResolver, ServerPlayNetworking.PlayPayloadHandler<FabricPluginMessage> {
public static final Logger LOGGER = LoggerFactory.getLogger("HuskHomes");
private final ModContainer modContainer = FabricLoader.getInstance().getModContainer("huskhomes")
@@ -326,20 +321,18 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
@Override
public void initializePluginChannels() {
ServerPlayNetworking.registerGlobalReceiver(new Identifier("bungeecord", "main"), this);
ServerPlayNetworking.registerGlobalReceiver(FabricPluginMessage.BUNGEE_CHANNEL_ID, this);
}
// When the server receives a plugin message
@Override
public void receive(@NotNull MinecraftServer server, @NotNull ServerPlayerEntity player,
@NotNull ServerPlayNetworkHandler handler, @NotNull PacketByteBuf buf,
@NotNull PacketSender responseSender) {
public void receive(@NotNull FabricPluginMessage payload, @NotNull ServerPlayNetworking.Context context) {
if (broker instanceof PluginMessageBroker messenger
&& getSettings().getCrossServer().getBrokerType() == Broker.Type.PLUGIN_MESSAGE) {
messenger.onReceive(
PluginMessageBroker.BUNGEE_CHANNEL_ID,
FabricUser.adapt(player, this),
ByteBufUtil.getBytes(buf)
FabricUser.adapt(context.player(), this),
payload.getData()
);
}
}
@@ -0,0 +1,46 @@
/*
* This file is part of HuskHomes, licensed under the Apache License 2.0.
*
* Copyright (c) William278 <[email protected]>
* Copyright (c) contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.william278.huskhomes.network;
import lombok.*;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor
public class FabricPluginMessage implements CustomPayload {
public static final Id<FabricPluginMessage> BUNGEE_CHANNEL_ID = new Id<>(
Identifier.of("bungeecord", "main")
);
private Id<FabricPluginMessage> id;
private byte[] data;
@NotNull
public static FabricPluginMessage of(@NotNull String id, byte[] data) {
return new FabricPluginMessage(
id.equals("BungeeCord") ? BUNGEE_CHANNEL_ID : new Id<>(Identifier.tryParse(id)), data
);
}
}
@@ -21,10 +21,8 @@ package net.william278.huskhomes.user;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.kyori.adventure.audience.Audience;
import net.minecraft.entity.Entity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
@@ -33,6 +31,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.TeleportTarget;
import net.william278.huskhomes.FabricHuskHomes;
import net.william278.huskhomes.network.FabricPluginMessage;
import net.william278.huskhomes.position.Location;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.position.World;
@@ -163,10 +162,7 @@ public class FabricUser extends OnlineUser {
@Override
public void sendPluginMessage(@NotNull String channel, byte[] message) {
final PacketByteBuf buf = PacketByteBufs.create();
buf.writeIdentifier(parseIdentifier(channel));
buf.writeBytes(message);
player.networkHandler.sendPacket(new CustomPayloadS2CPacket(buf));
player.networkHandler.sendPacket(new CustomPayloadS2CPacket(FabricPluginMessage.of(channel, message)));
}
@Override
@@ -193,14 +189,4 @@ public class FabricUser extends OnlineUser {
plugin.runSyncDelayed(() -> player.setInvulnerable(false), invulnerabilityTimeInTicks);
}
@NotNull
private static Identifier parseIdentifier(@NotNull String channel) {
if (channel.equals("BungeeCord")) {
return new Identifier("bungeecord", "main");
}
return Optional.ofNullable(Identifier.tryParse(channel))
.orElseThrow(() -> new IllegalArgumentException("Invalid channel name: " + channel));
}
}
+15 -15
View File
@@ -1,29 +1,29 @@
javaVersion=17
javaVersion=21
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true
# Plugin metadata
plugin_version=4.6.2
plugin_version=4.6.3
plugin_archive=huskhomes
plugin_description=The powerful & intuitive homes, warps, and teleportation suite
# General settings
jedis_version=5.1.2
mysql_driver_version=8.3.0
mariadb_driver_version=3.3.3
sqlite_driver_version=3.45.2.0
jedis_version=5.1.3
mysql_driver_version=8.4.0
mariadb_driver_version=3.4.0
sqlite_driver_version=3.46.0.0
h2_driver_version=2.2.220
postgresql_driver_version=42.7.3
commons_pool_version=2.12.0
# Fabric settings
fabric_loom_version=1.5-SNAPSHOT
fabric_minecraft_version=1.20.4
fabric_loader_version=0.15.9
fabric_yarn_mappings=1.20.4+build.3
fabric_api_version=0.96.11+1.20.4
fabric_permissions_api_version=0.2-SNAPSHOT
adventure_platform_fabric_version=5.12.0
fabric_impactor_api_version=5.2.0-SNAPSHOT
fabric_placeholder_api_version=2.3.0+1.20.3
fabric_loom_version=1.6-SNAPSHOT
fabric_minecraft_version=1.20.6
fabric_loader_version=0.15.11
fabric_yarn_mappings=1.20.6+build.3
fabric_api_version=0.99.0+1.20.6
fabric_permissions_api_version=0.3.1
adventure_platform_fabric_version=5.13.0
fabric_impactor_api_version=5.2.4
fabric_placeholder_api_version=2.4.0-pre.1+1.20.5
+5 -5
View File
@@ -47,15 +47,15 @@ shadowJar {
tasks {
runServer {
minecraftVersion('1.20.4')
minecraftVersion('1.20.6')
downloadPlugins {
url("https://download.luckperms.net/1526/bukkit/loader/LuckPerms-Bukkit-5.4.113.jar")
url("https://ci.lucko.me/job/spark/399/artifact/spark-bukkit/build/libs/spark-1.10.58-bukkit.jar")
hangar("Plan-Player-Analytics", "5.6+build.2614")
// url("https://download.luckperms.net/1526/bukkit/loader/LuckPerms-Bukkit-5.4.113.jar")
// url("https://ci.lucko.me/job/spark/399/artifact/spark-bukkit/build/libs/spark-1.10.58-bukkit.jar")
// hangar("Plan-Player-Analytics", "5.6+build.2614")
// modrinth("dynmap", "5F9fwzR1")
modrinth("pl3xmap", "1.20.4-489")
// modrinth("pl3xmap", "1.20.4-489")
// modrinth("bluemap", "3.20-paper")
}
}