1
0
mirror of https://github.com/LOOHP/Limbo.git synced 2026-06-08 14:11:44 +00:00

Added PacketPlayOutSetTitleTimes, PacketPlayOutSetTitleTimes, and PacketPlayOutSetTitleSubTitleText, along with a few methods in Player such ass Player.setTitleSubTitle which calls all of these packets to create a beautiful title and sub title system for the server owners

This commit is contained in:
GamerDuck123
2021-12-21 14:15:42 -05:00
parent 53a4baa420
commit 48b8cdab80
7 changed files with 195 additions and 2 deletions
@@ -21,6 +21,9 @@ import com.loohp.limbo.server.packets.PacketPlayOutPlayerListHeaderFooter;
import com.loohp.limbo.server.packets.PacketPlayOutPositionAndLook;
import com.loohp.limbo.server.packets.PacketPlayOutResourcePackSend;
import com.loohp.limbo.server.packets.PacketPlayOutRespawn;
import com.loohp.limbo.server.packets.PacketPlayOutSetTitleSubTitleText;
import com.loohp.limbo.server.packets.PacketPlayOutSetTitleText;
import com.loohp.limbo.server.packets.PacketPlayOutSetTitleTimes;
import com.loohp.limbo.utils.GameMode;
import net.md_5.bungee.api.ChatColor;
@@ -308,4 +311,61 @@ public class Player extends LivingEntity implements CommandSender {
setPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(header)}, footer == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(footer)});
}
public void setTitle(BaseComponent[] title) {
try {
PacketPlayOutSetTitleText setTitle = new PacketPlayOutSetTitleText(title == null ? EMPTY_CHAT_COMPONENT : title);
clientConnection.sendPacket(setTitle);
} catch (IOException e) {
e.printStackTrace();
}
}
public void setTitle(BaseComponent title) {
setTitle(title == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {title});
}
public void setTitle(String title) {
setTitle(title == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(title)});
}
public void setSubTitle(BaseComponent[] subTitle) {
try {
PacketPlayOutSetTitleSubTitleText setSubTitle = new PacketPlayOutSetTitleSubTitleText(subTitle == null ? EMPTY_CHAT_COMPONENT : subTitle);
clientConnection.sendPacket(setSubTitle);
} catch (IOException e) {
e.printStackTrace();
}
}
public void setSubTitle(BaseComponent subTitle) {
setSubTitle(subTitle == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {subTitle});
}
public void setSubTitle(String subTitle) {
setSubTitle(subTitle == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(subTitle)});
}
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);
}
}