Skip to content

Commit 64a7d9f

Browse files
Strip default namespace when reading types (#1049)
1 parent 9243468 commit 64a7d9f

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/data/Dialog.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.viaversion.viabackwards.protocol.v1_21_6to1_21_5.provider.ChestDialogViewProvider;
3232
import com.viaversion.viabackwards.protocol.v1_21_6to1_21_5.storage.RegistryAndTags;
3333
import com.viaversion.viabackwards.protocol.v1_21_6to1_21_5.storage.ServerLinks;
34+
import com.viaversion.viaversion.util.Key;
3435
import java.util.ArrayList;
3536
import java.util.List;
3637
import java.util.Locale;
@@ -89,12 +90,12 @@ public Dialog(final RegistryAndTags registryAndTags, final ServerLinks serverLin
8990
}
9091
}
9192

92-
switch (type) {
93-
case "minecraft:notice" -> fillNoticeDialog(tag);
94-
case "minecraft:server_links" -> fillServerLinksDialog(serverLinks, tag);
95-
case "minecraft:dialog_list" -> fillDialogList(registryAndTags, serverLinks, tag);
96-
case "minecraft:multi_action" -> fillMultiActionDialog(tag);
97-
case "minecraft:confirmation" -> fillConfirmationDialog(tag);
93+
switch (Key.stripMinecraftNamespace(type)) {
94+
case "notice" -> fillNoticeDialog(tag);
95+
case "server_links" -> fillServerLinksDialog(serverLinks, tag);
96+
case "dialog_list" -> fillDialogList(registryAndTags, serverLinks, tag);
97+
case "multi_action" -> fillMultiActionDialog(tag);
98+
case "confirmation" -> fillConfirmationDialog(tag);
9899
default -> throw new IllegalArgumentException("Unknown dialog type: " + type + " in tag: " + tag);
99100
}
100101
}
@@ -105,9 +106,9 @@ private void fillBodyWidget(final CompoundTag tag) {
105106
throw new IllegalArgumentException("Dialog type is missing in tag: " + tag);
106107
}
107108

108-
if (type.equals("minecraft:plain_message")) {
109+
if (Key.stripMinecraftNamespace(type).equals("plain_message")) {
109110
widgets.add(new TextWidget(tag));
110-
} else if (type.equals("minecraft:item")) {
111+
} else if (Key.stripMinecraftNamespace(type).equals("item")) {
111112
widgets.add(new ItemWidget(tag));
112113
} else {
113114
throw new IllegalArgumentException("Unknown dialog body type: " + type + " in tag: " + tag);
@@ -120,11 +121,11 @@ private void fillInputWidget(final CompoundTag tag) {
120121
throw new IllegalArgumentException("Dialog type is missing in tag: " + tag);
121122
}
122123

123-
widgets.add(switch (type) {
124-
case "minecraft:boolean" -> new BooleanInput(tag);
125-
case "minecraft:number_range" -> new NumberRangeInput(tag);
126-
case "minecraft:single_option" -> new SingleOptionInput(tag);
127-
case "minecraft:text" -> new TextInput(tag);
124+
widgets.add(switch (Key.stripMinecraftNamespace(type)) {
125+
case "boolean" -> new BooleanInput(tag);
126+
case "number_range" -> new NumberRangeInput(tag);
127+
case "single_option" -> new SingleOptionInput(tag);
128+
case "text" -> new TextInput(tag);
128129
default -> throw new IllegalArgumentException("Unknown dialog input type: " + type + " in tag: " + tag);
129130
});
130131
}

common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/storage/ClickEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public boolean handleChatCommand(final UserConnection connection, final String c
5757
}
5858

5959
public static void handleClickEvent(final UserConnection connection, final CompoundTag clickEvent) {
60-
final String action = clickEvent.getString("action");
60+
final String action = Key.stripMinecraftNamespace(clickEvent.getString("action"));
6161
if ("show_dialog".equals(action)) {
6262
final RegistryAndTags registryAndTags = connection.get(RegistryAndTags.class);
6363
final ServerLinks serverLinks = connection.get(ServerLinks.class);

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ checkerQual = "3.49.1"
1616
paper = "1.16.5-R0.1-SNAPSHOT"
1717
velocity = "3.1.1"
1818
fabricLoader = "0.11.6"
19-
viaProxy = "3.4.2-SNAPSHOT"
19+
viaProxy = "3.4.3-SNAPSHOT"
2020

2121
[libraries]
2222

0 commit comments

Comments
 (0)