mirror of https://github.com/LOOHP/Limbo.git
Added a way to change PlayerList Header and Footer
This commit is contained in:
parent
7e81f6b3be
commit
120f9dce3f
|
|
@ -55,6 +55,9 @@ public class ServerProperties {
|
|||
private boolean resourcePackRequired;
|
||||
private String resourcePackPrompt;
|
||||
|
||||
private String tabHeader;
|
||||
private String tabFooter;
|
||||
|
||||
Optional<BufferedImage> favicon;
|
||||
|
||||
public ServerProperties(File file) throws IOException {
|
||||
|
|
@ -133,6 +136,9 @@ public class ServerProperties {
|
|||
resourcePackRequired = Boolean.parseBoolean(prop.getProperty("required-resource-pack"));
|
||||
resourcePackPrompt = prop.getProperty("resource-pack-prompt");
|
||||
|
||||
tabHeader = prop.getProperty("tab-header");
|
||||
tabFooter = prop.getProperty("tab-footer");
|
||||
|
||||
File png = new File("server-icon.png");
|
||||
if (png.exists()) {
|
||||
try {
|
||||
|
|
@ -269,4 +275,12 @@ public class ServerProperties {
|
|||
return resourcePackPrompt;
|
||||
}
|
||||
|
||||
public String getTabHeader() {
|
||||
return tabHeader;
|
||||
}
|
||||
|
||||
public String getTabFooter() {
|
||||
return tabFooter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.loohp.limbo.server.ClientConnection;
|
|||
import com.loohp.limbo.server.packets.PacketPlayOutChat;
|
||||
import com.loohp.limbo.server.packets.PacketPlayOutGameState;
|
||||
import com.loohp.limbo.server.packets.PacketPlayOutHeldItemChange;
|
||||
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;
|
||||
|
|
@ -273,4 +274,37 @@ public class Player extends LivingEntity implements CommandSender {
|
|||
}
|
||||
}
|
||||
|
||||
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
||||
try {
|
||||
PacketPlayOutPlayerListHeaderFooter packsend = new PacketPlayOutPlayerListHeaderFooter(
|
||||
ComponentSerializer.toString(header),
|
||||
ComponentSerializer.toString(footer));
|
||||
clientConnection.sendPacket(packsend);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerListHeader(BaseComponent[] header) {
|
||||
try {
|
||||
PacketPlayOutPlayerListHeaderFooter packsend = new PacketPlayOutPlayerListHeaderFooter(
|
||||
ComponentSerializer.toString(header),
|
||||
null);
|
||||
clientConnection.sendPacket(packsend);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerListFooter(BaseComponent[] footer) {
|
||||
try {
|
||||
PacketPlayOutPlayerListHeaderFooter packsend = new PacketPlayOutPlayerListHeaderFooter(
|
||||
null,
|
||||
ComponentSerializer.toString(footer));
|
||||
clientConnection.sendPacket(packsend);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -419,6 +419,8 @@ public class ClientConnection extends Thread {
|
|||
sendPacket(state);
|
||||
}
|
||||
|
||||
// RESOURCEPACK CODE ADDED BY GAMERDUCK123
|
||||
|
||||
if (properties.getResourcePackLink() != null && !properties.getResourcePackLink().equalsIgnoreCase("")) {
|
||||
if (properties.getResourcePackSHA() != null && !properties.getResourcePackSHA().equalsIgnoreCase("")) {
|
||||
//SEND RESOURCEPACK
|
||||
|
|
@ -433,6 +435,20 @@ public class ClientConnection extends Thread {
|
|||
//RESOURCEPACK NOT ENABLED
|
||||
}
|
||||
|
||||
// PLAYER LIST HEADER AND FOOTER CODE ADDED BY GAMERDUCK123
|
||||
// Sadly due to the limitations of minecraft (?) I cannot get the footer to work alone, it needs a header to have a footer, BUT
|
||||
// You can have just a header with no footer (which is weird!)
|
||||
String tabHeader = "";
|
||||
String tabFooter = "";
|
||||
if (properties.getTabHeader() != null && !properties.getTabHeader().equalsIgnoreCase("")) {
|
||||
tabHeader = properties.getTabHeader();
|
||||
}
|
||||
if (properties.getTabFooter() != null && !properties.getTabFooter().equalsIgnoreCase("")) {
|
||||
tabFooter = properties.getTabFooter();
|
||||
}
|
||||
player.setPlayerListHeaderFooter(ComponentSerializer.parse(tabHeader),
|
||||
ComponentSerializer.parse(tabFooter));
|
||||
|
||||
ready = true;
|
||||
|
||||
while (client_socket.isConnected()) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package com.loohp.limbo.server.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
|
||||
|
||||
private String header;
|
||||
private String footer;
|
||||
|
||||
public PacketPlayOutPlayerListHeaderFooter(String header, String footer) {
|
||||
this.header = header;
|
||||
this.footer = footer;
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public String getFooter() {
|
||||
return footer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] serializePacket() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
DataTypeIO.writeString(output, header, StandardCharsets.UTF_8);
|
||||
DataTypeIO.writeString(output, footer, StandardCharsets.UTF_8);
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -43,7 +43,8 @@
|
|||
"PacketPlayOutEntityMetadata": "0x4D",
|
||||
"PacketPlayOutSpawnEntity": "0x00",
|
||||
"PacketPlayOutSpawnEntityLiving": "0x02",
|
||||
"PacketPlayOutHeldItemChange": "0x48"
|
||||
"PacketPlayOutHeldItemChange": "0x48",
|
||||
"PacketPlayOutPlayerListHeaderFooter": "0x5E"
|
||||
},
|
||||
"StatusIn": {
|
||||
"0x01": "PacketStatusInPing",
|
||||
|
|
|
|||
|
|
@ -58,3 +58,9 @@ motd={"text":"","extra":[{"text":"Limbo Server!","color":"yellow"}]}
|
|||
|
||||
#Server list version as string
|
||||
version=Limbo!
|
||||
|
||||
#Tab-List Header
|
||||
tab-header={"text":"","extra":[{"text":"Welcome to Limbo!","color":"green"}]}
|
||||
|
||||
#Tab-List Footer
|
||||
tab-footer={"text":"","extra":[{"text":"Limbo Server by LOOHP","color":"yellow"}]}
|
||||
Loading…
Reference in New Issue