Skip to content
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

Update to 1.20.5 #47

Merged
merged 4 commits into from
Apr 21, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
# Use these Java versions
java: [
17 # Minimum supported by Minecraft
21 # Minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
Expand All @@ -32,7 +32,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v2
with:
name: Artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
17 changes: 9 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
plugins {
id 'fabric-loom' version '1.4.+'
id 'fabric-loom' version '1.6.+'
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
}

var isStable = project.is_stable == "true"

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -41,12 +41,12 @@ dependencies {
//modCompileOnly fabricApi.module("fabric-api-base", project.fabric_version)
//modLocalRuntime fabricApi.module("fabric-api-base", project.fabric_version)

modImplementation include("eu.pb4:predicate-api:0.3.0+1.20.2")
modImplementation include("eu.pb4:placeholder-api:2.4.0-pre.1+1.20.4")
modImplementation include("me.lucko:fabric-permissions-api:0.2-SNAPSHOT")
modImplementation include("eu.pb4:predicate-api:0.4.0+1.20.5")
modImplementation include("eu.pb4:placeholder-api:2.4.0-pre.1+1.20.5")
modImplementation include("me.lucko:fabric-permissions-api:0.3.1")
modImplementation include("eu.pb4:player-data-api:0.4.0+1.20.3")

modCompileOnly("maven.modrinth:vanish:1.1.0")
modCompileOnly("maven.modrinth:vanish:1.5.2+1.20.4")
//modLocalRuntime("fr.catcore:server-translations-api:1.4.17+1.19.2")

//modRuntime "supercoder79:databreaker:0.2.7"
Expand All @@ -59,6 +59,7 @@ loom {
interfaceInjection {
enableDependencyInterfaceInjection = false
}
accessWidenerPath = file("src/main/resources/styledchat.accesswidener")
}

processResources {
Expand All @@ -77,7 +78,7 @@ tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"

// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
15 changes: 7 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.6
minecraft_version=1.20.5-rc2
yarn_mappings=1.20.5-rc2+build.1
loader_version=0.15.10

#Fabric api
fabric_version=0.91.1+1.20.4
fabric_version=0.97.3+1.20.5

# Mod Properties

mod_version = 2.4.1+1.20.4
maven_group = eu.pb4
archives_base_name = styled-chat
mod_version = 2.4.1+1.20.5
maven_group = eu.pb4
archives_base_name = styled-chat

# Dependencies
is_stable = true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
13 changes: 10 additions & 3 deletions src/main/java/eu/pb4/styledchat/StyledChatStyles.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import eu.pb4.placeholders.api.node.TextNode;
import eu.pb4.styledchat.config.ConfigManager;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.network.message.MessageType;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -178,7 +179,7 @@ public static Map<String, TextNode> getEmotes(ServerCommandSource source) {

}

public static Text getCustom(Identifier identifier, Text displayName, Text message, @Nullable Text receiver, ServerCommandSource source) {
public static Text getCustom(Identifier identifier, Text displayName, Text message, Text receiver, ServerCommandSource source) {
if (source.isExecutedByPlayer()) {
var style = StyledChatUtils.getPersonalStyle(source.getPlayer()).getCustom(identifier, displayName, message, receiver, source);
if (style != null) {
Expand All @@ -192,18 +193,24 @@ public static Text getCustom(Identifier identifier, Text displayName, Text messa
return out;
}

var type = StyledChatMod.server.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).get(identifier);
var type = source.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).get(identifier);

if (type == null) {
return Text.empty();
}

var params = type.params(displayName);
var optional = source.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).getKey(type);

if (optional.isEmpty()) {
return Text.empty();
}
var params = MessageType.params(optional.get(), source.getRegistryManager(), displayName);

if (receiver != null) {
params = params.withTargetName(receiver);
}


return type.chat().apply(message, params);
}
}
5 changes: 4 additions & 1 deletion src/main/java/eu/pb4/styledchat/StyledChatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
import net.minecraft.network.message.MessageType;
import net.minecraft.network.message.SignedMessage;
import net.minecraft.network.packet.s2c.play.ChatSuggestionsS2CPacket;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.*;
Expand Down Expand Up @@ -508,6 +511,6 @@ public static ChatStyle createStyleOf(ServerPlayerEntity player) {
}

public static MessageType.Parameters createParameters(Text override) {
return new MessageType.Parameters(StyledChatMod.getMessageType(), override, null);
return MessageType.params(StyledChatMod.MESSAGE_TYPE_ID, StyledChatMod.server.getRegistryManager(), override);
}
}
13 changes: 6 additions & 7 deletions src/main/java/eu/pb4/styledchat/mixin/RegistryLoaderMixin.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package eu.pb4.styledchat.mixin;

import com.mojang.datafixers.util.Pair;
import eu.pb4.styledchat.StyledChatMod;
import net.minecraft.network.message.MessageType;
import net.minecraft.registry.*;
import net.minecraft.resource.ResourceManager;
import net.minecraft.text.Decoration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
Expand All @@ -17,12 +16,12 @@

@Mixin(RegistryLoader.class)
public class RegistryLoaderMixin {
@Inject(method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", ordinal = 0, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private static void styledChat$injectMessageTypes(ResourceManager resourceManager, DynamicRegistryManager baseRegistryManager, List<RegistryLoader.Entry<?>> entries,
CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir, Map _unused, List<Pair<MutableRegistry<?>, Object>> list) {
@Inject(method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", ordinal = 0, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private static void styledChat$injectMessageTypes(@Coerce Object registryLoadable, DynamicRegistryManager baseRegistryManager, List<RegistryLoader.Entry<?>> entries, CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir, Map map,
List<RegistryLoader.Loader<?>> list, RegistryOps.RegistryInfoGetter registryInfoGetter) {

for (var pair : list) {
var reg = pair.getFirst();
for (var entry : list) {
var reg = entry.registry();
if (reg.getKey().equals(RegistryKeys.MESSAGE_TYPE)) {
Registry.register((Registry<MessageType>) reg, StyledChatMod.MESSAGE_TYPE_ID, new MessageType(Decoration.ofChat("%s"), Decoration.ofChat("%s")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static void styledChat_noopFeedback(ServerCommandSource instance, SentMe
private static void styledChat_formatText(ServerPlayerEntity instance, SentMessage message, boolean bl, MessageType.Parameters parameters, ServerCommandSource source) {
if (message instanceof ExtendedSentMessage extSentMessage) {
try {
var sent = StyledChatMod.getMessageType().params(StyledChatStyles.getPrivateMessageSent(
var sent = MessageType.params(StyledChatMod.MESSAGE_TYPE_ID, source.getServer().getRegistryManager(), StyledChatStyles.getPrivateMessageSent(
source.getDisplayName(),
instance.getDisplayName(),
ExtSignedMessage.getArg(extSentMessage.styledChat$message(), "base_input"), instance.getCommandSource()
Expand All @@ -47,10 +47,10 @@ private static void styledChat_formatText(ServerPlayerEntity instance, SentMessa

source.sendChatMessage(message, bl, sent);

var rex = StyledChatMod.getMessageType().params(StyledChatStyles.getPrivateMessageReceived(
source.getDisplayName(),
instance.getDisplayName(),
ExtSignedMessage.getArg(extSentMessage.styledChat$message(), "base_input"), source
var rex = MessageType.params(StyledChatMod.MESSAGE_TYPE_ID, source.getServer().getRegistryManager(), StyledChatStyles.getPrivateMessageReceived(
source.getDisplayName(),
instance.getDisplayName(),
ExtSignedMessage.getArg(extSentMessage.styledChat$message(), "base_input"), source
));

instance.sendChatMessage(message, bl, rex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ private static void styledChat_replaceForSelf(ServerPlayerEntity instance, SentM
if (message instanceof ExtendedSentMessage extSentMessage) {
try {
if (source.getPlayer() == instance) {
var sent = StyledChatMod.getMessageType().params(StyledChatStyles.getTeamChatSent(
((Team) source.getEntity().getScoreboardTeam()).getFormattedName(),
source.getDisplayName(),
ExtSignedMessage.getArg(extSentMessage.styledChat$message(), "base_input"), instance.getCommandSource()
var sent = MessageType.params(StyledChatMod.MESSAGE_TYPE_ID, source.getServer().getRegistryManager(), StyledChatStyles.getTeamChatSent(
source.getEntity().getScoreboardTeam().getFormattedName(),
source.getDisplayName(),
ExtSignedMessage.getArg(extSentMessage.styledChat$message(), "base_input"), instance.getCommandSource()
));

source.sendChatMessage(message, bl, sent);
} else {
var rex = StyledChatMod.getMessageType().params(StyledChatStyles.getTeamChatReceived(
((Team) source.getEntity().getScoreboardTeam()).getFormattedName(),
var rex = MessageType.params(StyledChatMod.MESSAGE_TYPE_ID, source.getServer().getRegistryManager(), StyledChatStyles.getTeamChatReceived(
source.getEntity().getScoreboardTeam().getFormattedName(),
source.getDisplayName(),
ExtSignedMessage.getArg(extSentMessage.styledChat$message(), "base_input"), source
));
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/eu/pb4/styledchat/other/StyledChatSentMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, Message
colorless.setValue(StyledChatUtils.removeColor(parameters));
}
if (!signedMessage.isFullyFiltered()) {
var id = receiver.server.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).getId(params.type());
var id = receiver.server.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).getId(params.type().value());

if (sourceType == null || Objects.equals(id, this.sourceType.getValue())) {
receiver.networkHandler.sendChatMessage(signedMessage, color ? this.parameters : colorless.getValue());
Expand All @@ -56,13 +56,13 @@ public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, Message
? baseInput
: signedMessage.getContent();

var text = StyledChatStyles.getCustom(id, params.name(), input, params.targetName(), source != null ? source : StyledChatMod.server.getCommandSource());
var text = StyledChatStyles.getCustom(id, params.name(), input, params.targetName().orElse(null), source != null ? source : StyledChatMod.server.getCommandSource());

if (!color) {
text = StyledChatUtils.removeColor(text);
}

receiver.networkHandler.sendChatMessage(signedMessage, StyledChatUtils.createParameters(text));
receiver.networkHandler.sendChatMessage(signedMessage, MessageType.params(StyledChatMod.MESSAGE_TYPE_ID, receiver.server.getRegistryManager(), text));
}
}
}
Expand All @@ -80,7 +80,7 @@ public Text content() {

@Override
public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, MessageType.Parameters params) {
var id = receiver.server.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).getId(params.type());
var id = receiver.server.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).getId(params.type().value());
var color = ((ExtPlayNetworkHandler) receiver.networkHandler).styledChat$chatColors();
if (!color && colorless.getValue() == null) {
colorless.setValue(StyledChatUtils.removeColor(parameters));
Expand All @@ -96,7 +96,7 @@ public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, Message
? baseInput
: message.getContent();

var text = StyledChatStyles.getCustom(id, params.name(), input, params.targetName(), source != null ? source : StyledChatMod.server.getCommandSource());
var text = StyledChatStyles.getCustom(id, params.name(), input, params.targetName().orElse(null), source != null ? source : StyledChatMod.server.getCommandSource());

if (!color) {
text = StyledChatUtils.removeColor(text);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"homepage": "https://pb4.eu",
"sources": "https://github.com/Patbox/StyledChat"
},

"accessWidener": "styledchat.accesswidener",
"license": "LGPLv3",
"icon": "assets/icon.png",
"environment": "*",
Expand All @@ -29,8 +29,8 @@
],

"depends": {
"minecraft": ">=1.20.3-",
"fabricloader": ">=0.15.0"
"minecraft": ">=1.20.5-",
"fabricloader": ">=0.15.10"
},
"custom": {
"modmenu": {
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/styledchat.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessWidener v2 named

accessible class net/minecraft/registry/RegistryLoader$Loader
Loading