diff --git a/pom.xml b/pom.xml
index 7c98403..3a48c2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
pk.ajneb97
PlayerKits2
- 1.21.1
+ 1.21.2
21
diff --git a/src/main/java/pk/ajneb97/libs/titles/TitleAPI.java b/src/main/java/pk/ajneb97/libs/titles/TitleAPI.java
index 54eebb2..13913f9 100644
--- a/src/main/java/pk/ajneb97/libs/titles/TitleAPI.java
+++ b/src/main/java/pk/ajneb97/libs/titles/TitleAPI.java
@@ -44,7 +44,7 @@ public class TitleAPI implements Listener {
}
if(PlayerKitsAPI.getPlugin().getConfigsManager().getMainConfigManager().isUseMiniMessage()){
- MiniMessageUtils.title(player,title,subtitle);
+ MiniMessageUtils.title(player,title,subtitle,fadeIn,stay,fadeOut);
}else{
player.sendTitle(MessagesManager.getLegacyColoredMessage(title), MessagesManager.getLegacyColoredMessage(subtitle), fadeIn, stay, fadeOut);
}
diff --git a/src/main/java/pk/ajneb97/managers/InventoryManager.java b/src/main/java/pk/ajneb97/managers/InventoryManager.java
index 77799d7..ec4c77b 100644
--- a/src/main/java/pk/ajneb97/managers/InventoryManager.java
+++ b/src/main/java/pk/ajneb97/managers/InventoryManager.java
@@ -347,20 +347,24 @@ public class InventoryManager {
newStatus = "default";
}
+ kitItem = kitItem.clone();
+
boolean useMiniMessage = plugin.getConfigsManager().getMainConfigManager().isUseMiniMessage();
if(newStatus.equals(currentStatus) && currentItem != null){
// Name and Lore update
+ kitItemManager.replaceVariables(kitItem,variablesToReplace,player);
+
ItemMeta meta = currentItem.getItemMeta();
String name = kitItem.getName();
if(name != null){
- name = OtherUtils.replaceGlobalVariables(name,player,plugin);
if(useMiniMessage){
MiniMessageUtils.setItemName(meta,name);
}else{
meta.setDisplayName(MessagesManager.getLegacyColoredMessage(name));
}
}
+
List lore = kitItem.getLore();
if(lore != null) {
List loreCopy = new ArrayList<>(lore);
@@ -374,13 +378,12 @@ public class InventoryManager {
meta.setLore(loreCopy);
}
}
- currentItem.setItemMeta(meta);
- kitItemManager.replaceVariables(currentItem,variablesToReplace);
+ currentItem.setItemMeta(meta);
}else{
// Full update
+ kitItemManager.replaceVariables(kitItem,variablesToReplace,player);
ItemStack item = kitItemManager.createItemFromKitItem(kitItem,player,kit);
- kitItemManager.replaceVariables(item,variablesToReplace);
item = ItemUtils.setTagStringItem(plugin,item, "playerkits_kit", kitName);
item = ItemUtils.setTagStringItem(plugin,item, "playerkits_kit_status", newStatus);
inv.setItem(slot,item);
diff --git a/src/main/java/pk/ajneb97/managers/KitItemManager.java b/src/main/java/pk/ajneb97/managers/KitItemManager.java
index dc9c015..2f4bcc5 100644
--- a/src/main/java/pk/ajneb97/managers/KitItemManager.java
+++ b/src/main/java/pk/ajneb97/managers/KitItemManager.java
@@ -811,39 +811,26 @@ public class KitItemManager {
return kitItem;
}
- public void replaceVariables(ItemStack item, ArrayList variables){
- boolean useMiniMessage = plugin.getConfigsManager().getMainConfigManager().isUseMiniMessage();
- if(item.hasItemMeta()){
- ItemMeta meta = item.getItemMeta();
- if(meta.hasDisplayName()){
- if(useMiniMessage){
- MiniMessageUtils.replaceVariablesItemName(meta,variables);
- }else{
- String newName = meta.getDisplayName();
- for(KitVariable variable : variables){
- newName = newName.replace(variable.getVariable(),variable.getValue());
- }
- meta.setDisplayName(MessagesManager.getLegacyColoredMessage(newName));
- }
+ public void replaceVariables(KitItem commonItem, ArrayList variables, Player player){
+ if(commonItem.getName() != null){
+ String newName = commonItem.getName();
+ for(KitVariable variable : variables){
+ newName = newName.replace(variable.getVariable(),variable.getValue());
}
+ newName = OtherUtils.replaceGlobalVariables(newName,player,plugin);
+ commonItem.setName(newName);
+ }
- if(meta.hasLore()){
- if(useMiniMessage){
- MiniMessageUtils.replaceVariablesItemLore(meta,variables);
- }else{
- List lore = meta.getLore();
- for(int i=0;i lore = commonItem.getLore();
+ for(int i=0;iWhat is my plugin id?
*/
- public Metrics(JavaPlugin plugin, int serviceId) {
+ public Metrics(Plugin plugin, int serviceId) {
this.plugin = plugin;
// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
@@ -71,7 +94,8 @@ public class Metrics {
+ "many people use their plugin and their total player count. It's recommended to keep bStats\n"
+ "enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n"
+ "performance penalty associated with having metrics enabled, and data sent to bStats is fully\n"
- + "anonymous.")
+ + "anonymous.\n"
+ + "Learn more here: https://bstats.org/docs/server-owners")
.copyDefaults(true);
try {
config.save(configFile);
@@ -84,21 +108,36 @@ public class Metrics {
boolean logErrors = config.getBoolean("logFailedRequests", false);
boolean logSentData = config.getBoolean("logSentData", false);
boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false);
+ boolean isFolia = false;
+ try {
+ isFolia = Class.forName("io.papermc.paper.threadedregions.RegionizedServer") != null;
+ } catch (Exception e) {
+ }
metricsBase =
- new MetricsBase(
+ new // See https://github.com/Bastian/bstats-metrics/pull/126
+ // See https://github.com/Bastian/bstats-metrics/pull/126
+ // See https://github.com/Bastian/bstats-metrics/pull/126
+ // See https://github.com/Bastian/bstats-metrics/pull/126
+ // See https://github.com/Bastian/bstats-metrics/pull/126
+ // See https://github.com/Bastian/bstats-metrics/pull/126
+ // See https://github.com/Bastian/bstats-metrics/pull/126
+ MetricsBase(
"bukkit",
serverUUID,
serviceId,
enabled,
this::appendPlatformData,
this::appendServiceData,
- submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
+ isFolia
+ ? null
+ : submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
plugin::isEnabled,
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
(message) -> this.plugin.getLogger().log(Level.INFO, message),
logErrors,
logSentData,
- logResponseStatusText);
+ logResponseStatusText,
+ false);
}
/** Shuts down the underlying scheduler service. */
@@ -149,7 +188,7 @@ public class Metrics {
public static class MetricsBase {
/** The version of the Metrics class. */
- public static final String METRICS_VERSION = "3.0.2";
+ public static final String METRICS_VERSION = "3.2.1";
private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s";
@@ -203,6 +242,7 @@ public class Metrics {
* @param logErrors Whether or not errors should be logged.
* @param logSentData Whether or not the sent data should be logged.
* @param logResponseStatusText Whether or not the response status text should be logged.
+ * @param skipRelocateCheck Whether or not the relocate check should be skipped.
*/
public MetricsBase(
String platform,
@@ -217,9 +257,16 @@ public class Metrics {
Consumer infoLogger,
boolean logErrors,
boolean logSentData,
- boolean logResponseStatusText) {
+ boolean logResponseStatusText,
+ boolean skipRelocateCheck) {
ScheduledThreadPoolExecutor scheduler =
- new ScheduledThreadPoolExecutor(1, task -> new Thread(task, "bStats-Metrics"));
+ new ScheduledThreadPoolExecutor(
+ 1,
+ task -> {
+ Thread thread = new Thread(task, "bStats-Metrics");
+ thread.setDaemon(true);
+ return thread;
+ });
// We want delayed tasks (non-periodic) that will execute in the future to be
// cancelled when the scheduler is shutdown.
// Otherwise, we risk preventing the server from shutting down even when
@@ -239,7 +286,9 @@ public class Metrics {
this.logErrors = logErrors;
this.logSentData = logSentData;
this.logResponseStatusText = logResponseStatusText;
- checkRelocation();
+ if (!skipRelocateCheck) {
+ checkRelocation();
+ }
if (enabled) {
// WARNING: Removing the option to opt-out will get your plugin banned from
// bStats
@@ -303,7 +352,6 @@ public class Metrics {
scheduler.execute(
() -> {
try {
- // Send the data
sendData(data);
} catch (Exception e) {
// Something went wrong! :(
@@ -384,9 +432,43 @@ public class Metrics {
}
}
- public static class SimplePie extends CustomChart {
+ public abstract static class CustomChart {
- private final Callable callable;
+ private final String chartId;
+
+ protected CustomChart(String chartId) {
+ if (chartId == null) {
+ throw new IllegalArgumentException("chartId must not be null");
+ }
+ this.chartId = chartId;
+ }
+
+ public JsonObjectBuilder.JsonObject getRequestJsonObject(
+ BiConsumer errorLogger, boolean logErrors) {
+ JsonObjectBuilder builder = new JsonObjectBuilder();
+ builder.appendField("chartId", chartId);
+ try {
+ JsonObjectBuilder.JsonObject data = getChartData();
+ if (data == null) {
+ // If the data is null we don't send the chart.
+ return null;
+ }
+ builder.appendField("data", data);
+ } catch (Throwable t) {
+ if (logErrors) {
+ errorLogger.accept("Failed to get data for custom chart with id " + chartId, t);
+ }
+ return null;
+ }
+ return builder.build();
+ }
+
+ protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception;
+ }
+
+ public static class SingleLineChart extends CustomChart {
+
+ private final Callable callable;
/**
* Class constructor.
@@ -394,15 +476,15 @@ public class Metrics {
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
- public SimplePie(String chartId, Callable callable) {
+ public SingleLineChart(String chartId, Callable callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
- String value = callable.call();
- if (value == null || value.isEmpty()) {
+ int value = callable.call();
+ if (value == 0) {
// Null = skip the chart
return null;
}
@@ -410,6 +492,120 @@ public class Metrics {
}
}
+ public static class DrilldownPie extends CustomChart {
+
+ private final Callable