mirror of
https://github.com/NEZNAMY/TAB.git
synced 2026-11-26 10:29:49 -05:00
error checks
This commit is contained in:
1 parent
6fa68ab4e4
commit
1780734cce
5 files changed
+39
-14
No files matched your search
@@ -11,6 +11,7 @@ import me.neznamy.tab.bukkit.packets.PacketPlayOutPlayerInfo.EnumPlayerInfoActio
|
||||
import me.neznamy.tab.bukkit.packets.PacketPlayOutPlayerInfo.PlayerInfoData;
|
||||
import me.neznamy.tab.shared.Configs;
|
||||
import me.neznamy.tab.shared.ITabPlayer;
|
||||
import me.neznamy.tab.shared.ProtocolVersion;
|
||||
import me.neznamy.tab.shared.Shared;
|
||||
import me.neznamy.tab.shared.Shared.Feature;
|
||||
|
||||
@@ -92,11 +93,13 @@ public class Playerlist {
|
||||
public static Field GameProfile_legacy;
|
||||
|
||||
static{
|
||||
try {
|
||||
(GameProfile_properties = GameProfile.class.getDeclaredField("properties")).setAccessible(true);
|
||||
(GameProfile_legacy = GameProfile.class.getDeclaredField("legacy")).setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
Shared.error("Failed to initialize Playerlist class", e);
|
||||
if (ProtocolVersion.SERVER_VERSION.getMinorVersion() >= 8) {
|
||||
try {
|
||||
(GameProfile_properties = GameProfile.class.getDeclaredField("properties")).setAccessible(true);
|
||||
(GameProfile_legacy = GameProfile.class.getDeclaredField("legacy")).setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
Shared.error("Failed to initialize Playerlist class", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,9 +139,15 @@ public class TabPlayer extends ITabPlayer{
|
||||
NameTagLineManager.destroy(this);
|
||||
armorStands.clear();
|
||||
loadArmorStands();
|
||||
for (Player all : getPlayer().getWorld().getPlayers()) {
|
||||
if (all.getName().equals(getName())) continue;
|
||||
NameTagLineManager.spawnArmorStand(this, Shared.getPlayer(all.getUniqueId()), true);
|
||||
for (Player w : getPlayer().getWorld().getPlayers()) {
|
||||
ITabPlayer wPlayer = Shared.getPlayer(w.getUniqueId());
|
||||
if (wPlayer == null) {
|
||||
Shared.error("Data of " + w.getName() + " don't exist ?");
|
||||
continue;
|
||||
}
|
||||
if (w == wPlayer) continue;
|
||||
if (w.getName().equals(getName())) continue;
|
||||
NameTagLineManager.spawnArmorStand(this, wPlayer, true);
|
||||
}
|
||||
}
|
||||
public void loadArmorStands() {
|
||||
|
||||
@@ -16,6 +16,7 @@ public class FancyMessage {
|
||||
extras.add(c);
|
||||
}
|
||||
public String toString() {
|
||||
if (ProtocolVersion.packageName.equals("v1_8_R1")) return null;
|
||||
JsonObject main = new JsonObject();
|
||||
main.addProperty("text", "");
|
||||
if (!extras.isEmpty()) {
|
||||
|
||||
@@ -27,19 +27,19 @@ public enum ProtocolVersion {
|
||||
public static String packageName;
|
||||
|
||||
private int number;
|
||||
private String friendly;
|
||||
private String friendlyName;
|
||||
private int minorVersion;
|
||||
|
||||
ProtocolVersion(int number, String friendly, int minorVersion){
|
||||
ProtocolVersion(int number, String friendlyName, int minorVersion){
|
||||
this.number = number;
|
||||
this.friendly = friendly;
|
||||
this.friendlyName = friendlyName;
|
||||
this.minorVersion = minorVersion;
|
||||
}
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
public String getFriendlyName() {
|
||||
return friendly;
|
||||
return friendlyName;
|
||||
}
|
||||
public int getMinorVersion() {
|
||||
return minorVersion;
|
||||
@@ -47,12 +47,24 @@ public enum ProtocolVersion {
|
||||
public boolean isSupported() {
|
||||
return minorVersion >= 8;
|
||||
}
|
||||
public static ProtocolVersion fromString(String s) {
|
||||
public ProtocolVersion friendlyName(String name) {
|
||||
friendlyName = name;
|
||||
return this;
|
||||
}
|
||||
public ProtocolVersion minorVersion(int version) {
|
||||
minorVersion = version;
|
||||
return this;
|
||||
}
|
||||
public static ProtocolVersion fromServerString(String s) {
|
||||
if (s.startsWith("1.8")) return v1_8_x;
|
||||
if (s.startsWith("1.10")) return v1_10_x;
|
||||
if (s.equals("1.9.3") || s.equals("1.9.4")) return v1_9_3and4;
|
||||
if (s.equals("1.11.1") || s.equals("1.11.2")) return v1_11_1and2;
|
||||
return valueOf("v" + s.replace(".", "_"));
|
||||
try {
|
||||
return valueOf("v" + s.replace(".", "_"));
|
||||
} catch (Exception e) {
|
||||
return UNKNOWN.friendlyName(s).minorVersion(Integer.parseInt(s.split("\\.")[1]));
|
||||
}
|
||||
}
|
||||
public static ProtocolVersion fromNumber(int number) {
|
||||
for (ProtocolVersion v : values()) {
|
||||
|
||||
@@ -13,6 +13,7 @@ public class PacketPlayOutChat extends UniversalPacketPlayOut{
|
||||
private ChatMessageType type;
|
||||
|
||||
public PacketPlayOutChat(String json) {
|
||||
if (json == null) return;
|
||||
component = Shared.servertype == ServerType.BUKKIT ? MethodAPI.getInstance().ICBC_fromString(json) : json;
|
||||
this.type = ChatMessageType.CHAT;
|
||||
}
|
||||
@@ -21,6 +22,7 @@ public class PacketPlayOutChat extends UniversalPacketPlayOut{
|
||||
this.type = type;
|
||||
}
|
||||
public Object toNMS(ProtocolVersion clientVersion) throws Exception {
|
||||
if (component == null) return null;
|
||||
if (ProtocolVersion.SERVER_VERSION.getMinorVersion() >= 12) {
|
||||
return MethodAPI.getInstance().newPacketPlayOutChat(component, type.toNMS());
|
||||
} else {
|
||||
@@ -28,6 +30,7 @@ public class PacketPlayOutChat extends UniversalPacketPlayOut{
|
||||
}
|
||||
}
|
||||
public Object toBungee(ProtocolVersion clientVersion) {
|
||||
if (component == null) return null;
|
||||
return new Chat((String) component, type.toByte());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user