TabList: header and footer

This commit is contained in:
Bixilon 2020-06-23 16:41:45 +02:00
parent 341c29f8cf
commit f25ec3b5b1
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 81 additions and 1 deletions

View File

@ -91,7 +91,6 @@ public class Minosoft {
case OTHER:
path += ".minosoft/";
break;
//ToDo: Mac, Other
}
File folder = new File(path);
if (!folder.exists() && !folder.mkdirs()) {

View File

@ -47,6 +47,9 @@ public class Player {
HashMap<Integer, Inventory> inventories = new HashMap<>();
boolean spawnConfirmed = false;
TextComponent tabHeader;
TextComponent tabFooter;
public Player(MojangAccount acc) {
this.acc = acc;
// create our own inventory without any properties
@ -216,4 +219,20 @@ public class Player {
}
return null;
}
public TextComponent getTabHeader() {
return tabHeader;
}
public void setTabHeader(TextComponent tabHeader) {
this.tabHeader = tabHeader;
}
public TextComponent getTabFooter() {
return tabFooter;
}
public void setTabFooter(TextComponent tabFooter) {
this.tabFooter = tabFooter;
}
}

View File

@ -0,0 +1,56 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.game.datatypes.TextComponent;
import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketTabHeaderAndFooter implements ClientboundPacket {
TextComponent header;
TextComponent footer;
@Override
public void read(InPacketBuffer buffer, ProtocolVersion v) {
switch (v) {
case VERSION_1_8:
header = buffer.readTextComponent();
footer = buffer.readTextComponent();
break;
}
}
@Override
public void log() {
Log.protocol(String.format("Received tab list header: %s", header.getColoredMessage()));
Log.protocol(String.format("Received tab list footer: %s", footer.getColoredMessage()));
}
@Override
public void handle(PacketHandler h) {
h.handle(this);
}
public TextComponent getHeader() {
return header;
}
public TextComponent getFooter() {
return footer;
}
}

View File

@ -479,4 +479,9 @@ public class PacketHandler {
public void handle(PacketServerDifficulty pkg) {
}
public void handle(PacketTabHeaderAndFooter pkg) {
connection.getPlayer().setTabHeader(pkg.getHeader());
connection.getPlayer().setTabFooter(pkg.getFooter());
}
}

View File

@ -114,6 +114,7 @@ public abstract class Protocol implements ProtocolInterface {
packetClassMapping.put(Packets.Clientbound.PLAY_DISPLAY_SCOREBOARD, PacketScoreboardDisplayScoreboard.class);
packetClassMapping.put(Packets.Clientbound.PLAY_MAP_DATA, PacketMapData.class);
packetClassMapping.put(Packets.Clientbound.PLAY_SERVER_DIFFICULTY, PacketServerDifficulty.class);
packetClassMapping.put(Packets.Clientbound.PLAY_LIST_HEADER_AND_FOOTER, PacketTabHeaderAndFooter.class);
}
public static ProtocolVersion getLowestVersionSupported() {