Edit scoreboard teams so it works for 1.17, fixes #578

This commit is contained in:
libraryaddict 2021-06-25 18:41:02 +12:00
parent a1226abb81
commit 676185481e
2 changed files with 11 additions and 7 deletions

View File

@ -97,7 +97,7 @@
<asm.version>9.0</asm.version>
<lombok.version>1.18.16</lombok.version>
<protocollib.version>4.6.0</protocollib.version>
<protocollib.version>4.7.0-SNAPSHOT</protocollib.version>
<spigot.version>[1.17,]</spigot.version>
<junit.version>4.13.1</junit.version>
<paper-api.version>[1.16,]</paper-api.version>
@ -121,7 +121,7 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.github.dmulloy2</groupId>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>${protocollib.version}</version>
<optional>true</optional>
@ -183,10 +183,6 @@
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>md_5-releases</id>
<url>https://repo.md-5.net/content/groups/public/</url>

View File

@ -8,6 +8,7 @@ import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.chat.ComponentSerializer;
@ -34,7 +35,14 @@ public class PacketListenerScoreboardTeam extends PacketAdapter {
return;
}
StructureModifier<WrappedChatComponent> chats = packet.getChatComponents();
StructureModifier<WrappedChatComponent> chats;
if (NmsVersion.v1_17.isSupported()) {
// Might need to do sanity checks but eh
chats = packet.getOptionalStructures().read(0).get().getChatComponents();
} else {
chats = packet.getChatComponents();
}
BaseComponent[] prefix = DisguiseUtilities.getColoredChat(team.getPrefix());
BaseComponent[] suffix = DisguiseUtilities.getColoredChat(team.getSuffix());