Skip to content

Commit b6349fe

Browse files
committed
Fixed compile errors
1 parent 79d8fde commit b6349fe

File tree

9 files changed

+35
-36
lines changed

9 files changed

+35
-36
lines changed

src/main/java/net/lenni0451/miniconnect/server/protocol/ProtocolConstants.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import lombok.SneakyThrows;
88
import net.lenni0451.commons.gson.GsonParser;
99
import net.lenni0451.commons.gson.elements.GsonElement;
10-
import net.lenni0451.mcstructs.nbt.INbtTag;
10+
import net.lenni0451.mcstructs.nbt.NbtTag;
1111
import net.lenni0451.mcstructs.nbt.io.NbtIO;
1212
import net.lenni0451.mcstructs.nbt.io.NbtReadTracker;
1313
import net.lenni0451.mcstructs.nbt.tags.CompoundTag;
@@ -36,16 +36,16 @@ public class ProtocolConstants {
3636
static {
3737
REGISTRIES = readCompound("registries.nbt", tag -> {
3838
Map<String, CompoundTag> registries = new HashMap<>();
39-
for (Map.Entry<String, INbtTag> entry : tag) {
39+
for (Map.Entry<String, NbtTag> entry : tag) {
4040
registries.put(entry.getKey(), entry.getValue().asCompoundTag());
4141
}
4242
return registries;
4343
});
4444
TAGS = readCompound("tags.nbt", tag -> {
4545
Map<String, Map<String, int[]>> tags = new HashMap<>();
46-
for (Map.Entry<String, INbtTag> entry : tag) {
46+
for (Map.Entry<String, NbtTag> entry : tag) {
4747
Map<String, int[]> registryTags = new HashMap<>();
48-
for (Map.Entry<String, INbtTag> tagEntry : entry.getValue().asCompoundTag()) {
48+
for (Map.Entry<String, NbtTag> tagEntry : entry.getValue().asCompoundTag()) {
4949
registryTags.put(tagEntry.getKey(), tagEntry.getValue().asIntArrayTag().getValue());
5050
}
5151
tags.put(entry.getKey(), registryTags);
@@ -61,7 +61,7 @@ public class ProtocolConstants {
6161
private static <T> T readCompound(final String name, final Function<CompoundTag, T> mapper) {
6262
InputStream stream = ProtocolConstants.class.getClassLoader().getResourceAsStream(name);
6363
if (stream == null) throw new IllegalStateException("Missing resource: " + name);
64-
return mapper.apply(NbtIO.JAVA.read(stream, true, NbtReadTracker.unlimited()).asCompoundTag());
64+
return mapper.apply(NbtIO.LATEST.read(stream, true, NbtReadTracker.unlimitedDepth()).asCompoundTag());
6565
}
6666

6767
@SneakyThrows

src/main/java/net/lenni0451/miniconnect/server/protocol/packets/config/S2CConfigRegistryDataPacket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io.netty.buffer.ByteBuf;
44
import lombok.AllArgsConstructor;
55
import lombok.NoArgsConstructor;
6-
import net.lenni0451.mcstructs.nbt.INbtTag;
6+
import net.lenni0451.mcstructs.nbt.NbtTag;
77
import net.lenni0451.mcstructs.nbt.tags.CompoundTag;
88
import net.raphimc.netminecraft.packet.Packet;
99
import net.raphimc.netminecraft.packet.PacketTypes;
@@ -26,7 +26,7 @@ public void read(ByteBuf byteBuf, int protocolVersion) {
2626
public void write(ByteBuf byteBuf, int protocolVersion) {
2727
PacketTypes.writeString(byteBuf, this.registry);
2828
PacketTypes.writeVarInt(byteBuf, this.data.size());
29-
for (Map.Entry<String, INbtTag> entry : this.data) {
29+
for (Map.Entry<String, NbtTag> entry : this.data) {
3030
PacketTypes.writeString(byteBuf, entry.getKey());
3131
byteBuf.writeBoolean(true);
3232
PacketTypes.writeUnnamedTag(byteBuf, entry.getValue());

src/main/java/net/lenni0451/miniconnect/server/protocol/packets/play/s2c/S2COpenScreenPacket.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io.netty.buffer.ByteBuf;
44
import lombok.AllArgsConstructor;
55
import lombok.NoArgsConstructor;
6-
import net.lenni0451.mcstructs.text.ATextComponent;
6+
import net.lenni0451.mcstructs.text.TextComponent;
77
import net.lenni0451.miniconnect.server.protocol.ProtocolConstants;
88
import net.raphimc.netminecraft.packet.Packet;
99
import net.raphimc.netminecraft.packet.PacketTypes;
@@ -14,7 +14,7 @@ public class S2COpenScreenPacket implements Packet {
1414

1515
public int id;
1616
public int type;
17-
public ATextComponent title;
17+
public TextComponent title;
1818

1919
@Override
2020
public void read(ByteBuf byteBuf, int protocolVersion) {
@@ -25,7 +25,7 @@ public void read(ByteBuf byteBuf, int protocolVersion) {
2525
public void write(ByteBuf byteBuf, int protocolVersion) {
2626
PacketTypes.writeVarInt(byteBuf, this.id);
2727
PacketTypes.writeVarInt(byteBuf, this.type);
28-
PacketTypes.writeUnnamedTag(byteBuf, ProtocolConstants.TEXT_CODEC.serializeNbt(this.title));
28+
PacketTypes.writeUnnamedTag(byteBuf, ProtocolConstants.TEXT_CODEC.serializeNbtTree(this.title));
2929
}
3030

3131
}

src/main/java/net/lenni0451/miniconnect/server/protocol/packets/play/s2c/S2CSystemChatPacket.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io.netty.buffer.ByteBuf;
44
import lombok.AllArgsConstructor;
55
import lombok.NoArgsConstructor;
6-
import net.lenni0451.mcstructs.text.ATextComponent;
6+
import net.lenni0451.mcstructs.text.TextComponent;
77
import net.lenni0451.miniconnect.server.protocol.ProtocolConstants;
88
import net.raphimc.netminecraft.packet.Packet;
99
import net.raphimc.netminecraft.packet.PacketTypes;
@@ -12,7 +12,7 @@
1212
@AllArgsConstructor
1313
public class S2CSystemChatPacket implements Packet {
1414

15-
public ATextComponent message;
15+
public TextComponent message;
1616
public boolean actionbar;
1717

1818
@Override
@@ -22,7 +22,7 @@ public void read(ByteBuf byteBuf, int protocolVersion) {
2222

2323
@Override
2424
public void write(ByteBuf byteBuf, int protocolVersion) {
25-
PacketTypes.writeUnnamedTag(byteBuf, ProtocolConstants.TEXT_CODEC.serializeNbt(this.message));
25+
PacketTypes.writeUnnamedTag(byteBuf, ProtocolConstants.TEXT_CODEC.serializeNbtTree(this.message));
2626
byteBuf.writeBoolean(this.actionbar);
2727
}
2828

src/main/java/net/lenni0451/miniconnect/server/states/play/Tutorial.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private static FilterableComponent[] buildTutorial(final String... pages) {
5858
if (i != 0) base.append("\n");
5959
base.append(lines[i]);
6060
}
61-
components.add(new FilterableComponent(ViaUtils.convertNbt(ProtocolConstants.TEXT_CODEC.serializeNbt(base)), null));
61+
components.add(new FilterableComponent(ViaUtils.convertNbt(ProtocolConstants.TEXT_CODEC.serializeNbtTree(base)), null));
6262
}
6363
return components.toArray(new FilterableComponent[0]);
6464
}

src/main/java/net/lenni0451/miniconnect/server/states/play/screen/ItemBuilder.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
77
import com.viaversion.viaversion.api.minecraft.item.Item;
88
import com.viaversion.viaversion.api.minecraft.item.StructuredItem;
9-
import net.lenni0451.mcstructs.text.ATextComponent;
9+
import net.lenni0451.mcstructs.text.TextComponent;
1010
import net.lenni0451.miniconnect.server.protocol.ProtocolConstants;
1111
import net.lenni0451.miniconnect.utils.ViaUtils;
1212

@@ -21,21 +21,21 @@ public static ItemBuilder item(final String id) {
2121

2222

2323
private final String id;
24-
private ATextComponent name;
25-
private final List<ATextComponent> lore = new ArrayList<>();
24+
private TextComponent name;
25+
private final List<TextComponent> lore = new ArrayList<>();
2626
private Boolean glint;
2727
private final Map<StructuredDataKey, Object> structuredData = new HashMap<>();
2828

2929
private ItemBuilder(final String id) {
3030
this.id = id;
3131
}
3232

33-
public ItemBuilder named(final ATextComponent name) {
33+
public ItemBuilder named(final TextComponent name) {
3434
this.name = name;
3535
return this;
3636
}
3737

38-
public ItemBuilder lore(final ATextComponent... lore) {
38+
public ItemBuilder lore(final TextComponent... lore) {
3939
Collections.addAll(this.lore, lore);
4040
return this;
4141
}
@@ -61,12 +61,12 @@ public Item get() {
6161
StructuredItem item = new StructuredItem(rawId, 1);
6262
item.dataContainer().setIdLookup(Via.getManager().getProtocolManager().getProtocol(Protocol1_21_4To1_21_2.class), false);
6363
if (this.name != null) {
64-
item.dataContainer().set(StructuredDataKey.CUSTOM_NAME, ViaUtils.convertNbt(ProtocolConstants.TEXT_CODEC.serializeNbt(this.name)));
64+
item.dataContainer().set(StructuredDataKey.CUSTOM_NAME, ViaUtils.convertNbt(ProtocolConstants.TEXT_CODEC.serializeNbtTree(this.name)));
6565
}
6666
if (!this.lore.isEmpty()) {
6767
Tag[] lore = new Tag[this.lore.size()];
6868
for (int i = 0; i < this.lore.size(); i++) {
69-
lore[i] = ViaUtils.convertNbt(ProtocolConstants.TEXT_CODEC.serializeNbt(this.lore.get(i)));
69+
lore[i] = ViaUtils.convertNbt(ProtocolConstants.TEXT_CODEC.serializeNbtTree(this.lore.get(i)));
7070
}
7171
item.dataContainer().set(StructuredDataKey.LORE, lore);
7272
}

src/main/java/net/lenni0451/miniconnect/server/states/play/screen/Screen.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
package net.lenni0451.miniconnect.server.states.play.screen;
22

3-
import net.lenni0451.mcstructs.text.ATextComponent;
3+
import net.lenni0451.mcstructs.text.TextComponent;
44

55
public abstract class Screen {
66

7-
private final ATextComponent title;
7+
private final TextComponent title;
88
private final int slotCount;
99
private final int inventoryType;
1010

11-
public Screen(final ATextComponent title, final int rows) {
11+
public Screen(final TextComponent title, final int rows) {
1212
this.title = title;
1313
this.slotCount = rows * 9;
1414
this.inventoryType = rows - 1;
1515
}
1616

17-
public Screen(final ATextComponent title, final int inventoryType, final int slotCount) {
17+
public Screen(final TextComponent title, final int inventoryType, final int slotCount) {
1818
this.title = title;
1919
this.slotCount = slotCount;
2020
this.inventoryType = inventoryType;
2121
}
2222

23-
public ATextComponent getTitle() {
23+
public TextComponent getTitle() {
2424
return this.title;
2525
}
2626

src/main/java/net/lenni0451/miniconnect/server/states/play/screen/impl/MainScreen.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook;
1111
import com.viaversion.viaversion.api.platform.PlatformTask;
1212
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
13-
import net.lenni0451.mcstructs.core.TextFormatting;
14-
import net.lenni0451.mcstructs.text.ATextComponent;
13+
import net.lenni0451.mcstructs.text.TextComponent;
14+
import net.lenni0451.mcstructs.text.TextFormatting;
1515
import net.lenni0451.mcstructs.text.components.StringComponent;
16-
import net.lenni0451.mcstructs.text.events.click.ClickEvent;
17-
import net.lenni0451.mcstructs.text.events.click.ClickEventAction;
16+
import net.lenni0451.mcstructs.text.events.click.types.OpenUrlClickEvent;
1817
import net.lenni0451.miniconnect.Main;
1918
import net.lenni0451.miniconnect.server.model.PlayerConfig;
2019
import net.lenni0451.miniconnect.server.protocol.ProtocolConstants;
@@ -105,8 +104,8 @@ public void init(ScreenHandler screenHandler, ItemList itemList) {
105104
PlatformTask<?> task = Via.getPlatform().runAsync(() -> {
106105
try {
107106
playerConfig.account = new MicrosoftAccount(MicrosoftAccount.DEVICE_CODE_LOGIN.getFromInput(MinecraftAuth.createHttpClient(), new StepMsaDeviceCode.MsaDeviceCodeCallback(code -> {
108-
ATextComponent component = new StringComponent("Please open your browser and visit ").modifyStyle(style -> style.setFormatting(TextFormatting.YELLOW));
109-
component.append(new StringComponent(code.getDirectVerificationUri()).modifyStyle(style -> style.setFormatting(TextFormatting.BLUE).setClickEvent(new ClickEvent(ClickEventAction.OPEN_URL, code.getDirectVerificationUri()))));
107+
TextComponent component = new StringComponent("Please open your browser and visit ").styled(style -> style.setFormatting(TextFormatting.YELLOW));
108+
component.append(new StringComponent(code.getDirectVerificationUri()).styled(style -> style.setFormatting(TextFormatting.BLUE).setClickEvent(new OpenUrlClickEvent(code.getDirectVerificationUri()))));
110109
component.append(new StringComponent(" and login with your Microsoft account"));
111110
screenHandler.getStateHandler().send(new S2CSystemChatPacket(component, false));
112111
screenHandler.getStateHandler().send(new S2CSystemChatPacket(new StringComponent("§bIf the code is not inserted automatically, please enter the code: §a" + code.getUserCode()), false));

src/main/java/net/lenni0451/miniconnect/utils/ViaUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package net.lenni0451.miniconnect.utils;
22

33
import com.viaversion.nbt.tag.*;
4-
import net.lenni0451.mcstructs.nbt.INbtTag;
4+
import net.lenni0451.mcstructs.nbt.NbtTag;
55

66
import javax.annotation.Nullable;
77
import java.util.Collections;
88
import java.util.Map;
99

1010
public class ViaUtils {
1111

12-
public static Tag convertNbt(@Nullable final INbtTag nbt) {
12+
public static Tag convertNbt(@Nullable final NbtTag nbt) {
1313
if (nbt == null) return null;
1414
return switch (nbt.getNbtType()) {
1515
case END -> throw new UnsupportedOperationException();
@@ -23,14 +23,14 @@ public static Tag convertNbt(@Nullable final INbtTag nbt) {
2323
case STRING -> new StringTag(nbt.asStringTag().getValue());
2424
case LIST -> {
2525
ListTag<? super Tag> listTag = new ListTag<>(Collections.emptyList());
26-
for (INbtTag tag : nbt.asListTag()) {
26+
for (NbtTag tag : nbt.asListTag()) {
2727
listTag.add(convertNbt(tag));
2828
}
2929
yield listTag;
3030
}
3131
case COMPOUND -> {
3232
CompoundTag compoundTag = new CompoundTag();
33-
for (Map.Entry<String, INbtTag> entry : nbt.asCompoundTag()) {
33+
for (Map.Entry<String, NbtTag> entry : nbt.asCompoundTag()) {
3434
compoundTag.put(entry.getKey(), convertNbt(entry.getValue()));
3535
}
3636
yield compoundTag;

0 commit comments

Comments
 (0)