Skip to content

Commit 515b47c

Browse files
committed
Finish update to 1.20.5
1 parent 1a385cc commit 515b47c

9 files changed

Lines changed: 18 additions & 37 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
matrix:
1313
# Use these Java versions
1414
java: [
15-
17 # Latest version
15+
21 # Latest version
1616
]
1717
# and run on both Linux and Windows
1818
os: [ubuntu-20.04]

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up JDK
2525
uses: actions/setup-java@v1
2626
with:
27-
java-version: 17
27+
java-version: 21
2828

2929
- name: Grant execute permission for gradlew
3030
run: chmod +x gradlew

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.5.+'
2+
id 'fabric-loom' version '1.6.+'
33
id 'maven-publish'
44
id "com.modrinth.minotaur" version "2.+"
55
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
88
loader_version=0.15.10
99

1010
#Fabric api
11-
fabric_version=0.96.12+1.20.5
11+
fabric_version=0.97.3+1.20.5
1212

1313
# Mod Properties
1414
mod_version = 2.4.0-pre.1+1.20.5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/eu/pb4/placeholders/api/node/TranslatedNode.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ public Text toText(ParserContext context, boolean removeBackslashes) {
3333
args[i] = this.args[i] instanceof TextNode textNode ? textNode.toText(context, removeBackslashes) : this.args[i];
3434
}
3535

36-
if (GeneralUtils.IS_LEGACY_TRANSLATION) {
37-
return Text.translatable(this.key, args);
38-
} else {
39-
return Text.translatableWithFallback(this.key(), this.fallback, args);
40-
}
36+
37+
return Text.translatableWithFallback(this.key(), this.fallback, args);
4138
}
4239

4340
@Override

src/main/java/eu/pb4/placeholders/impl/GeneralUtils.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@ public class GeneralUtils {
2525
public static final boolean IS_DEV = FabricLoader.getInstance().isDevelopmentEnvironment();
2626
public static final TextNode[] CASTER = new TextNode[0];
2727

28-
public static final boolean IS_LEGACY_TRANSLATION;
29-
30-
static {
31-
boolean IS_LEGACY1;
32-
try {
33-
IS_LEGACY1 = FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion().compareTo(Version.parse("1.19.4")) < 0;
34-
} catch (VersionParsingException e) {
35-
IS_LEGACY1 = false;
36-
e.printStackTrace();
37-
}
38-
IS_LEGACY_TRANSLATION = IS_LEGACY1;
39-
}
40-
4128
public static String durationToString(long x) {
4229
long seconds = x % 60;
4330
long minutes = (x / 60) % 60;
@@ -239,11 +226,8 @@ public static ParentNode convertToNodes(Text input) {
239226
}
240227
}
241228

242-
if (IS_LEGACY_TRANSLATION) {
243-
list.add(TranslatedNode.of(content.getKey(), args.toArray()));
244-
} else {
245-
list.add(TranslatedNode.ofFallback(content.getKey(), content.getFallback(), args.toArray()));
246-
}
229+
230+
list.add(TranslatedNode.ofFallback(content.getKey(), content.getFallback(), args.toArray()));
247231
} else if (input.getContent() instanceof ScoreTextContent content) {
248232
list.add(new ScoreNode(content.getName(), content.getObjective()));
249233
} else if (input.getContent() instanceof KeybindTextContent content) {

src/main/java/eu/pb4/placeholders/impl/textparser/BuiltinTags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static void register() {
114114
true,
115115
(nodes, data, parser) -> {
116116
return new ColorNode(nodes, TextColor.parse(data.get("value", 0, "white")).result().orElse(DEFAULT_COLOR));
117-
}
117+
})
118118
);
119119
}
120120
{

src/testmod/java/eu/pb4/placeholderstest/TestMod.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private static int test2(CommandContext<ServerCommandSource> context) {
116116
try {
117117
ServerPlayerEntity player = context.getSource().getPlayer();
118118
Text text = TextParserUtils.formatText(context.getArgument("text", String.class));
119-
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text)), false);
119+
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text, context.getSource().getRegistryManager())), false);
120120
player.sendMessage(text, false);
121121
} catch (Exception e) {
122122
e.printStackTrace();
@@ -147,10 +147,10 @@ private static int test2oldnewjson(CommandContext<ServerCommandSource> context)
147147
Text text = TextParserV1.DEFAULT.parseNode(form).toText();
148148
Text text2 = TagParser.SIMPLIFIED_TEXT_FORMAT.parseNode(form).toText();
149149
player.sendMessage(Text.literal("v1"), false);
150-
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text)), false);
150+
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text, context.getSource().getRegistryManager())), false);
151151
player.sendMessage(text, false);
152152
player.sendMessage(Text.literal("v2"), false);
153-
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text2)), false);
153+
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text2, context.getSource().getRegistryManager())), false);
154154
player.sendMessage(text2, false);
155155
} catch (Exception e) {
156156
e.printStackTrace();
@@ -183,7 +183,7 @@ private static int test3(CommandContext<ServerCommandSource> context) {
183183
Text text = placeholders.toText(ParserContext.of(PlaceholderContext.KEY, PlaceholderContext.of(player)), true);
184184
var textTime = System.nanoTime() - time;
185185

186-
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text)), false);
186+
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text, context.getSource().getRegistryManager())), false);
187187
player.sendMessage(Texts.parse(context.getSource(), text, context.getSource().getEntity(), 0), false);
188188
player.sendMessage(Text.literal(
189189
"Tag: " + ((tagTime / 1000) / 1000d) + " ms | " +
@@ -205,7 +205,7 @@ private static int test4Text(CommandContext<ServerCommandSource> context) {
205205
Placeholders.PREDEFINED_PLACEHOLDER_PATTERN,
206206
Map.of("player", player.getName())
207207
);
208-
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text)), false);
208+
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text, context.getSource().getRegistryManager())), false);
209209
player.sendMessage(text, false);
210210
} catch (Exception e) {
211211
e.printStackTrace();
@@ -221,7 +221,7 @@ private static int test4nodes(CommandContext<ServerCommandSource> context) {
221221
Placeholders.PREDEFINED_PLACEHOLDER_PATTERN,
222222
Map.of("player", player.getName())
223223
).toText(ParserContext.of(PlaceholderContext.KEY, PlaceholderContext.of(player)), true);
224-
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text)), false);
224+
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text, context.getSource().getRegistryManager())), false);
225225
player.sendMessage(text, false);
226226
} catch (Exception e) {
227227
e.printStackTrace();
@@ -239,7 +239,7 @@ private static int test5(CommandContext<ServerCommandSource> context) {
239239
.simplifiedTextFormat()
240240
.build()
241241
.parseText(form, PlaceholderContext.of(player).asParserContext());
242-
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text2)), false);
242+
player.sendMessage(Text.literal(Text.Serialization.toJsonString(text2, context.getSource().getRegistryManager())), false);
243243
player.sendMessage(text2, false);
244244
} catch (Exception e) {
245245
e.printStackTrace();
@@ -278,7 +278,7 @@ private static int test7(CommandContext<ServerCommandSource> context) {
278278
public void onInitialize() {
279279
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, dedicated) -> {
280280
dispatcher.register(
281-
literal("test").then(argument("text", TextArgumentType.text()).executes(TestMod::test))
281+
literal("test").then(argument("text", TextArgumentType.text(registryAccess)).executes(TestMod::test))
282282
);
283283
dispatcher.register(
284284
literal("argtest").then(argument("arg", StringArgumentType.greedyString()).executes(TestMod::argTest))

0 commit comments

Comments
 (0)