Skip to content

Update to Minecraft 1.21.1 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.6.0'
id 'org.jetbrains.kotlin.jvm' version '2.0.20'
}

repositories{
Expand All @@ -13,9 +13,9 @@ repositories{
}
}

def kotlinVersion = "1.6.0"
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
def kotlinVersion = "2.0.20"
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -27,7 +27,7 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc:fabric-language-kotlin:1.7.0+kotlin.${kotlinVersion}"
modImplementation "net.fabricmc:fabric-language-kotlin:1.12.2+kotlin.${kotlinVersion}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
Expand All @@ -49,7 +49,7 @@ tasks.withType(JavaCompile) {
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
archiveClassifier = "sources"
from sourceSets.main.allSource
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19
yarn_mappings=1.19+build.4
loader_version=0.14.8
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.5
# Mod Properties
mod_version=1.0.6
mod_version=1.0.6+1.21.1
maven_group=com.github.quiltservertools
archives_base_name=wires
# Dependencies
# check this on https://fabricmc.net/versions.html
fabric_version=0.56.3+1.19
fabric_version=0.105.0+1.21.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.quiltservertools.wires.mixins;

import net.minecraft.server.network.ConnectedClientData;
import net.quiltservertools.wires.command.VanishCommand;
import com.mojang.authlib.GameProfile;
import net.minecraft.network.ClientConnection;
Expand All @@ -24,8 +25,8 @@ public void checkMaintenanceMode(SocketAddress address, GameProfile profile, Cal
cir.setReturnValue(Text.literal("Server is closed for maintenance"));
}
}
@Inject(method = "onPlayerConnect(Lnet/minecraft/network/ClientConnection;Lnet/minecraft/server/network/ServerPlayerEntity;)V", at = @At("RETURN"))
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity entity, CallbackInfo ci) {
VanishCommand.INSTANCE.getPlayers().forEach(player -> connection.send(new PlayerListS2CPacket(PlayerListS2CPacket.Action.REMOVE_PLAYER, player)));
@Inject(method = "onPlayerConnect", at = @At("RETURN"))
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity entity, ConnectedClientData clientData, CallbackInfo ci) {
VanishCommand.INSTANCE.getPlayers().forEach(player -> connection.send(new PlayerListS2CPacket(PlayerListS2CPacket.Action.UPDATE_LISTED, player)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.quiltservertools.wires.mixins;

import net.minecraft.network.DisconnectionInfo;
import net.quiltservertools.wires.StaffChat;
import net.quiltservertools.wires.command.MuteCommands;
import net.quiltservertools.wires.command.VanishCommand;
Expand Down Expand Up @@ -33,7 +34,7 @@ public abstract class MixinServerPlayNetworkHandler {
@Inject(method = "onChatMessage(Lnet/minecraft/network/packet/c2s/play/ChatMessageC2SPacket;)V", at = @At("HEAD"), cancellable = true)
public void interceptChatMessage(ChatMessageC2SPacket packet, CallbackInfo ci) {
Config config = Config.INSTANCE;
String message = packet.getChatMessage();
String message = packet.chatMessage();
if (config.isPlayerMuted(player.getUuid()) && Permissions.INSTANCE.hasPermission(player.getCommandSource(), MuteCommands.name)) {
player.sendMessage(muted);
player.sendMessage(Text.literal("Reason: " + (config.getMute(player).isPresent() ? config.getMute(player).get().getReason() : "<None provided>")));
Expand All @@ -48,7 +49,7 @@ public void interceptChatMessage(ChatMessageC2SPacket packet, CallbackInfo ci) {
}

@Inject(method = "onDisconnected", at = @At("HEAD"))
public void removeFromVanish(Text reason, CallbackInfo ci) {
public void removeFromVanish(DisconnectionInfo info, CallbackInfo ci) {
VanishCommand.INSTANCE.removePlayer(this.getPlayer());
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
package net.quiltservertools.wires.mixins;

import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerMetadata;
import net.minecraft.server.network.ServerQueryNetworkHandler;
import net.quiltservertools.wires.config.Config;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.Optional;

@Mixin(ServerQueryNetworkHandler.class)
public abstract class MixinServerQueryNetworkHandler {
@Redirect(method = "onRequest", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getServerMetadata()Lnet/minecraft/server/ServerMetadata;"))
private ServerMetadata showMaintenance(MinecraftServer server) {
var realData = server.getServerMetadata();

if(Config.INSTANCE.isMaintenanceMode()) {
var metadata = new ServerMetadata();
metadata.setVersion(new ServerMetadata.Version("Maintenance", -1));
metadata.setDescription(realData.getDescription());
metadata.setFavicon(realData.getFavicon());
metadata.setPlayers(realData.getPlayers());
@Shadow
@Final
private ServerMetadata metadata;

return metadata;
@Redirect(method = "onRequest", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerQueryNetworkHandler;metadata:Lnet/minecraft/server/ServerMetadata;"))
private ServerMetadata showMaintenance(ServerQueryNetworkHandler instance) {

if(Config.INSTANCE.isMaintenanceMode()) {
return new ServerMetadata(
metadata.description(),
metadata.players(),
Optional.of(new ServerMetadata.Version("Maintenance", -1)),
metadata.favicon(),
metadata.secureChatEnforced()
);
}

return realData;
return metadata;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import net.minecraft.text.Text
import net.minecraft.util.Formatting
import net.quiltservertools.wires.config.Config
import net.quiltservertools.wires.util.Permissions.hasPermission
import java.util.function.Supplier

object MaintenanceModeCommand {

Expand Down Expand Up @@ -50,7 +51,7 @@ object MaintenanceModeCommand {
}
}
scs.sendFeedback(
Text.literal("Maintenance mode ").append(Text.literal(if (state) "enabled" else "disabled").formatted(if (state) Formatting.RED else Formatting.GREEN)),
{ Text.literal("Maintenance mode ").append(Text.literal(if (state) "enabled" else "disabled").formatted(if (state) Formatting.RED else Formatting.GREEN)) },
true
)
return 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,29 @@ object MuteCommands {
}
Config.mute(profile, seconds, reason)
scs.sendFeedback(
Text.literal("Muted ${profile.name} for${
{ Text.literal("Muted ${profile.name} for${
if (seconds < 0) {
"ever"
} else {
" ${seconds - Instant.now().epochSecond} seconds"
}
}"),
}") },
true
)
return 1
}
private fun unmutePlayer(scs: ServerCommandSource, profile: GameProfile): Int {
Config.unmute(profile)
scs.sendFeedback(
Text.literal("Unmuted ${profile.name}"),
{ Text.literal("Unmuted ${profile.name}") },
true
)
return 1
}

private fun serverMute(scs: ServerCommandSource, time: Long): Int {
val serverMuteStatus: Boolean = Config.serverMute(time)
scs.sendFeedback(Text.literal("Server mute ${if (serverMuteStatus) "enabled" else "disabled"}"), true)
scs.sendFeedback({ Text.literal("Server mute ${if (serverMuteStatus) "enabled" else "disabled"}") }, true)
return 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ object StaffChatCommand {
.executes { ctx: CommandContext<ServerCommandSource> ->
StaffChat.toggle(ctx.source.player!!.uuid)
ctx.source.sendFeedback(
Text.literal(
{ Text.literal(
if (StaffChat.isInStaffChat(ctx.source.player!!.uuid)
) "Moved to staff chat" else "Moved to game chat"
), false
) }, false
)
1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object VanishCommand {
player.addStatusEffect(EFFECT_INSTANCE)
player.getServer()!!.playerManager.sendToAll(
PlayerListS2CPacket(
PlayerListS2CPacket.Action.REMOVE_PLAYER,
PlayerListS2CPacket.Action.UPDATE_LISTED,
player
)
)
Expand Down Expand Up @@ -68,7 +68,7 @@ object VanishCommand {
val player = EntityArgumentType.getPlayer(ctx, "player")
addOrRemove(player)
ctx.source.sendFeedback(
Text.literal("${if (players.contains(player)) "Vanished" else "Unvanished"} ${player.name.string}"),
{ Text.literal("${if (players.contains(player)) "Vanished" else "Unvanished"} ${player.name.string}") },
true
)
return 1
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
],

"depends": {
"fabricloader": ">=0.14.7",
"fabric": ">=0.56.0",
"minecraft": "1.19.x",
"java": ">=17",
"fabricloader": ">=0.16.5",
"fabric": ">=0.105.0",
"minecraft": "1.21.1",
"java": ">=21",
"fabric-language-kotlin": "*"
}
}
2 changes: 1 addition & 1 deletion src/main/resources/wires.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "net.quiltservertools.wires.mixins",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"server": [
],
"injectors": {
Expand Down