mirror of
https://github.com/NEZNAMY/TAB.git
synced 2026-11-26 10:29:49 -05:00
small changes
This commit is contained in:
1 parent
fa7cfc198c
commit
61ba8a6e00
16 files changed
+45
-52
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
name: TAB
|
||||
main: me.neznamy.tab.platforms.bungee.Main
|
||||
version: 2.5.4-pre3
|
||||
version: 2.5.4-pre4
|
||||
author: NEZNAMY
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name: TAB
|
||||
version: 2.5.4-pre3
|
||||
version: 2.5.4-pre4
|
||||
author: NEZNAMY
|
||||
main: me.neznamy.tab.platforms.bukkit.Main
|
||||
api-version: 1.13
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Main extends JavaPlugin implements Listener, MainClass{
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
Bukkit.getPluginCommand("tab").setExecutor(new CommandExecutor() {
|
||||
public boolean onCommand(CommandSender sender, Command c, String cmd, String[] args){
|
||||
TabCommand.execute(sender instanceof Player ? Shared.getPlayer(sender.getName()) : null, args);
|
||||
TabCommand.execute(sender instanceof Player ? Shared.getPlayer(((Player)sender).getUniqueId()) : null, args);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -346,7 +346,7 @@ public class Main extends JavaPlugin implements Listener, MainClass{
|
||||
}
|
||||
PluginHooks.luckPerms = Bukkit.getPluginManager().isPluginEnabled("LuckPerms");
|
||||
PluginHooks.groupManager = Bukkit.getPluginManager().getPlugin("GroupManager");
|
||||
PluginHooks.placeholderAPI= Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
|
||||
PluginHooks.placeholderAPI = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
|
||||
if (PluginHooks.placeholderAPI) PlaceholderAPIExpansion.register();
|
||||
PluginHooks.permissionsEx = Bukkit.getPluginManager().isPluginEnabled("PermissionsEx");
|
||||
PluginHooks.libsDisguises = Bukkit.getPluginManager().isPluginEnabled("LibsDisguises");
|
||||
@@ -533,13 +533,13 @@ public class Main extends JavaPlugin implements Listener, MainClass{
|
||||
});
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Player[] getOnlinePlayers() {
|
||||
Object players = Bukkit.getOnlinePlayers();
|
||||
public static Player[] getOnlinePlayers() throws Exception {
|
||||
Object players = Bukkit.class.getMethod("getOnlinePlayers").invoke(null);
|
||||
if (players instanceof Player[]) {
|
||||
//1.5.x - 1.7.x
|
||||
//1.5.x - 1.6.x
|
||||
return (Player[]) players;
|
||||
} else {
|
||||
//1.8+
|
||||
//1.7+
|
||||
return ((Collection<Player>)players).toArray(new Player[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.neznamy.tab.platforms.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -12,44 +11,39 @@ public class PerWorldPlayerlist {
|
||||
public static boolean allowBypass;
|
||||
public static List<Object> ignoredWorlds;
|
||||
|
||||
public static void load(){
|
||||
public static void load() throws Exception{
|
||||
if (!enabled) return;
|
||||
for (Player p : Bukkit.getOnlinePlayers()){
|
||||
for (Player p : Main.getOnlinePlayers()){
|
||||
hidePlayer(p);
|
||||
showInSameWorld(p);
|
||||
}
|
||||
}
|
||||
public static void unload(){
|
||||
if (enabled) for (Player p : Bukkit.getOnlinePlayers()) for (Player pl : Bukkit.getOnlinePlayers()) p.showPlayer(pl);
|
||||
public static void unload() throws Exception{
|
||||
if (enabled) for (Player p : Main.getOnlinePlayers()) for (Player pl : Main.getOnlinePlayers()) p.showPlayer(pl);
|
||||
}
|
||||
public static void trigger(Player p){
|
||||
public static void trigger(Player p) throws Exception{
|
||||
if (!enabled) return;
|
||||
// System.out.println("triggering world change/join for " + p.getName());
|
||||
hidePlayer(p);
|
||||
showInSameWorld(p);
|
||||
}
|
||||
public static void showInSameWorld(Player p) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()){
|
||||
public static void showInSameWorld(Player p) throws Exception {
|
||||
for (Player pl : Main.getOnlinePlayers()){
|
||||
if (pl == p) continue;
|
||||
if (p.getWorld() == pl.getWorld()) {
|
||||
// System.out.println("showing " + p.getName() + " and " + pl.getName() + " mutually because they are in the same world");
|
||||
p.showPlayer(pl);
|
||||
pl.showPlayer(p);
|
||||
}
|
||||
if ((allowBypass && p.hasPermission("tab.bypass")) || ignoredWorlds.contains(p.getWorld().getName())) {
|
||||
// System.out.println("showing " + pl.getName() + " to " + p.getName() + " because bypassPermision & has bypass permission OR " + p.getName() + " is in ignored world");
|
||||
p.showPlayer(pl);
|
||||
}
|
||||
if ((allowBypass && pl.hasPermission("tab.bypass")) || ignoredWorlds.contains(pl.getWorld().getName())) {
|
||||
// System.out.println("showing " + p.getName() + " to " + pl.getName() + " because bypassPermision & has bypass permission OR " + pl.getName() + " is in ignored world");
|
||||
pl.showPlayer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void hidePlayer(Player p) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()){
|
||||
public static void hidePlayer(Player p) throws Exception {
|
||||
for (Player pl : Main.getOnlinePlayers()){
|
||||
if (pl == p) continue;
|
||||
// System.out.println("hiding players " + p.getName() + " and " + pl.getName() + " mutually");
|
||||
p.hidePlayer(pl);
|
||||
pl.hidePlayer(p);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ArmorStand{
|
||||
updateLocation();
|
||||
for (ITabPlayer all : registeredTo.toArray(new ITabPlayer[0])) {
|
||||
if (all == owner) continue; //should never be anyway
|
||||
if (all.getVersion().getNetworkId() >= ProtocolVersion.v1_14.getNetworkId()) {
|
||||
if (all.getVersion().getMinorVersion() >= 14) {
|
||||
//sneaking feature was removed in 1.14, so despawning completely now
|
||||
if (sneaking) {
|
||||
all.sendPacket(MethodAPI.getInstance().newPacketPlayOutEntityDestroy(entityId));
|
||||
@@ -126,7 +126,7 @@ public class ArmorStand{
|
||||
}
|
||||
}
|
||||
public boolean getVisibility() {
|
||||
return !owner.hasInvisibility() && player.getGameMode() != GameMode.valueOf("SPECTATOR") && !TABAPI.hasHiddenNametag(player.getUniqueId()) && property.get().length() > 0;
|
||||
return !owner.hasInvisibility() && player.getGameMode() != GameMode.valueOf("SPECTATOR") && !TABAPI.hasHiddenNametag(owner.getUniqueId()) && property.get().length() > 0;
|
||||
}
|
||||
private void updateLocation() {
|
||||
if (System.currentTimeMillis() - lastLocationRefresh < 50) return;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Main extends Plugin implements Listener, MainClass{
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
getProxy().getPluginManager().registerCommand(this, new Command("btab") {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
TabCommand.execute(sender instanceof ProxiedPlayer ? Shared.getPlayer(sender.getName()) : null, args);
|
||||
TabCommand.execute(sender instanceof ProxiedPlayer ? Shared.getPlayer(((ProxiedPlayer)sender).getUniqueId()) : null, args);
|
||||
}
|
||||
});
|
||||
load(false, true);
|
||||
@@ -211,7 +211,7 @@ public class Main extends Plugin implements Listener, MainClass{
|
||||
super.write(context, packet, channelPromise);
|
||||
return;
|
||||
}
|
||||
if (packet instanceof PlayerListItem && Playerlist.enable && player.getVersion().getNetworkId() >= ProtocolVersion.v1_8.getNetworkId()) {
|
||||
if (packet instanceof PlayerListItem && Playerlist.enable && player.getVersion().getMinorVersion() >= 8) {
|
||||
PacketPlayOutPlayerInfo p = PacketPlayOutPlayerInfo.fromBungee(packet);
|
||||
Playerlist.modifyPacket(p, player);
|
||||
packet = p.toBungee(null);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Main implements MainClass{
|
||||
Shared.mainClass = this;
|
||||
server.getCommandManager().register("btab", new Command() {
|
||||
public void execute(CommandSource sender, String[] args) {
|
||||
TabCommand.execute(sender instanceof Player ? Shared.getPlayer(((Player)sender).getUsername()) : null, args);
|
||||
TabCommand.execute(sender instanceof Player ? Shared.getPlayer(((Player)sender).getUniqueId()) : null, args);
|
||||
}
|
||||
});
|
||||
load(false, true);
|
||||
@@ -179,7 +179,7 @@ public class Main implements MainClass{
|
||||
super.write(context, packet, channelPromise);
|
||||
return;
|
||||
}
|
||||
if (packet instanceof PlayerListItem && Playerlist.enable) {
|
||||
if (packet instanceof PlayerListItem && Playerlist.enable && player.getVersion().getMinorVersion() >= 8) {
|
||||
PacketPlayOutPlayerInfo p = PacketPlayOutPlayerInfo.fromVelocity(packet);
|
||||
Playerlist.modifyPacket(p, player);
|
||||
packet = p.toVelocity(null);
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package me.neznamy.tab.shared;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import me.neznamy.tab.platforms.bukkit.packets.method.MethodAPI;
|
||||
import me.neznamy.tab.shared.Shared.Feature;
|
||||
import me.neznamy.tab.shared.packets.PacketPlayOutBoss.BarColor;
|
||||
@@ -16,8 +14,8 @@ import me.neznamy.tab.shared.packets.PacketPlayOutBoss.BarStyle;
|
||||
public class BossBar{
|
||||
|
||||
public static boolean enabled;
|
||||
public static List<String> defaultBars = Lists.newArrayList();
|
||||
public static Map<String, List<String>> perWorld = Maps.newConcurrentMap();
|
||||
public static List<String> defaultBars = new ArrayList<String>();
|
||||
public static Map<String, List<String>> perWorld = new HashMap<String, List<String>>();
|
||||
public static List<BossBarLine> lines = new ArrayList<BossBarLine>();
|
||||
public static int refresh;
|
||||
public static String toggleCommand;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class HeaderFooter {
|
||||
});
|
||||
}
|
||||
public static void clearHeaderFooter(ITabPlayer p) {
|
||||
if (p.disabledHeaderFooter || p.getVersion().getNetworkId() < ProtocolVersion.v1_8.getNetworkId()) return;
|
||||
if (p.disabledHeaderFooter || p.getVersion().getMinorVersion() < 8) return;
|
||||
p.sendCustomPacket(new PacketPlayOutPlayerListHeaderFooter("",""));
|
||||
}
|
||||
public static void unload() {
|
||||
@@ -28,7 +28,7 @@ public class HeaderFooter {
|
||||
if (enable) refreshHeaderFooter(p, true);
|
||||
}
|
||||
public static void refreshHeaderFooter(ITabPlayer p, boolean force) {
|
||||
if (p.disabledHeaderFooter || p.getVersion().getNetworkId() < ProtocolVersion.v1_8.getNetworkId()) return;
|
||||
if (p.disabledHeaderFooter || p.getVersion().getMinorVersion() < 8) return;
|
||||
boolean header = p.properties.get("header").isUpdateNeeded();
|
||||
boolean footer = p.properties.get("footer").isUpdateNeeded();
|
||||
if (header || footer || force) p.sendCustomPacket(new PacketPlayOutPlayerListHeaderFooter(p.properties.get("header").get(), p.properties.get("footer").get()));
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class ITabPlayer{
|
||||
disabledTablistObjective = Configs.disabledTablistObjective.contains(getWorldName());
|
||||
disabledBossbar = Configs.disabledBossbar.contains(getWorldName());
|
||||
disabledBelowname = Configs.disabledBelowname.contains(getWorldName());
|
||||
infoData = new PlayerInfoData(name, tablistId, null, 0, EnumGamemode.CREATIVE, name);
|
||||
if (Playerlist.enable) infoData = new PlayerInfoData(name, tablistId, null, 0, EnumGamemode.CREATIVE, name);
|
||||
}
|
||||
|
||||
//bukkit only
|
||||
|
||||
@@ -9,7 +9,6 @@ public interface MainClass {
|
||||
public String getSeparatorType();
|
||||
public boolean isDisabled();
|
||||
public void reload(ITabPlayer sender);
|
||||
// public Object createComponent(String text);
|
||||
public boolean killPacket(Object packetPlayOutScoreboardTeam) throws Exception;
|
||||
public Object toNMS(UniversalPacketPlayOut packet, ProtocolVersion protocolVersion) throws Exception;
|
||||
public void loadConfig() throws Exception;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class PacketAPI{
|
||||
|
||||
//scoreboard team
|
||||
public static synchronized void registerScoreboardTeam(ITabPlayer to, String teamName, String prefix, String suffix, boolean enumNameTagVisibility, boolean enumTeamPush, Collection<String> players) {
|
||||
if (to.getVersion().getNetworkId() >= ProtocolVersion.v1_8.getNetworkId() && Configs.SECRET_safe_register) {
|
||||
if (to.getVersion().getMinorVersion() >= 8 && Configs.SECRET_safe_register) {
|
||||
unregisterScoreboardTeam(to, teamName);
|
||||
}
|
||||
sendScoreboardTeamPacket(to, teamName, prefix, suffix, enumNameTagVisibility, enumTeamPush, players, 0, 69);
|
||||
@@ -50,7 +50,7 @@ public class PacketAPI{
|
||||
|
||||
//scoreboard objective
|
||||
public static void registerScoreboardObjective(ITabPlayer to, String objectiveName, String title, int position, EnumScoreboardHealthDisplay displayType) {
|
||||
if (to.getVersion().getNetworkId() >= ProtocolVersion.v1_8.getNetworkId()) {
|
||||
if (to.getVersion().getMinorVersion() >= 8) {
|
||||
unregisterScoreboardObjective(to, objectiveName, title, displayType);
|
||||
}
|
||||
to.sendCustomPacket(new PacketPlayOutScoreboardObjective(objectiveName, title, displayType, 0));
|
||||
|
||||
@@ -14,35 +14,39 @@ public class Playerlist {
|
||||
public static boolean enable;
|
||||
public static int refresh;
|
||||
|
||||
public static void load() {
|
||||
public static void load() throws Exception {
|
||||
if (enable) {
|
||||
updateNames(true);
|
||||
Shared.scheduleRepeatingTask(refresh, "refreshing tablist prefix/suffix", Feature.PLAYERLIST_1, new Runnable() {
|
||||
public void run() {
|
||||
updateNames(false);
|
||||
try {
|
||||
updateNames(false);
|
||||
} catch (Exception e) {
|
||||
Shared.error(null, null, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private static void updateNames(boolean force) {
|
||||
private static void updateNames(boolean force) throws Exception {
|
||||
List<PlayerInfoData> updatedPlayers = new ArrayList<PlayerInfoData>();
|
||||
for (ITabPlayer p : Shared.getPlayers()) {
|
||||
if (!p.disabledTablistNames && (p.isListNameUpdateNeeded() || force)) updatedPlayers.add(p.getInfoData());
|
||||
}
|
||||
if (!updatedPlayers.isEmpty()) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, updatedPlayers);
|
||||
Object packet = Shared.mainClass.toNMS(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, updatedPlayers), null);
|
||||
for (ITabPlayer all : Shared.getPlayers()) {
|
||||
if (all.getVersion().getNetworkId() >= ProtocolVersion.v1_8.getNetworkId()) all.sendCustomPacket(packet);
|
||||
if (all.getVersion().getMinorVersion() >= 8) all.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void unload() {
|
||||
public static void unload() throws Exception {
|
||||
if (enable) {
|
||||
updateNames(true);
|
||||
}
|
||||
}
|
||||
public static void modifyPacket(PacketPlayOutPlayerInfo packet, ITabPlayer receiver){
|
||||
if (receiver.getVersion().getNetworkId() < ProtocolVersion.v1_8.getNetworkId()) return;
|
||||
if (receiver.getVersion().getMinorVersion() < 8) return;
|
||||
for (PlayerInfoData playerInfoData : packet.players) {
|
||||
ITabPlayer packetPlayer = Shared.getPlayerByTablistUUID(playerInfoData.uniqueId);
|
||||
if (packet.action == EnumPlayerInfoAction.UPDATE_GAME_MODE || packet.action == EnumPlayerInfoAction.ADD_PLAYER) {
|
||||
|
||||
@@ -3,8 +3,6 @@ package me.neznamy.tab.shared;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class Property {
|
||||
|
||||
private ITabPlayer owner;
|
||||
@@ -107,7 +105,7 @@ public class Property {
|
||||
return Static;
|
||||
}
|
||||
public static List<Placeholder> detectPlaceholders(String rawValue, boolean playerPlaceholders) {
|
||||
if (!rawValue.contains("%") && !rawValue.contains("{")) return Lists.newArrayList();
|
||||
if (!rawValue.contains("%") && !rawValue.contains("{")) return new ArrayList<Placeholder>();
|
||||
List<Placeholder> placeholdersTotal = new ArrayList<Placeholder>();
|
||||
for (Placeholder placeholder : playerPlaceholders ? Placeholders.getAll() : Placeholders.serverPlaceholders) {
|
||||
if (rawValue.contains(placeholder.getIdentifier())) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Shared {
|
||||
public static final String DECODER_NAME = "TABReader";
|
||||
public static final ExecutorService exe = Executors.newCachedThreadPool();
|
||||
public static final boolean consoleErrors = false;
|
||||
public static final String pluginVersion = "2.5.4-pre3";
|
||||
public static final String pluginVersion = "2.5.4-pre4";
|
||||
|
||||
public static ConcurrentHashMap<UUID, ITabPlayer> data = new ConcurrentHashMap<UUID, ITabPlayer>();
|
||||
public static ConcurrentHashMap<Feature, Long> cpuLastSecond = new ConcurrentHashMap<Feature, Long>();
|
||||
|
||||
@@ -225,7 +225,7 @@ public class TabCommand{
|
||||
}
|
||||
public static void debug(ITabPlayer sender, ITabPlayer analyzed) {
|
||||
if (analyzed == null && sender != null) {
|
||||
analyzed = Shared.getPlayer(sender.getName());
|
||||
analyzed = Shared.getPlayer(sender.getUniqueId());
|
||||
}
|
||||
sendMessage(sender, "§3[TAB] §a§lShowing debug information");
|
||||
sendMessage(sender, "§7§m>-------------------------------<");
|
||||
|
||||
Reference in new issue
Block a user