mirror of https://github.com/LOOHP/Limbo.git
Re-structure + Adventure
This commit is contained in:
parent
98cb6067e8
commit
2988e605b5
34
pom.xml
34
pom.xml
|
|
@ -5,7 +5,7 @@
|
||||||
<groupId>com.loohp</groupId>
|
<groupId>com.loohp</groupId>
|
||||||
<artifactId>Limbo</artifactId>
|
<artifactId>Limbo</artifactId>
|
||||||
<name>Limbo</name>
|
<name>Limbo</name>
|
||||||
<version>0.6.8-ALPHA</version>
|
<version>0.6.9-ALPHA</version>
|
||||||
|
|
||||||
<description>Standalone Limbo Minecraft Server.</description>
|
<description>Standalone Limbo Minecraft Server.</description>
|
||||||
<url>https://github.com/LOOHP/Limbo</url>
|
<url>https://github.com/LOOHP/Limbo</url>
|
||||||
|
|
@ -117,7 +117,7 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>${project.artifactId}-${project.version}-1.18</finalName>
|
<finalName>${project.artifactId}-${project.version}-1.18.1</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
@ -234,6 +234,36 @@
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||||
|
<version>4.9.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||||
|
<version>4.9.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-serializer-plain</artifactId>
|
||||||
|
<version>4.9.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-api</artifactId>
|
||||||
|
<version>4.9.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-nbt</artifactId>
|
||||||
|
<version>4.9.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fusesource.jansi</groupId>
|
<groupId>org.fusesource.jansi</groupId>
|
||||||
<artifactId>jansi</artifactId>
|
<artifactId>jansi</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,16 @@ import com.loohp.limbo.consolegui.ConsoleTextOutput;
|
||||||
import com.loohp.limbo.utils.CustomStringUtils;
|
import com.loohp.limbo.utils.CustomStringUtils;
|
||||||
|
|
||||||
import jline.console.ConsoleReader;
|
import jline.console.ConsoleReader;
|
||||||
|
import net.kyori.adventure.audience.MessageType;
|
||||||
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
import net.kyori.adventure.inventory.Book;
|
||||||
|
import net.kyori.adventure.sound.Sound;
|
||||||
|
import net.kyori.adventure.sound.Sound.Emitter;
|
||||||
|
import net.kyori.adventure.sound.SoundStop;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import net.kyori.adventure.title.TitlePart;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
|
@ -113,11 +123,13 @@ public class Console implements CommandSender {
|
||||||
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(BaseComponent component, UUID uuid) {
|
public void sendMessage(BaseComponent component, UUID uuid) {
|
||||||
sendMessage(component);
|
sendMessage(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(BaseComponent[] component, UUID uuid) {
|
public void sendMessage(BaseComponent[] component, UUID uuid) {
|
||||||
sendMessage(component);
|
sendMessage(component);
|
||||||
|
|
@ -128,16 +140,83 @@ public class Console implements CommandSender {
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(BaseComponent component) {
|
public void sendMessage(BaseComponent component) {
|
||||||
sendMessage(new BaseComponent[] {component});
|
sendMessage(new BaseComponent[] {component});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(BaseComponent[] component) {
|
public void sendMessage(BaseComponent[] component) {
|
||||||
sendMessage(String.join("", Arrays.asList(component).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())));
|
sendMessage(String.join("", Arrays.asList(component).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Identity source, Component message, MessageType type) {
|
||||||
|
sendMessage(PlainTextComponentSerializer.plainText().serialize(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openBook(Book book) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopSound(SoundStop stop) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Sound sound, Emitter emitter) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Sound sound, double x, double y, double z) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Sound sound) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendActionBar(Component message) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendPlayerListHeaderAndFooter(Component header, Component footer) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> void sendTitlePart(TitlePart<T> part, T value) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearTitle() {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetTitle() {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showBossBar(BossBar bar) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hideBossBar(BossBar bar) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
stashLine();
|
stashLine();
|
||||||
|
|
|
||||||
|
|
@ -43,16 +43,16 @@ import com.loohp.limbo.events.EventsManager;
|
||||||
import com.loohp.limbo.file.ServerProperties;
|
import com.loohp.limbo.file.ServerProperties;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.metrics.Metrics;
|
import com.loohp.limbo.metrics.Metrics;
|
||||||
|
import com.loohp.limbo.network.ServerConnection;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.Packet;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketIn;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketOut;
|
||||||
import com.loohp.limbo.permissions.PermissionsManager;
|
import com.loohp.limbo.permissions.PermissionsManager;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.plugins.LimboPlugin;
|
import com.loohp.limbo.plugins.LimboPlugin;
|
||||||
import com.loohp.limbo.plugins.PluginManager;
|
import com.loohp.limbo.plugins.PluginManager;
|
||||||
import com.loohp.limbo.scheduler.LimboScheduler;
|
import com.loohp.limbo.scheduler.LimboScheduler;
|
||||||
import com.loohp.limbo.scheduler.Tick;
|
import com.loohp.limbo.scheduler.Tick;
|
||||||
import com.loohp.limbo.server.ServerConnection;
|
|
||||||
import com.loohp.limbo.server.packets.Packet;
|
|
||||||
import com.loohp.limbo.server.packets.PacketIn;
|
|
||||||
import com.loohp.limbo.server.packets.PacketOut;
|
|
||||||
import com.loohp.limbo.utils.CustomStringUtils;
|
import com.loohp.limbo.utils.CustomStringUtils;
|
||||||
import com.loohp.limbo.utils.ImageUtils;
|
import com.loohp.limbo.utils.ImageUtils;
|
||||||
import com.loohp.limbo.utils.NetworkUtils;
|
import com.loohp.limbo.utils.NetworkUtils;
|
||||||
|
|
@ -61,8 +61,9 @@ import com.loohp.limbo.world.Environment;
|
||||||
import com.loohp.limbo.world.Schematic;
|
import com.loohp.limbo.world.Schematic;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.querz.nbt.io.NBTUtil;
|
import net.querz.nbt.io.NBTUtil;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
|
||||||
|
|
@ -106,7 +107,7 @@ public class Limbo {
|
||||||
|
|
||||||
//===========================
|
//===========================
|
||||||
|
|
||||||
public final String serverImplementationVersion = "1.18";
|
public final String serverImplementationVersion = "1.18.1";
|
||||||
public final int serverImplmentationProtocol = 757;
|
public final int serverImplmentationProtocol = 757;
|
||||||
public final String limboImplementationVersion;
|
public final String limboImplementationVersion;
|
||||||
|
|
||||||
|
|
@ -456,7 +457,7 @@ public class Limbo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public String buildServerListResponseJson(String version, int protocol, BaseComponent[] motd, int maxPlayers, int playersOnline, BufferedImage favicon) throws IOException {
|
public String buildServerListResponseJson(String version, int protocol, Component motd, int maxPlayers, int playersOnline, BufferedImage favicon) throws IOException {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
|
|
||||||
JSONObject versionJson = new JSONObject();
|
JSONObject versionJson = new JSONObject();
|
||||||
|
|
@ -491,12 +492,12 @@ public class Limbo {
|
||||||
|
|
||||||
Gson g = new GsonBuilder().create();
|
Gson g = new GsonBuilder().create();
|
||||||
|
|
||||||
return g.toJson(treeMap).replace("\"%MOTD%\"", ComponentSerializer.toString(motd));
|
return g.toJson(treeMap).replace("\"%MOTD%\"", GsonComponentSerializer.gson().serialize(motd));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String buildLegacyPingResponse(String version, BaseComponent[] motd, int maxPlayers, int playersOnline) {
|
public String buildLegacyPingResponse(String version, Component motd, int maxPlayers, int playersOnline) {
|
||||||
String begin = "§1";
|
String begin = "§1";
|
||||||
return String.join("\00", begin, "127", version, String.join("", Arrays.asList(motd).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())), String.valueOf(playersOnline), String.valueOf(maxPlayers));
|
return String.join("\00", begin, "127", version, String.join("", Arrays.asList(motd).stream().map(each -> LegacyComponentSerializer.legacySection().serialize(each)).collect(Collectors.toList())), String.valueOf(playersOnline), String.valueOf(maxPlayers));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void terminate() {
|
protected void terminate() {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,18 @@ package com.loohp.limbo.commands;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.audience.MessageType;
|
||||||
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
import net.kyori.adventure.inventory.Book;
|
||||||
|
import net.kyori.adventure.sound.Sound;
|
||||||
|
import net.kyori.adventure.sound.SoundStop;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.title.TitlePart;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
public interface CommandSender {
|
public interface CommandSender extends Audience {
|
||||||
|
|
||||||
public void sendMessage(BaseComponent[] component, UUID uuid);
|
public void sendMessage(BaseComponent[] component, UUID uuid);
|
||||||
|
|
||||||
|
|
@ -22,4 +31,30 @@ public interface CommandSender {
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
public void sendMessage(Identity source, Component message, MessageType type);
|
||||||
|
|
||||||
|
public void openBook(Book book);
|
||||||
|
|
||||||
|
public void stopSound(SoundStop stop);
|
||||||
|
|
||||||
|
public void playSound(Sound sound, Sound.Emitter emitter);
|
||||||
|
|
||||||
|
public void playSound(Sound sound, double x, double y, double z);
|
||||||
|
|
||||||
|
public void playSound(Sound sound);
|
||||||
|
|
||||||
|
public void sendActionBar(Component message);
|
||||||
|
|
||||||
|
public void sendPlayerListHeaderAndFooter(Component header, Component footer);
|
||||||
|
|
||||||
|
public <T> void sendTitlePart(TitlePart<T> part, T value);
|
||||||
|
|
||||||
|
public void clearTitle();
|
||||||
|
|
||||||
|
public void resetTitle();
|
||||||
|
|
||||||
|
public void showBossBar(BossBar bar);
|
||||||
|
|
||||||
|
public void hideBossBar(BossBar bar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,9 @@ import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
|
||||||
|
|
||||||
public class DefaultCommands implements CommandExecutor, TabCompletor {
|
public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||||
|
|
||||||
|
|
@ -55,7 +54,7 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("kick")) {
|
if (args[0].equalsIgnoreCase("kick")) {
|
||||||
if (sender.hasPermission("limboserver.kick")) {
|
if (sender.hasPermission("limboserver.kick")) {
|
||||||
BaseComponent reason = new TranslatableComponent("multiplayer.disconnect.kicked");
|
Component reason = Component.translatable("multiplayer.disconnect.kicked");
|
||||||
boolean customReason = false;
|
boolean customReason = false;
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
Player player = Limbo.getInstance().getPlayer(args[1]);
|
Player player = Limbo.getInstance().getPlayer(args[1]);
|
||||||
|
|
@ -63,13 +62,13 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
String reasonRaw = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
String reasonRaw = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||||
if (reasonRaw.trim().length() > 0) {
|
if (reasonRaw.trim().length() > 0) {
|
||||||
reason = new TextComponent(reasonRaw);
|
reason = LegacyComponentSerializer.legacySection().deserialize(reasonRaw);
|
||||||
customReason = true;
|
customReason = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.disconnect(reason);
|
player.disconnect(reason);
|
||||||
if (customReason) {
|
if (customReason) {
|
||||||
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName() + " for the reason: " + reason.toLegacyText());
|
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName() + " for the reason: " + LegacyComponentSerializer.legacySection().serialize(reason));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName());
|
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,12 @@ import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
import com.loohp.limbo.entity.DataWatcher.WatchableField;
|
||||||
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
|
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
|
|
||||||
public abstract class Entity {
|
public abstract class Entity {
|
||||||
|
|
||||||
|
|
@ -32,7 +34,7 @@ public abstract class Entity {
|
||||||
@WatchableField(MetadataIndex = 1, WatchableObjectType = WatchableObjectType.VARINT)
|
@WatchableField(MetadataIndex = 1, WatchableObjectType = WatchableObjectType.VARINT)
|
||||||
protected int air = 300;
|
protected int air = 300;
|
||||||
@WatchableField(MetadataIndex = 2, WatchableObjectType = WatchableObjectType.CHAT, IsOptional = true)
|
@WatchableField(MetadataIndex = 2, WatchableObjectType = WatchableObjectType.CHAT, IsOptional = true)
|
||||||
protected BaseComponent[] customName = null;
|
protected Component customName = null;
|
||||||
@WatchableField(MetadataIndex = 3, WatchableObjectType = WatchableObjectType.BOOLEAN)
|
@WatchableField(MetadataIndex = 3, WatchableObjectType = WatchableObjectType.BOOLEAN)
|
||||||
protected boolean customNameVisible = false;
|
protected boolean customNameVisible = false;
|
||||||
@WatchableField(MetadataIndex = 4, WatchableObjectType = WatchableObjectType.BOOLEAN)
|
@WatchableField(MetadataIndex = 4, WatchableObjectType = WatchableObjectType.BOOLEAN)
|
||||||
|
|
@ -100,20 +102,26 @@ public abstract class Entity {
|
||||||
this.pitch = location.getPitch();
|
this.pitch = location.getPitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getCustomName() {
|
public Component getCustomName() {
|
||||||
return customName;
|
return customName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomName(String name) {
|
public void setCustomName(String name) {
|
||||||
this.customName = name == null ? null : new BaseComponent[] {new TextComponent(name)};
|
this.customName = name == null ? null : LegacyComponentSerializer.legacySection().deserialize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCustomName(Component component) {
|
||||||
|
this.customName = component;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setCustomName(BaseComponent component) {
|
public void setCustomName(BaseComponent component) {
|
||||||
this.customName = component == null ? null : new BaseComponent[] {component};
|
setCustomName(component == null ? null : BungeecordAdventureConversionUtils.toComponent(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setCustomName(BaseComponent[] components) {
|
public void setCustomName(BaseComponent[] components) {
|
||||||
this.customName = components;
|
setCustomName(components == null ? null : BungeecordAdventureConversionUtils.toComponent(components));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnFire() {
|
public boolean isOnFire() {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.loohp.limbo.events.player;
|
||||||
|
|
||||||
import com.loohp.limbo.events.Cancellable;
|
import com.loohp.limbo.events.Cancellable;
|
||||||
import com.loohp.limbo.events.Event;
|
import com.loohp.limbo.events.Event;
|
||||||
import com.loohp.limbo.server.ClientConnection;
|
import com.loohp.limbo.network.ClientConnection;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.loohp.limbo.events.player;
|
package com.loohp.limbo.events.player;
|
||||||
|
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInResourcePackStatus.EnumResourcePackStatus;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInResourcePackStatus.EnumResourcePackStatus;
|
|
||||||
|
|
||||||
public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,21 @@ package com.loohp.limbo.events.status;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import com.loohp.limbo.events.Event;
|
import com.loohp.limbo.events.Event;
|
||||||
import com.loohp.limbo.server.ClientConnection;
|
import com.loohp.limbo.network.ClientConnection;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
public class StatusPingEvent extends Event {
|
public class StatusPingEvent extends Event {
|
||||||
|
|
||||||
private ClientConnection connection;
|
private ClientConnection connection;
|
||||||
private String version;
|
private String version;
|
||||||
private int protocol;
|
private int protocol;
|
||||||
private BaseComponent[] motd;
|
private Component motd;
|
||||||
private int maxPlayers;
|
private int maxPlayers;
|
||||||
private int playersOnline;
|
private int playersOnline;
|
||||||
private BufferedImage favicon;
|
private BufferedImage favicon;
|
||||||
|
|
||||||
public StatusPingEvent(ClientConnection connection, String version, int protocol, BaseComponent[] motd, int maxPlayers, int playersOnline, BufferedImage favicon) {
|
public StatusPingEvent(ClientConnection connection, String version, int protocol, Component motd, int maxPlayers, int playersOnline, BufferedImage favicon) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
|
|
@ -47,11 +47,11 @@ public class StatusPingEvent extends Event {
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getMotd() {
|
public Component getMotd() {
|
||||||
return motd;
|
return motd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotd(BaseComponent[] motd) {
|
public void setMotd(Component motd) {
|
||||||
this.motd = motd;
|
this.motd = motd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,12 @@ import com.loohp.limbo.utils.GameMode;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
import com.loohp.limbo.utils.NamespacedKey;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
|
||||||
|
|
||||||
public class ServerProperties {
|
public class ServerProperties {
|
||||||
|
|
||||||
public static final String COMMENT = "For explaination of what each of the options does, please visit:\nhttps://github.com/LOOHP/Limbo/blob/master/src/main/resources/server.properties";
|
public static final String COMMENT = "For explaination of what each of the options does, please visit:\nhttps://github.com/LOOHP/Limbo/blob/master/src/main/resources/server.properties";
|
||||||
public static final BaseComponent[] EMPTY_CHAT_COMPONENT = new BaseComponent[] {new TextComponent("")};
|
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
private int maxPlayers;
|
private int maxPlayers;
|
||||||
|
|
@ -44,7 +42,7 @@ public class ServerProperties {
|
||||||
private boolean reducedDebugInfo;
|
private boolean reducedDebugInfo;
|
||||||
private boolean allowFlight;
|
private boolean allowFlight;
|
||||||
private boolean allowChat;
|
private boolean allowChat;
|
||||||
private BaseComponent[] motd;
|
private Component motd;
|
||||||
private String versionString;
|
private String versionString;
|
||||||
private int protocol;
|
private int protocol;
|
||||||
private boolean bungeecord;
|
private boolean bungeecord;
|
||||||
|
|
@ -58,10 +56,10 @@ public class ServerProperties {
|
||||||
private String resourcePackSHA1;
|
private String resourcePackSHA1;
|
||||||
private String resourcePackLink;
|
private String resourcePackLink;
|
||||||
private boolean resourcePackRequired;
|
private boolean resourcePackRequired;
|
||||||
private BaseComponent[] resourcePackPrompt;
|
private Component resourcePackPrompt;
|
||||||
|
|
||||||
private BaseComponent[] tabHeader;
|
private Component tabHeader;
|
||||||
private BaseComponent[] tabFooter;
|
private Component tabFooter;
|
||||||
|
|
||||||
Optional<BufferedImage> favicon;
|
Optional<BufferedImage> favicon;
|
||||||
|
|
||||||
|
|
@ -109,7 +107,7 @@ public class ServerProperties {
|
||||||
allowFlight = Boolean.parseBoolean(prop.getProperty("allow-flight"));
|
allowFlight = Boolean.parseBoolean(prop.getProperty("allow-flight"));
|
||||||
allowChat = Boolean.parseBoolean(prop.getProperty("allow-chat"));
|
allowChat = Boolean.parseBoolean(prop.getProperty("allow-chat"));
|
||||||
String motdJson = prop.getProperty("motd");
|
String motdJson = prop.getProperty("motd");
|
||||||
motd = motdJson.equals("") ? EMPTY_CHAT_COMPONENT : ComponentSerializer.parse(motdJson);
|
motd = motdJson.equals("") ? Component.empty() : GsonComponentSerializer.gson().deserialize(motdJson);
|
||||||
versionString = prop.getProperty("version");
|
versionString = prop.getProperty("version");
|
||||||
bungeecord = Boolean.parseBoolean(prop.getProperty("bungeecord"));
|
bungeecord = Boolean.parseBoolean(prop.getProperty("bungeecord"));
|
||||||
velocityModern = Boolean.parseBoolean(prop.getProperty("velocity-modern"));
|
velocityModern = Boolean.parseBoolean(prop.getProperty("velocity-modern"));
|
||||||
|
|
@ -141,12 +139,12 @@ public class ServerProperties {
|
||||||
resourcePackSHA1 = prop.getProperty("resource-pack-sha1");
|
resourcePackSHA1 = prop.getProperty("resource-pack-sha1");
|
||||||
resourcePackRequired = Boolean.parseBoolean(prop.getProperty("required-resource-pack"));
|
resourcePackRequired = Boolean.parseBoolean(prop.getProperty("required-resource-pack"));
|
||||||
String resourcePackPromptJson = prop.getProperty("resource-pack-prompt");
|
String resourcePackPromptJson = prop.getProperty("resource-pack-prompt");
|
||||||
resourcePackPrompt = resourcePackPromptJson.equals("") ? null : ComponentSerializer.parse(resourcePackPromptJson);
|
resourcePackPrompt = resourcePackPromptJson.equals("") ? null : GsonComponentSerializer.gson().deserialize(resourcePackPromptJson);
|
||||||
|
|
||||||
String tabHeaderJson = prop.getProperty("tab-header");
|
String tabHeaderJson = prop.getProperty("tab-header");
|
||||||
tabHeader = tabHeaderJson.equals("") ? EMPTY_CHAT_COMPONENT : ComponentSerializer.parse(tabHeaderJson);
|
tabHeader = tabHeaderJson.equals("") ? Component.empty() : GsonComponentSerializer.gson().deserialize(tabHeaderJson);
|
||||||
String tabFooterJson = prop.getProperty("tab-footer");
|
String tabFooterJson = prop.getProperty("tab-footer");
|
||||||
tabFooter = tabFooterJson.equals("") ? EMPTY_CHAT_COMPONENT : ComponentSerializer.parse(tabFooterJson);
|
tabFooter = tabFooterJson.equals("") ? Component.empty() : GsonComponentSerializer.gson().deserialize(tabFooterJson);
|
||||||
|
|
||||||
File png = new File("server-icon.png");
|
File png = new File("server-icon.png");
|
||||||
if (png.exists()) {
|
if (png.exists()) {
|
||||||
|
|
@ -244,7 +242,7 @@ public class ServerProperties {
|
||||||
return this.allowChat;
|
return this.allowChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getMotd() {
|
public Component getMotd() {
|
||||||
return motd;
|
return motd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,15 +278,15 @@ public class ServerProperties {
|
||||||
return resourcePackRequired;
|
return resourcePackRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getResourcePackPrompt() {
|
public Component getResourcePackPrompt() {
|
||||||
return resourcePackPrompt;
|
return resourcePackPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getTabHeader() {
|
public Component getTabHeader() {
|
||||||
return tabHeader;
|
return tabHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getTabFooter() {
|
public Component getTabFooter() {
|
||||||
return tabFooter;
|
return tabFooter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.loohp.limbo.network;
|
||||||
|
|
||||||
|
public class Channel {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server;
|
package com.loohp.limbo.network;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -33,47 +33,48 @@ import com.loohp.limbo.events.player.PlayerSelectedSlotChangeEvent;
|
||||||
import com.loohp.limbo.events.status.StatusPingEvent;
|
import com.loohp.limbo.events.status.StatusPingEvent;
|
||||||
import com.loohp.limbo.file.ServerProperties;
|
import com.loohp.limbo.file.ServerProperties;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.Packet;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketHandshakingIn;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketLoginInLoginStart;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketLoginInPluginMessaging;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketLoginOutDisconnect;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketLoginOutLoginSuccess;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketLoginOutPluginMessaging;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketOut;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInChat;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInHeldItemChange;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInKeepAlive;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInPosition;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInPositionAndLook;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInResourcePackStatus;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInResourcePackStatus.EnumResourcePackStatus;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInRotation;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayInTabComplete;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutDeclareCommands;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutDisconnect;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityMetadata;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutGameState;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutHeldItemChange;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutKeepAlive;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutLogin;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerAbilities;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerAbilities.PlayerAbilityFlags;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoAction;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer.PlayerSkinProperty;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPositionAndLook;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSpawnPosition;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutTabComplete;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutTabComplete.TabCompleteMatches;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutUpdateViewPosition;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketStatusInPing;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketStatusInRequest;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketStatusOutPong;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketStatusOutResponse;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.player.PlayerInteractManager;
|
import com.loohp.limbo.player.PlayerInteractManager;
|
||||||
import com.loohp.limbo.server.packets.Packet;
|
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
||||||
import com.loohp.limbo.server.packets.PacketHandshakingIn;
|
|
||||||
import com.loohp.limbo.server.packets.PacketLoginInLoginStart;
|
|
||||||
import com.loohp.limbo.server.packets.PacketLoginInPluginMessaging;
|
|
||||||
import com.loohp.limbo.server.packets.PacketLoginOutDisconnect;
|
|
||||||
import com.loohp.limbo.server.packets.PacketLoginOutLoginSuccess;
|
|
||||||
import com.loohp.limbo.server.packets.PacketLoginOutPluginMessaging;
|
|
||||||
import com.loohp.limbo.server.packets.PacketOut;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInChat;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInHeldItemChange;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInKeepAlive;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInPosition;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInPositionAndLook;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInResourcePackStatus;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInResourcePackStatus.EnumResourcePackStatus;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInRotation;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayInTabComplete;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutDeclareCommands;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutDisconnect;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutEntityMetadata;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutGameState;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutHeldItemChange;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutKeepAlive;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutLogin;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerAbilities;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerAbilities.PlayerAbilityFlags;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerInfo;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerInfo.PlayerInfoAction;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerInfo.PlayerInfoData;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer.PlayerSkinProperty;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPositionAndLook;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutSpawnPosition;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutTabComplete;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutTabComplete.TabCompleteMatches;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutUpdateViewPosition;
|
|
||||||
import com.loohp.limbo.server.packets.PacketStatusInPing;
|
|
||||||
import com.loohp.limbo.server.packets.PacketStatusInRequest;
|
|
||||||
import com.loohp.limbo.server.packets.PacketStatusOutPong;
|
|
||||||
import com.loohp.limbo.server.packets.PacketStatusOutResponse;
|
|
||||||
import com.loohp.limbo.utils.CheckedBiConsumer;
|
import com.loohp.limbo.utils.CheckedBiConsumer;
|
||||||
import com.loohp.limbo.utils.CustomStringUtils;
|
import com.loohp.limbo.utils.CustomStringUtils;
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
@ -85,6 +86,7 @@ import com.loohp.limbo.utils.MojangAPIUtils.SkinResponse;
|
||||||
import com.loohp.limbo.world.BlockPosition;
|
import com.loohp.limbo.world.BlockPosition;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
@ -181,6 +183,10 @@ public class ClientConnection extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(BaseComponent[] reason) {
|
public void disconnect(BaseComponent[] reason) {
|
||||||
|
disconnect(BungeecordAdventureConversionUtils.toComponent(reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect(Component reason) {
|
||||||
try {
|
try {
|
||||||
PacketPlayOutDisconnect packet = new PacketPlayOutDisconnect(reason);
|
PacketPlayOutDisconnect packet = new PacketPlayOutDisconnect(reason);
|
||||||
sendPacket(packet);
|
sendPacket(packet);
|
||||||
|
|
@ -191,6 +197,10 @@ public class ClientConnection extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disconnectDuringLogin(BaseComponent[] reason) {
|
private void disconnectDuringLogin(BaseComponent[] reason) {
|
||||||
|
disconnectDuringLogin(BungeecordAdventureConversionUtils.toComponent(reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disconnectDuringLogin(Component reason) {
|
||||||
try {
|
try {
|
||||||
PacketLoginOutDisconnect packet = new PacketLoginOutDisconnect(reason);
|
PacketLoginOutDisconnect packet = new PacketLoginOutDisconnect(reason);
|
||||||
sendPacket(packet);
|
sendPacket(packet);
|
||||||
|
|
@ -452,7 +462,7 @@ public class ClientConnection extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PLAYER LIST HEADER AND FOOTER CODE CONRIBUTED BY GAMERDUCK123
|
// PLAYER LIST HEADER AND FOOTER CODE CONRIBUTED BY GAMERDUCK123
|
||||||
player.setPlayerListHeaderFooter(properties.getTabHeader(), properties.getTabFooter());
|
player.sendPlayerListHeaderAndFooter(properties.getTabHeader(), properties.getTabFooter());
|
||||||
|
|
||||||
ready = true;
|
ready = true;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server;
|
package com.loohp.limbo.network;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ClientboundClearTitlesPacket extends PacketOut {
|
||||||
|
|
||||||
|
private boolean reset;
|
||||||
|
|
||||||
|
public ClientboundClearTitlesPacket(boolean reset) {
|
||||||
|
this.reset = reset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReset() {
|
||||||
|
return reset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] serializePacket() throws IOException {
|
||||||
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
|
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||||
|
output.writeBoolean(reset);
|
||||||
|
|
||||||
|
return buffer.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -7,17 +7,18 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutSetTitleSubTitleText extends PacketOut {
|
public class ClientboundSetSubtitleTextPacket extends PacketOut {
|
||||||
private BaseComponent[] subTitle;
|
|
||||||
|
|
||||||
public PacketPlayOutSetTitleSubTitleText(BaseComponent[] subTitle) {
|
private Component subTitle;
|
||||||
|
|
||||||
|
public ClientboundSetSubtitleTextPacket(Component subTitle) {
|
||||||
this.subTitle = subTitle;
|
this.subTitle = subTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getSubTitle() {
|
public Component getSubTitle() {
|
||||||
return subTitle;
|
return subTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ public class PacketPlayOutSetTitleSubTitleText extends PacketOut {
|
||||||
|
|
||||||
DataOutputStream output = new DataOutputStream(buffer);
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(subTitle), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(subTitle), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -7,18 +7,18 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutSetTitleText extends PacketOut {
|
public class ClientboundSetTitleTextPacket extends PacketOut {
|
||||||
|
|
||||||
private BaseComponent[] titleText;
|
private Component titleText;
|
||||||
|
|
||||||
public PacketPlayOutSetTitleText(BaseComponent[] titleText) {
|
public ClientboundSetTitleTextPacket(Component titleText) {
|
||||||
this.titleText = titleText;
|
this.titleText = titleText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getTitle() {
|
public Component getTitle() {
|
||||||
return titleText;
|
return titleText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class PacketPlayOutSetTitleText extends PacketOut {
|
||||||
|
|
||||||
DataOutputStream output = new DataOutputStream(buffer);
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(titleText), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(titleText), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketPlayOutSetTitleTimes extends PacketOut {
|
public class ClientboundSetTitlesAnimationPacket extends PacketOut {
|
||||||
|
|
||||||
private Integer fadeIn;
|
private int fadeIn;
|
||||||
private Integer stay;
|
private int stay;
|
||||||
private Integer fadeOut;
|
private int fadeOut;
|
||||||
|
|
||||||
public PacketPlayOutSetTitleTimes(Integer fadeIn, Integer stay, Integer fadeOut) {
|
public ClientboundSetTitlesAnimationPacket(int fadeIn, int stay, int fadeOut) {
|
||||||
this.fadeIn = fadeIn;
|
this.fadeIn = fadeIn;
|
||||||
this.stay = stay;
|
this.stay = stay;
|
||||||
this.fadeOut = fadeOut;
|
this.fadeOut = fadeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFadeIn() {
|
public int getFadeIn() {
|
||||||
return fadeIn;
|
return fadeIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getStay() {
|
public int getStay() {
|
||||||
return stay;
|
return stay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFadeOut() {
|
public int getFadeOut() {
|
||||||
return fadeOut;
|
return fadeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
public abstract class PacketIn extends Packet {
|
public abstract class PacketIn extends Packet {
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -7,18 +7,18 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketLoginOutDisconnect extends PacketOut {
|
public class PacketLoginOutDisconnect extends PacketOut {
|
||||||
|
|
||||||
private BaseComponent[] reason;
|
private Component reason;
|
||||||
|
|
||||||
public PacketLoginOutDisconnect(BaseComponent[] reason) {
|
public PacketLoginOutDisconnect(Component reason) {
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getReason() {
|
public Component getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class PacketLoginOutDisconnect extends PacketOut {
|
||||||
|
|
||||||
DataOutputStream output = new DataOutputStream(buffer);
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
output.writeByte(Packet.getLoginOut().get(getClass()));
|
output.writeByte(Packet.getLoginOut().get(getClass()));
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(reason), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(reason), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -8,22 +8,22 @@ import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutChat extends PacketOut {
|
public class PacketPlayOutChat extends PacketOut {
|
||||||
|
|
||||||
private BaseComponent[] message;
|
private Component message;
|
||||||
private int position;
|
private int position;
|
||||||
private UUID sender;
|
private UUID sender;
|
||||||
|
|
||||||
public PacketPlayOutChat(BaseComponent[] message, int position, UUID sender) {
|
public PacketPlayOutChat(Component message, int position, UUID sender) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getMessage() {
|
public Component getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class PacketPlayOutChat extends PacketOut {
|
||||||
|
|
||||||
DataOutputStream output = new DataOutputStream(buffer);
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(message), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(message), StandardCharsets.UTF_8);
|
||||||
output.writeByte(position);
|
output.writeByte(position);
|
||||||
DataTypeIO.writeUUID(output, sender);
|
DataTypeIO.writeUUID(output, sender);
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -7,18 +7,18 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutDisconnect extends PacketOut {
|
public class PacketPlayOutDisconnect extends PacketOut {
|
||||||
|
|
||||||
private BaseComponent[] reason;
|
private Component reason;
|
||||||
|
|
||||||
public PacketPlayOutDisconnect(BaseComponent[] reason) {
|
public PacketPlayOutDisconnect(Component reason) {
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getReason() {
|
public Component getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class PacketPlayOutDisconnect extends PacketOut {
|
||||||
|
|
||||||
DataOutputStream output = new DataOutputStream(buffer);
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(reason), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(reason), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -21,7 +21,8 @@ import com.loohp.limbo.utils.DataTypeIO;
|
||||||
import com.loohp.limbo.utils.Rotation3f;
|
import com.loohp.limbo.utils.Rotation3f;
|
||||||
import com.loohp.limbo.world.BlockPosition;
|
import com.loohp.limbo.world.BlockPosition;
|
||||||
|
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutEntityMetadata extends PacketOut {
|
public class PacketPlayOutEntityMetadata extends PacketOut {
|
||||||
|
|
||||||
|
|
@ -110,7 +111,7 @@ public class PacketPlayOutEntityMetadata extends PacketOut {
|
||||||
output.writeByte((byte) watch.getValue());
|
output.writeByte((byte) watch.getValue());
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
case CHAT:
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(watch.getValue()), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize((Component) watch.getValue()), StandardCharsets.UTF_8);
|
||||||
break;
|
break;
|
||||||
//case DIRECTION:
|
//case DIRECTION:
|
||||||
// break;
|
// break;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -7,7 +7,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer;
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -7,24 +7,24 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
||||||
|
|
||||||
private BaseComponent[] header;
|
private Component header;
|
||||||
private BaseComponent[] footer;
|
private Component footer;
|
||||||
|
|
||||||
public PacketPlayOutPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
public PacketPlayOutPlayerListHeaderFooter(Component header, Component footer) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
this.footer = footer;
|
this.footer = footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getHeader() {
|
public Component getHeader() {
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getFooter() {
|
public Component getFooter() {
|
||||||
return footer;
|
return footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,8 +35,8 @@ public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
||||||
|
|
||||||
DataOutputStream output = new DataOutputStream(buffer);
|
DataOutputStream output = new DataOutputStream(buffer);
|
||||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(header), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(header), StandardCharsets.UTF_8);
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(footer), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(footer), StandardCharsets.UTF_8);
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -7,8 +7,8 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutResourcePackSend extends PacketOut {
|
public class PacketPlayOutResourcePackSend extends PacketOut {
|
||||||
|
|
||||||
|
|
@ -18,9 +18,9 @@ public class PacketPlayOutResourcePackSend extends PacketOut {
|
||||||
private String hash;
|
private String hash;
|
||||||
private boolean isForced;
|
private boolean isForced;
|
||||||
private boolean hasPromptMessage;
|
private boolean hasPromptMessage;
|
||||||
private BaseComponent[] promptMessage;
|
private Component promptMessage;
|
||||||
|
|
||||||
public PacketPlayOutResourcePackSend(String url, String hash, boolean isForced, boolean hasPromptMessage, BaseComponent[] promptMessage) {
|
public PacketPlayOutResourcePackSend(String url, String hash, boolean isForced, boolean hasPromptMessage, Component promptMessage) {
|
||||||
if (hash.length() > MAX_HASH_LENGTH) {
|
if (hash.length() > MAX_HASH_LENGTH) {
|
||||||
throw new IllegalArgumentException("Hash is too long (max " + MAX_HASH_LENGTH + ", was " + hash.length() + ")");
|
throw new IllegalArgumentException("Hash is too long (max " + MAX_HASH_LENGTH + ", was " + hash.length() + ")");
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ public class PacketPlayOutResourcePackSend extends PacketOut {
|
||||||
return hasPromptMessage;
|
return hasPromptMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseComponent[] getPromptMessage() {
|
public Component getPromptMessage() {
|
||||||
return promptMessage;
|
return promptMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class PacketPlayOutResourcePackSend extends PacketOut {
|
||||||
output.writeBoolean(isForced);
|
output.writeBoolean(isForced);
|
||||||
output.writeBoolean(hasPromptMessage);
|
output.writeBoolean(hasPromptMessage);
|
||||||
if (hasPromptMessage) {
|
if (hasPromptMessage) {
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(promptMessage), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(promptMessage), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -8,8 +8,8 @@ import java.util.Optional;
|
||||||
|
|
||||||
import com.loohp.limbo.utils.DataTypeIO;
|
import com.loohp.limbo.utils.DataTypeIO;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class PacketPlayOutTabComplete extends PacketOut {
|
public class PacketPlayOutTabComplete extends PacketOut {
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class PacketPlayOutTabComplete extends PacketOut {
|
||||||
DataTypeIO.writeString(output, match.getMatch(), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, match.getMatch(), StandardCharsets.UTF_8);
|
||||||
if (match.getTooltip().isPresent()) {
|
if (match.getTooltip().isPresent()) {
|
||||||
output.writeBoolean(true);
|
output.writeBoolean(true);
|
||||||
DataTypeIO.writeString(output, ComponentSerializer.toString(match.getTooltip().get()), StandardCharsets.UTF_8);
|
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(match.getTooltip().get()), StandardCharsets.UTF_8);
|
||||||
} else {
|
} else {
|
||||||
output.writeBoolean(false);
|
output.writeBoolean(false);
|
||||||
}
|
}
|
||||||
|
|
@ -68,18 +68,23 @@ public class PacketPlayOutTabComplete extends PacketOut {
|
||||||
public static class TabCompleteMatches {
|
public static class TabCompleteMatches {
|
||||||
|
|
||||||
private String match;
|
private String match;
|
||||||
private Optional<BaseComponent[]> tooltip;
|
private Optional<Component> tooltip;
|
||||||
|
|
||||||
public TabCompleteMatches(String match, BaseComponent... tooltip) {
|
public TabCompleteMatches(String match) {
|
||||||
this.match = match;
|
this.match = match;
|
||||||
this.tooltip = tooltip.length > 0 ? Optional.of(tooltip) : Optional.empty();
|
this.tooltip = Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabCompleteMatches(String match, Component tooltip) {
|
||||||
|
this.match = match;
|
||||||
|
this.tooltip = Optional.ofNullable(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMatch() {
|
public String getMatch() {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<BaseComponent[]> getTooltip() {
|
public Optional<Component> getTooltip() {
|
||||||
return tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.server.packets;
|
package com.loohp.limbo.network.protocol.packets;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.loohp.limbo.player;
|
package com.loohp.limbo.player;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
|
|
@ -13,19 +14,33 @@ import com.loohp.limbo.entity.LivingEntity;
|
||||||
import com.loohp.limbo.events.player.PlayerChatEvent;
|
import com.loohp.limbo.events.player.PlayerChatEvent;
|
||||||
import com.loohp.limbo.events.player.PlayerTeleportEvent;
|
import com.loohp.limbo.events.player.PlayerTeleportEvent;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.server.ClientConnection;
|
import com.loohp.limbo.network.ClientConnection;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutChat;
|
import com.loohp.limbo.network.protocol.packets.ClientboundClearTitlesPacket;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutGameState;
|
import com.loohp.limbo.network.protocol.packets.ClientboundSetSubtitleTextPacket;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutHeldItemChange;
|
import com.loohp.limbo.network.protocol.packets.ClientboundSetTitleTextPacket;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPlayerListHeaderFooter;
|
import com.loohp.limbo.network.protocol.packets.ClientboundSetTitlesAnimationPacket;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPositionAndLook;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutChat;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutResourcePackSend;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutGameState;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutRespawn;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutHeldItemChange;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutSetTitleSubTitleText;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerListHeaderFooter;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutSetTitleText;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPositionAndLook;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutSetTitleTimes;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutResourcePackSend;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutRespawn;
|
||||||
|
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
|
||||||
import com.loohp.limbo.utils.GameMode;
|
import com.loohp.limbo.utils.GameMode;
|
||||||
|
|
||||||
|
import net.kyori.adventure.audience.MessageType;
|
||||||
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
import net.kyori.adventure.inventory.Book;
|
||||||
|
import net.kyori.adventure.sound.Sound;
|
||||||
|
import net.kyori.adventure.sound.Sound.Emitter;
|
||||||
|
import net.kyori.adventure.sound.SoundStop;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
import net.kyori.adventure.title.Title.Times;
|
||||||
|
import net.kyori.adventure.title.TitlePart;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
@ -34,7 +49,6 @@ import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||||
public class Player extends LivingEntity implements CommandSender {
|
public class Player extends LivingEntity implements CommandSender {
|
||||||
|
|
||||||
public static final String CHAT_DEFAULT_FORMAT = "<%name%> %message%";
|
public static final String CHAT_DEFAULT_FORMAT = "<%name%> %message%";
|
||||||
public static final BaseComponent[] EMPTY_CHAT_COMPONENT = new BaseComponent[] {new TextComponent("")};
|
|
||||||
|
|
||||||
public final ClientConnection clientConnection;
|
public final ClientConnection clientConnection;
|
||||||
public final PlayerInteractManager playerInteractManager;
|
public final PlayerInteractManager playerInteractManager;
|
||||||
|
|
@ -202,51 +216,55 @@ public class Player extends LivingEntity implements CommandSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String message, UUID uuid) {
|
public void sendMessage(String message, UUID uuid) {
|
||||||
sendMessage(new TextComponent(message), uuid);
|
sendMessage(Identity.identity(uuid), LegacyComponentSerializer.legacySection().deserialize(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void sendMessage(BaseComponent component, UUID uuid) {
|
public void sendMessage(BaseComponent component, UUID uuid) {
|
||||||
sendMessage(new BaseComponent[] {component}, uuid);
|
sendMessage(new BaseComponent[] {component}, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(BaseComponent[] component, UUID uuid) {
|
public void sendMessage(BaseComponent[] component, UUID uuid) {
|
||||||
try {
|
sendMessage(Identity.identity(uuid), BungeecordAdventureConversionUtils.toComponent(component));
|
||||||
PacketPlayOutChat chat = new PacketPlayOutChat(component, 0, uuid);
|
|
||||||
clientConnection.sendPacket(chat);
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
sendMessage(new TextComponent(message));
|
sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void sendMessage(BaseComponent component) {
|
public void sendMessage(BaseComponent component) {
|
||||||
sendMessage(new BaseComponent[] {component});
|
sendMessage(new BaseComponent[] {component});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(BaseComponent[] component) {
|
public void sendMessage(BaseComponent[] component) {
|
||||||
try {
|
sendMessage(BungeecordAdventureConversionUtils.toComponent(component));
|
||||||
PacketPlayOutChat chat = new PacketPlayOutChat(component, 0, new UUID(0, 0));
|
|
||||||
clientConnection.sendPacket(chat);
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
disconnect(new TranslatableComponent("multiplayer.disconnect.kicked"));
|
disconnect(Component.translatable("multiplayer.disconnect.kicked"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
disconnect(new TextComponent(reason));
|
disconnect(LegacyComponentSerializer.legacySection().deserialize(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disconnect(Component reason) {
|
||||||
|
clientConnection.disconnect(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void disconnect(BaseComponent reason) {
|
public void disconnect(BaseComponent reason) {
|
||||||
disconnect(new BaseComponent[] {reason});
|
disconnect(new BaseComponent[] {reason});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void disconnect(BaseComponent[] reason) {
|
public void disconnect(BaseComponent[] reason) {
|
||||||
clientConnection.disconnect(reason);
|
disconnect(BungeecordAdventureConversionUtils.toComponent(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chat(String message) {
|
public void chat(String message) {
|
||||||
|
|
@ -281,11 +299,17 @@ public class Player extends LivingEntity implements CommandSender {
|
||||||
setResourcePack(url, hash, forced, (BaseComponent[]) null);
|
setResourcePack(url, hash, forced, (BaseComponent[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setResourcePack(String url, String hash, boolean forced, BaseComponent promptmessage) {
|
public void setResourcePack(String url, String hash, boolean forced, BaseComponent promptmessage) {
|
||||||
setResourcePack(url, hash, forced, new BaseComponent[] {promptmessage});
|
setResourcePack(url, hash, forced, promptmessage == null ? null : new BaseComponent[] {promptmessage});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setResourcePack(String url, String hash, boolean forced, BaseComponent[] promptmessage) {
|
public void setResourcePack(String url, String hash, boolean forced, BaseComponent[] promptmessage) {
|
||||||
|
setResourcePack(url, hash, forced, promptmessage == null ? null : BungeecordAdventureConversionUtils.toComponent(promptmessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourcePack(String url, String hash, boolean forced, Component promptmessage) {
|
||||||
try {
|
try {
|
||||||
PacketPlayOutResourcePackSend packsend = new PacketPlayOutResourcePackSend(url, hash, forced, promptmessage != null, promptmessage);
|
PacketPlayOutResourcePackSend packsend = new PacketPlayOutResourcePackSend(url, hash, forced, promptmessage != null, promptmessage);
|
||||||
clientConnection.sendPacket(packsend);
|
clientConnection.sendPacket(packsend);
|
||||||
|
|
@ -294,78 +318,175 @@ public class Player extends LivingEntity implements CommandSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
||||||
|
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(header), footer == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(footer));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) {
|
||||||
|
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(header), footer == null ? Component.empty() : BungeecordAdventureConversionUtils.toComponent(footer));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerListHeaderFooter(String header, String footer) {
|
||||||
|
sendPlayerListHeaderAndFooter(header == null ? Component.empty() : LegacyComponentSerializer.legacySection().deserialize(header), footer == null ? Component.empty() : LegacyComponentSerializer.legacySection().deserialize(footer));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setTitle(BaseComponent[] title) {
|
||||||
|
sendTitlePart(TitlePart.TITLE, BungeecordAdventureConversionUtils.toComponent(title));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setTitle(BaseComponent title) {
|
||||||
|
sendTitlePart(TitlePart.TITLE, BungeecordAdventureConversionUtils.toComponent(title));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
sendTitlePart(TitlePart.TITLE, LegacyComponentSerializer.legacySection().deserialize(title));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setSubTitle(BaseComponent[] subTitle) {
|
||||||
|
sendTitlePart(TitlePart.SUBTITLE, BungeecordAdventureConversionUtils.toComponent(subTitle));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setSubTitle(BaseComponent subTitle) {
|
||||||
|
sendTitlePart(TitlePart.SUBTITLE, BungeecordAdventureConversionUtils.toComponent(subTitle));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTitle(String subTitle) {
|
||||||
|
sendTitlePart(TitlePart.SUBTITLE, LegacyComponentSerializer.legacySection().deserialize(subTitle));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitleTimer(int fadeIn, int stay, int fadeOut) {
|
||||||
|
sendTitlePart(TitlePart.TIMES, Title.Times.of(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setTitleSubTitle(BaseComponent[] title, BaseComponent[] subTitle, int fadeIn, int stay, int fadeOut) {
|
||||||
|
setTitleTimer(fadeIn, stay, fadeOut);
|
||||||
|
setTitle(title);
|
||||||
|
setSubTitle(subTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setTitleSubTitle(BaseComponent title, BaseComponent subTitle, int fadeIn, int stay, int fadeOut) {
|
||||||
|
setTitleSubTitle(new BaseComponent[] {title}, new BaseComponent[] {subTitle}, fadeIn, stay, fadeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setTitleSubTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||||
|
setTitleSubTitle(new BaseComponent[] {new TextComponent(title)}, new BaseComponent[] {new TextComponent(subTitle)}, fadeIn, stay, fadeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Identity source, Component message, MessageType type) {
|
||||||
try {
|
try {
|
||||||
PacketPlayOutPlayerListHeaderFooter packsend = new PacketPlayOutPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : header, footer == null ? EMPTY_CHAT_COMPONENT : footer);
|
PacketPlayOutChat chat = new PacketPlayOutChat(message, 0, uuid);
|
||||||
|
clientConnection.sendPacket(chat);
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openBook(Book book) {
|
||||||
|
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopSound(SoundStop stop) {
|
||||||
|
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Sound sound, Emitter emitter) {
|
||||||
|
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Sound sound, double x, double y, double z) {
|
||||||
|
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playSound(Sound sound) {
|
||||||
|
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendActionBar(Component message) {
|
||||||
|
try {
|
||||||
|
PacketPlayOutChat chat = new PacketPlayOutChat(message, 2, new UUID(0, 0));
|
||||||
|
clientConnection.sendPacket(chat);
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendPlayerListHeaderAndFooter(Component header, Component footer) {
|
||||||
|
try {
|
||||||
|
PacketPlayOutPlayerListHeaderFooter packsend = new PacketPlayOutPlayerListHeaderFooter(header, footer);
|
||||||
clientConnection.sendPacket(packsend);
|
clientConnection.sendPacket(packsend);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) {
|
@Override
|
||||||
setPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {header}, footer == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {footer});
|
public <T> void sendTitlePart(TitlePart<T> part, T value) {
|
||||||
|
if (part.equals(TitlePart.TITLE)) {
|
||||||
|
try {
|
||||||
|
ClientboundSetTitleTextPacket setTitle = new ClientboundSetTitleTextPacket((Component) value);
|
||||||
|
clientConnection.sendPacket(setTitle);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else if (part.equals(TitlePart.SUBTITLE)) {
|
||||||
|
try {
|
||||||
|
ClientboundSetSubtitleTextPacket setSubTitle = new ClientboundSetSubtitleTextPacket((Component) value);
|
||||||
|
clientConnection.sendPacket(setSubTitle);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else if (part.equals(TitlePart.TIMES)) {
|
||||||
|
try {
|
||||||
|
Title.Times times = (Times) value;
|
||||||
|
ClientboundSetTitlesAnimationPacket setSubTitle = new ClientboundSetTitlesAnimationPacket((int) (times.fadeIn().toMillis() / 50), (int) (times.stay().toMillis() / 50), (int) (times.fadeOut().toMillis() / 50));
|
||||||
|
clientConnection.sendPacket(setSubTitle);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerListHeaderFooter(String header, String footer) {
|
@Override
|
||||||
setPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(header)}, footer == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(footer)});
|
public void clearTitle() {
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(BaseComponent[] title) {
|
|
||||||
try {
|
try {
|
||||||
PacketPlayOutSetTitleText setTitle = new PacketPlayOutSetTitleText(title == null ? EMPTY_CHAT_COMPONENT : title);
|
ClientboundClearTitlesPacket clearTitle = new ClientboundClearTitlesPacket(false);
|
||||||
clientConnection.sendPacket(setTitle);
|
clientConnection.sendPacket(clearTitle);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(BaseComponent title) {
|
@Override
|
||||||
setTitle(title == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {title});
|
public void resetTitle() {
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
setTitle(title == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(title)});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTitle(BaseComponent[] subTitle) {
|
|
||||||
try {
|
try {
|
||||||
PacketPlayOutSetTitleSubTitleText setSubTitle = new PacketPlayOutSetTitleSubTitleText(subTitle == null ? EMPTY_CHAT_COMPONENT : subTitle);
|
ClientboundClearTitlesPacket clearTitle = new ClientboundClearTitlesPacket(true);
|
||||||
clientConnection.sendPacket(setSubTitle);
|
clientConnection.sendPacket(clearTitle);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubTitle(BaseComponent subTitle) {
|
@Override
|
||||||
setSubTitle(subTitle == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {subTitle});
|
public void showBossBar(BossBar bar) {
|
||||||
|
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubTitle(String subTitle) {
|
@Override
|
||||||
setSubTitle(subTitle == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(subTitle)});
|
public void hideBossBar(BossBar bar) {
|
||||||
}
|
throw new UnsupportedOperationException("This function has not been implemented yet.");
|
||||||
|
|
||||||
public void setTitleTimer(Integer fadeIn, Integer stay, Integer fadeOut) {
|
|
||||||
try {
|
|
||||||
PacketPlayOutSetTitleTimes setTitleTimes = new PacketPlayOutSetTitleTimes(fadeIn, stay, fadeOut);
|
|
||||||
clientConnection.sendPacket(setTitleTimes);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitleSubTitle(BaseComponent[] title, BaseComponent[] subTitle, Integer fadeIn, Integer stay, Integer fadeOut) {
|
|
||||||
setTitleTimer(fadeIn, stay, fadeOut);
|
|
||||||
setTitle(title);
|
|
||||||
setSubTitle(subTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitleSubTitle(BaseComponent title, BaseComponent subTitle, Integer fadeIn, Integer stay, Integer fadeOut) {
|
|
||||||
setTitleSubTitle(new BaseComponent[] {title}, new BaseComponent[] {subTitle}, fadeIn, stay, fadeOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitleSubTitle(String title, String subTitle, Integer fadeIn, Integer stay, Integer fadeOut) {
|
|
||||||
setTitleSubTitle(new BaseComponent[] {new TextComponent(title)}, new BaseComponent[] {new TextComponent(subTitle)}, fadeIn, stay, fadeOut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ import java.util.stream.Collectors;
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.entity.Entity;
|
import com.loohp.limbo.entity.Entity;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
import com.loohp.limbo.server.packets.ClientboundLevelChunkWithLightPacket;
|
import com.loohp.limbo.network.protocol.packets.ClientboundLevelChunkWithLightPacket;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutEntityDestroy;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityDestroy;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutEntityMetadata;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityMetadata;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutSpawnEntity;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSpawnEntity;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutSpawnEntityLiving;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSpawnEntityLiving;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutUnloadChunk;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutUnloadChunk;
|
||||||
import com.loohp.limbo.world.ChunkPosition;
|
import com.loohp.limbo.world.ChunkPosition;
|
||||||
import com.loohp.limbo.world.World;
|
import com.loohp.limbo.world.World;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutPluginMessaging;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPluginMessaging;
|
||||||
|
|
||||||
public class BungeeLoginMessageUtils {
|
public class BungeeLoginMessageUtils {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.loohp.limbo.utils;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
|
|
||||||
|
public class BungeecordAdventureConversionUtils {
|
||||||
|
|
||||||
|
public static Component toComponent(BaseComponent... components) {
|
||||||
|
return GsonComponentSerializer.gson().deserialize(ComponentSerializer.toString(components));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BaseComponent[] toComponent(Component component) {
|
||||||
|
return ComponentSerializer.parse(GsonComponentSerializer.gson().serialize(component));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.commands.CommandSender;
|
import com.loohp.limbo.commands.CommandSender;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutDeclareCommands;
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutDeclareCommands;
|
||||||
|
|
||||||
public class DeclareCommands {
|
public class DeclareCommands {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ import com.loohp.limbo.entity.DataWatcher.WatchableObject;
|
||||||
import com.loohp.limbo.entity.Entity;
|
import com.loohp.limbo.entity.Entity;
|
||||||
import com.loohp.limbo.entity.EntityType;
|
import com.loohp.limbo.entity.EntityType;
|
||||||
import com.loohp.limbo.location.Location;
|
import com.loohp.limbo.location.Location;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityDestroy;
|
||||||
|
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityMetadata;
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutEntityDestroy;
|
|
||||||
import com.loohp.limbo.server.packets.PacketPlayOutEntityMetadata;
|
|
||||||
import com.loohp.limbo.utils.SchematicConvertionUtils;
|
import com.loohp.limbo.utils.SchematicConvertionUtils;
|
||||||
|
|
||||||
import net.querz.mca.Chunk;
|
import net.querz.mca.Chunk;
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,10 @@
|
||||||
"PacketPlayOutHeldItemChange": "0x48",
|
"PacketPlayOutHeldItemChange": "0x48",
|
||||||
"PacketPlayOutPlayerListHeaderFooter": "0x5F",
|
"PacketPlayOutPlayerListHeaderFooter": "0x5F",
|
||||||
"PacketPlayOutResourcePackSend": "0x3C",
|
"PacketPlayOutResourcePackSend": "0x3C",
|
||||||
"PacketPlayOutSetTitleTimes": "0x5B",
|
"ClientboundSetTitlesAnimationPacket": "0x5B",
|
||||||
"PacketPlayOutSetTitleText": "0x5A",
|
"ClientboundSetTitleTextPacket": "0x5A",
|
||||||
"PacketPlayOutSetTitleSubTitleText": "0x58"
|
"ClientboundSetTitleTextPacket": "0x58",
|
||||||
|
"ClientboundClearTitlesPacket": "0x10"
|
||||||
},
|
},
|
||||||
"StatusIn": {
|
"StatusIn": {
|
||||||
"0x01": "PacketStatusInPing",
|
"0x01": "PacketStatusInPing",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue