Compare commits

...
19 Commits
Author SHA1 Message Date
NEZNAMY 189797aa73 Bukkit - Use the other constructor for player info packet which is cleaner (also #797) 2023-01-21 00:18:19 +01:00
NEZNAMY 1ae2ef7cad Fix compilation 2023-01-21 00:17:02 +01:00
NEZNAMY de14e14d33 Revert "Placeholders - Add timeout for placeholders to return value, causing TAB to freeze"
This reverts commit 37caed3123.
2023-01-19 22:30:09 +01:00
NEZNAMY 19892c14c1 Revert "Placeholders - Increase placeholder retrieve timeout to 500ms (#792)"
This reverts commit 6d85875fde.
2023-01-19 22:29:59 +01:00
NEZNAMY 2e00c4c002 Revert "NameTags - Fix error that doesn't make sense (#794)"
This reverts commit 12f5dd52b4.
2023-01-19 22:29:52 +01:00
NEZNAMY 97aa367629 Revert "Fix thread pool not being single threaded (maybe #781?)"
This reverts commit 87cc9a030b.
2023-01-19 22:28:22 +01:00
NEZNAMY 87cc9a030b Fix thread pool not being single threaded (maybe #781?) 2023-01-19 22:01:11 +01:00
NEZNAMY 8ba83d1cb1 BossBar - Fix errors when progress is below 0 or above 100 2023-01-19 16:59:05 +01:00
NEZNAMY 9f0e60bd47 Per world PlayerList - Remove redundant task schedule to main thread 2023-01-19 16:58:45 +01:00
NEZNAMY 93b2a25b2e Merge pull request #795 from Chris6ix/update-actions
Update Actions
2023-01-17 22:01:37 +01:00
Chris 4242d7a839 Remove Test Build Trigger 2023-01-17 21:33:33 +01:00
Chris 0ddb99bd46 Trigger Test Build 2023-01-17 21:29:34 +01:00
Chris 969672e3ad Update Actions 2023-01-17 21:26:40 +01:00
NEZNAMY 2423fbb150 Update README.md 2023-01-17 20:28:47 +01:00
NEZNAMY a99928dbf5 Placeholders - Colorize output of relational placeholders as well 2023-01-17 20:25:06 +01:00
NEZNAMY 12f5dd52b4 NameTags - Fix error that doesn't make sense (#794) 2023-01-17 15:38:20 +01:00
NEZNAMY 2bd105446e Bukkit - Properly send RGB messages into console (only for Paper+, Spigot doesn't support RGB at all) 2023-01-17 14:11:51 +01:00
NEZNAMY 6d85875fde Placeholders - Increase placeholder retrieve timeout to 500ms (#792) 2023-01-16 18:49:23 +01:00
NEZNAMY 42810aa490 3.2.3-SNAPSHOT 2023-01-16 18:47:42 +01:00
15 changed files with 46 additions and 74 deletions

No files matched your search

+5 -5
View File
@@ -11,22 +11,22 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.3.0 #https://github.com/actions/checkout/releases
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v3.9.0 #https://github.com/actions/setup-java/releases
with:
distribution: 'temurin'
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v2
uses: actions/cache@v3.2.3 #https://github.com/actions/cache/releases
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle
uses: actions/cache@v2
uses: actions/cache@v3.2.3 #https://github.com/actions/cache/releases
with:
path: |
~/.gradle/caches
@@ -39,7 +39,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: ./gradlew clean build
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v3.1.2 #https://github.com/actions/upload-artifact/releases
with:
name: Jar
path: jar/build/libs/TAB-**.jar
+3
View File
@@ -26,6 +26,9 @@ In other words, they **are not available for**:
* **Support** - support is provided on discord for buyers, where roles are given to verified users
allowing us to know who bought it and who didn't. It also serves as a much faster way of communication.
* **Feature requests** - closed indefinitely.
**If you're a customer, please use discord for reporting bugs, especially if you aren't good at making bug reports.
You will be provided with a much faster and higher quality service.**
# Contributing
If this plugin has helped you in any way, and you would like to return something back
@@ -335,23 +335,8 @@ public class TabConstants {
public static final String VAULT_SUFFIX = "%vault-suffix%";
public static final String HEALTH = "%health%";
/**
* Minimum refresh interval of a placeholder in milliseconds, used to set refresh interval of the main task
*/
public static final int MINIMUM_REFRESH_INTERVAL = 50;
/**
* Timeout in milliseconds for a placeholder to return value
* to prevent SQL tasks by PlaceholderAPI placeholders from freezing TAB
*/
public static final int PLACEHOLDER_RETRIEVE_TIMEOUT = 50;
/**
* Internal constant used to detect if placeholder threw an error.
* If so, placeholder's last known value is displayed instead.
*/
public static final String ERROR_VALUE = "ERROR";
public static String condition(String name) {
return "%condition:" + name + "%";
@@ -12,10 +12,12 @@ import me.neznamy.tab.api.protocol.PacketPlayOutBoss.Action;
import me.neznamy.tab.api.protocol.PacketPlayOutPlayerInfo.EnumGamemode;
import me.neznamy.tab.api.protocol.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import me.neznamy.tab.api.protocol.PacketPlayOutPlayerInfo.PlayerInfoData;
import me.neznamy.tab.platforms.bukkit.nms.*;
import me.neznamy.tab.platforms.bukkit.nms.PacketPlayOutEntityDestroy;
import me.neznamy.tab.platforms.bukkit.nms.PacketPlayOutEntityMetadata;
import me.neznamy.tab.platforms.bukkit.nms.PacketPlayOutEntityTeleport;
import me.neznamy.tab.platforms.bukkit.nms.PacketPlayOutSpawnEntityLiving;
import me.neznamy.tab.platforms.bukkit.nms.datawatcher.DataWatcher;
import me.neznamy.tab.platforms.bukkit.nms.storage.NMSStorage;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
@@ -100,7 +102,7 @@ public class BukkitPacketBuilder extends PacketBuilder {
);
}
Enum[] array = packet.getActions().stream().map(action -> Enum.valueOf(nms.EnumPlayerInfoAction, action.toString())).toArray(Enum[]::new);
Object nmsPacket = nms.newPacketPlayOutPlayerInfo.newInstance(array[0], nms.getHandle.invoke(Bukkit.getOnlinePlayers().iterator().next()));
Object nmsPacket = nms.newPacketPlayOutPlayerInfo.newInstance(EnumSet.of(array[0], array), Collections.emptyList());
List<Object> items = new ArrayList<>();
for (PlayerInfoData data : packet.getEntries()) {
GameProfile profile = new GameProfile(data.getUniqueId(), data.getName());
@@ -116,7 +118,6 @@ public class BukkitPacketBuilder extends PacketBuilder {
data.getProfilePublicKey() == null ? null : nms.newRemoteChatSession$Data.newInstance(data.getChatSessionId(), data.getProfilePublicKey()));
items.add(obj);
}
nms.setField(nmsPacket, nms.PacketPlayOutPlayerInfo_ACTION, EnumSet.of(array[0], array));
nms.setField(nmsPacket, nms.PacketPlayOutPlayerInfo_PLAYERS, items);
return nmsPacket;
} else {
@@ -5,6 +5,7 @@ import me.clip.placeholderapi.PlaceholderAPI;
import me.neznamy.tab.api.TabConstants;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.api.chat.EnumChatFormat;
import me.neznamy.tab.api.chat.rgb.RGBUtils;
import me.neznamy.tab.platforms.bukkit.features.BukkitTabExpansion;
import me.neznamy.tab.platforms.bukkit.features.PerWorldPlayerList;
import me.neznamy.tab.platforms.bukkit.features.PetFix;
@@ -272,6 +273,7 @@ public class BukkitPlatform extends Platform {
/**
* Sends console message using ConsoleCommandSender, due to
* Paper not translating colors correctly in Logger messages
* and to allow RGB (at least on Paper, doesn't work on spigot)
*
* @param message
* Message to send
@@ -280,6 +282,9 @@ public class BukkitPlatform extends Platform {
*/
@Override
public void sendConsoleMessage(String message, boolean translateColors) {
Bukkit.getConsoleSender().sendMessage("[TAB] " + (translateColors ? EnumChatFormat.color(message) : message));
Bukkit.getConsoleSender().sendMessage("[TAB] " + (translateColors ?
EnumChatFormat.color(RGBUtils.getInstance().convertToBukkitFormat(message,
TAB.getInstance().getServerVersion().getMinorVersion() >= 16))
: message));
}
}
@@ -25,9 +25,6 @@ import me.neznamy.tab.shared.TAB;
@SuppressWarnings("deprecation")
public class PerWorldPlayerList extends TabFeature implements Listener {
/** Reference to main class */
private final JavaPlugin plugin;
/** Config options */
private final boolean allowBypass = TabAPI.getInstance().getConfig().getBoolean("per-world-playerlist.allow-bypass-permission", false);
private final List<String> ignoredWorlds = TabAPI.getInstance().getConfig().getStringList("per-world-playerlist.ignore-effect-in-worlds", Arrays.asList("ignoredworld", "build"));
@@ -41,14 +38,13 @@ public class PerWorldPlayerList extends TabFeature implements Listener {
*/
public PerWorldPlayerList(JavaPlugin plugin) {
super("Per world PlayerList", null);
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
TabAPI.getInstance().debug(String.format("Loaded PerWorldPlayerList feature with parameters allowBypass=%s, ignoredWorlds=%s, sharedWorlds=%s", allowBypass, ignoredWorlds, sharedWorlds));
}
@Override
public void load(){
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getOnlinePlayers().forEach(this::checkPlayer));
Bukkit.getOnlinePlayers().forEach(this::checkPlayer);
}
@Override
@@ -312,7 +312,7 @@ public abstract class NMSStorage {
if (minorVersion < 8) return;
if (is1_19_3Plus()) {
newClientboundPlayerInfoRemovePacket = ClientboundPlayerInfoRemovePacket.getConstructor(List.class);
newPacketPlayOutPlayerInfo = PacketPlayOutPlayerInfo.getConstructor(EnumPlayerInfoAction, EntityPlayer);
newPacketPlayOutPlayerInfo = PacketPlayOutPlayerInfo.getConstructor(EnumSet.class, Collection.class);
ClientboundPlayerInfoRemovePacket_getEntries = getMethods(ClientboundPlayerInfoRemovePacket, List.class).get(0);
PacketPlayOutPlayerInfo_ACTION = getFields(PacketPlayOutPlayerInfo, EnumSet.class).get(0);
newRemoteChatSession$Data = RemoteChatSession$Data.getConstructor(UUID.class, ProfilePublicKey$a);
+1 -1
View File
@@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=3.2.2
projectVersion=3.2.3-SNAPSHOT
# Gradle properties
org.gradle.daemon=true
+1
View File
@@ -9,6 +9,7 @@ dependencyResolutionManagement {
maven("https://repo.viaversion.com/") // ViaVersion
maven("https://repo.essentialsx.net/releases/") // Essentials
maven("https://repo.codemc.org/repository/maven-public/") // RedisBungee
maven("https://repo.codemc.io/repository/maven-snapshots/") // Fixing compilation
maven("https://repo.kryptonmc.org/releases") // YamlAssist, LuckPerms
maven("https://repo.kryptonmc.org/snapshots") // BungeeCord
maven("https://repo.opencollab.dev/maven-snapshots/") // Floodgate
@@ -225,6 +225,6 @@ public class DynamicText implements Property {
RelationalPlaceholderImpl pl = (RelationalPlaceholderImpl) TAB.getInstance().getPlaceholderManager().getPlaceholder(identifier);
format = format.replace(pl.getIdentifier(), viewer == null ? "" : pl.getLastValue(viewer, owner));
}
return format;
return EnumChatFormat.color(format);
}
}
@@ -170,7 +170,10 @@ public class BossBarLine implements BossBar {
* @return parsed progress
*/
public float parseProgress(String progress) {
return TAB.getInstance().getErrorManager().parseFloat(progress, 100);
float value = TAB.getInstance().getErrorManager().parseFloat(progress, 100);
if (value < 0) value = 0;
if (value > 100) value = 100;
return value;
}
@Override
@@ -1,22 +1,24 @@
package me.neznamy.tab.shared.placeholders;
import me.neznamy.tab.api.TabConstants;
import java.util.*;
import java.util.function.Function;
import me.neznamy.tab.api.TabFeature;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.api.placeholder.PlayerPlaceholder;
import me.neznamy.tab.shared.TAB;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
/**
* Implementation of the PlayerPlaceholder interface
*/
public class PlayerPlaceholderImpl extends TabPlaceholder implements PlayerPlaceholder {
/**
* Internal constant used to detect if placeholder threw an error.
* If so, placeholder's last known value is displayed.
*/
private final String ERROR_VALUE = "ERROR";
/** Placeholder function returning fresh output on request */
private final Function<TabPlayer, Object> function;
@@ -57,8 +59,8 @@ public class PlayerPlaceholderImpl extends TabPlaceholder implements PlayerPlace
if (identifier.equals(newValue) && !lastValues.containsKey(p)) {
lastValues.put(p, identifier);
}
if (!lastValues.containsKey(p) || (!TabConstants.Placeholder.ERROR_VALUE.equals(newValue) && !identifier.equals(newValue) && !lastValues.get(p).equals(newValue))) {
lastValues.put(p, TabConstants.Placeholder.ERROR_VALUE.equals(newValue) ? identifier : newValue);
if (!lastValues.containsKey(p) || (!ERROR_VALUE.equals(newValue) && !identifier.equals(newValue) && !lastValues.get(p).equals(newValue))) {
lastValues.put(p, ERROR_VALUE.equals(newValue) ? identifier : newValue);
updateParents(p);
if (TAB.getInstance().getPlaceholderManager().getTabExpansion() != null)
TAB.getInstance().getPlaceholderManager().getTabExpansion().setPlaceholderValue(p, identifier, newValue);
@@ -125,14 +127,10 @@ public class PlayerPlaceholderImpl extends TabPlaceholder implements PlayerPlace
@Override
public Object request(TabPlayer p) {
try {
return placeholderFutureThreadPool.submit(() -> function.apply(p)).get(
TabConstants.Placeholder.PLACEHOLDER_RETRIEVE_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
TAB.getInstance().getErrorManager().criticalError("Placeholder " + identifier + " took longer than " +
TabConstants.Placeholder.PLACEHOLDER_RETRIEVE_TIMEOUT + "ms to retrieve value for player " + p.getName() + ", aborting.", null);
return function.apply(p);
} catch (Throwable t) {
TAB.getInstance().getErrorManager().placeholderError("Player placeholder " + identifier + " generated an error when setting for player " + p.getName(), t);
return ERROR_VALUE;
}
return TabConstants.Placeholder.ERROR_VALUE;
}
}
@@ -2,11 +2,8 @@ package me.neznamy.tab.shared.placeholders;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.BiFunction;
import me.neznamy.tab.api.TabConstants;
import me.neznamy.tab.api.TabFeature;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.api.chat.EnumChatFormat;
@@ -119,14 +116,10 @@ public class RelationalPlaceholderImpl extends TabPlaceholder implements Relatio
@Override
public Object request(TabPlayer viewer, TabPlayer target) {
try {
return placeholderFutureThreadPool.submit(() -> function.apply(viewer, target)).get(
TabConstants.Placeholder.PLACEHOLDER_RETRIEVE_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
TAB.getInstance().getErrorManager().criticalError("Placeholder " + identifier + " took longer than " +
TabConstants.Placeholder.PLACEHOLDER_RETRIEVE_TIMEOUT + "ms to retrieve value for viewer " + viewer.getName() + " and target " + target.getName() + ", aborting.", null);
return function.apply(viewer, target);
} catch (Throwable t) {
TAB.getInstance().getErrorManager().placeholderError("Relational placeholder " + identifier + " generated an error when setting for players " + viewer.getName() + " and " + target.getName(), t);
return "ERROR";
}
return TabConstants.Placeholder.ERROR_VALUE;
}
}
@@ -1,11 +1,8 @@
package me.neznamy.tab.shared.placeholders;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Supplier;
import me.neznamy.tab.api.TabConstants;
import me.neznamy.tab.api.TabFeature;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.api.placeholder.ServerPlaceholder;
@@ -53,7 +50,7 @@ public class ServerPlaceholderImpl extends TabPlaceholder implements ServerPlace
if (identifier.equals(newValue) && lastValue == null) {
lastValue = identifier;
}
if (!TabConstants.Placeholder.ERROR_VALUE.equals(newValue) && !identifier.equals(newValue) && (lastValue == null || !lastValue.equals(newValue))) {
if (!"ERROR".equals(newValue) && !identifier.equals(newValue) && (lastValue == null || !lastValue.equals(newValue))) {
lastValue = newValue;
for (TabPlayer player : TAB.getInstance().getOnlinePlayers()) {
updateParents(player);
@@ -116,14 +113,10 @@ public class ServerPlaceholderImpl extends TabPlaceholder implements ServerPlace
@Override
public Object request() {
try {
return placeholderFutureThreadPool.submit(supplier::get).get(
TabConstants.Placeholder.PLACEHOLDER_RETRIEVE_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
TAB.getInstance().getErrorManager().criticalError("Placeholder " + identifier + " took longer than " +
TabConstants.Placeholder.PLACEHOLDER_RETRIEVE_TIMEOUT + "ms to retrieve value, aborting.", null);
return supplier.get();
} catch (Throwable t) {
TAB.getInstance().getErrorManager().placeholderError("Server placeholder " + identifier + " generated an error", t);
return "ERROR";
}
return TabConstants.Placeholder.ERROR_VALUE;
}
}
@@ -1,6 +1,5 @@
package me.neznamy.tab.shared.placeholders;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import me.neznamy.tab.api.TabAPI;
import me.neznamy.tab.api.TabConstants;
import me.neznamy.tab.api.TabPlayer;
@@ -9,17 +8,12 @@ import me.neznamy.tab.shared.TAB;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* General collection of variables and functions shared between all placeholder types
*/
public abstract class TabPlaceholder implements Placeholder {
/** Thread pool for submitting placeholder requests with a timeout */
protected static ExecutorService placeholderFutureThreadPool = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("TAB Placeholder retrieving thread %d").build());
/** Refresh interval of the placeholder */
private final int refresh;