getEntitySuggestions() {
+ return entitySuggestions;
}
private static void prepareLists() {
+ //breaking an item means running its durability negative
itemBrokenSuggestions = Arrays.stream(Material.values())
.parallel()
.filter(Material::isItem)
@@ -43,7 +44,8 @@ public final class TabCompleteHelper {
.map(String::toLowerCase)
.collect(Collectors.toList());
- entityKilledSuggestions = Arrays.stream(EntityType.values())
+ //the only statistics dealing with entities are killed_entity and entity_killed_by
+ entitySuggestions = Arrays.stream(EntityType.values())
.parallel()
.filter(EntityType::isAlive)
.map(EntityType::toString)
diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java
index 75387af..ff4ad31 100644
--- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java
+++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java
@@ -13,7 +13,7 @@ import java.io.File;
public class ConfigHandler {
private static Main plugin;
- private static double configVersion;
+ private static int configVersion;
private File configFile;
private FileConfiguration config;
@@ -35,7 +35,7 @@ public class ConfigHandler {
PlayerStats 1.3: "config-version" is 3.
PlayerStats 1.4: "config-version" is 4.
*/
private void checkConfigVersion() {
- if (!config.contains("config-version") || config.getDouble("config-version") != configVersion) {
+ if (!config.contains("config-version") || config.getInt("config-version") != configVersion) {
new ConfigUpdateHandler(plugin, configFile, configVersion);
reloadConfig();
}
diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigUpdateHandler.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigUpdateHandler.java
index a614420..a067623 100644
--- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigUpdateHandler.java
+++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigUpdateHandler.java
@@ -11,7 +11,7 @@ import com.tchristofferson.configupdater.ConfigUpdater;
public class ConfigUpdateHandler {
/** Add new key-value pairs to the config without losing comments, using tchristofferson's Config-Updater */
- public ConfigUpdateHandler(Main plugin, File configFile, double configVersion) {
+ public ConfigUpdateHandler(Main plugin, File configFile, int configVersion) {
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
updateTopListDefault(configuration);
updateDefaultColors(configuration);
diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java
index 0ebbc02..31e0287 100644
--- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java
+++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java
@@ -16,4 +16,4 @@ public final class FontUtils {
return (int) Math.round((130.0 - (MinecraftFont.Font.getWidth(displayText) * 1.5))/2);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/statistic/StatThread.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/statistic/StatThread.java
index afecbe1..b42982d 100644
--- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/statistic/StatThread.java
+++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/statistic/StatThread.java
@@ -70,13 +70,13 @@ public class StatThread extends Thread {
}
}
- Target selection = request.getSelection();
long lastCalc = ThreadManager.getLastRecordedCalcTime();
if (lastCalc > 2000) {
adventure.sender(request.getCommandSender()).sendMessage(
messageWriter.waitAMoment(lastCalc > 20000, request.isBukkitConsoleSender()));
}
+ Target selection = request.getSelection();
TextComponent statResult;
try {
statResult = switch (selection) {
diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/utils/EnumHandler.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/utils/EnumHandler.java
index 1a581ca..08259f9 100644
--- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/utils/EnumHandler.java
+++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/utils/EnumHandler.java
@@ -12,6 +12,11 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+/** This class deals with Bukkit Enumerators. It holds private lists of all
+ block-, item-, entity- and statistic-names, and has one big list of all
+ possible sub-statistic-entries (block/item/entity). It can give the names
+ of all aforementioned enums, check if something is a valid enum constant,
+ and turn a name into its corresponding enum constant. */
public final class EnumHandler {
private final static List blockNames;
@@ -50,11 +55,22 @@ public final class EnumHandler {
.collect(Collectors.toList());
}
+ /** Returns all block-names in lowercase */
+ public static List getBlockNames() {
+ return blockNames;
+ }
+
+ /** Returns all item-names in lowercase*/
public static List getItemNames() {
return itemNames;
}
- /** Returns corresponding item enum constant for an itemName
+ /** Returns all statistic-names in lowercase */
+ public static List getStatNames() {
+ return statNames;
+ }
+
+ /** Returns the corresponding Material enum constant for an itemName
@param itemName String, case-insensitive
@return Material enum constant, uppercase */
public static @Nullable Material getItemEnum(String itemName) {
@@ -64,12 +80,7 @@ public final class EnumHandler {
return (item != null && item.isItem()) ? item : null;
}
- /** Returns all entitytype names in lowercase */
- public static List getEntityNames() {
- return entityNames;
- }
-
- /** Returns corresponding EntityType enum constant for an entityName
+ /** Returns the corresponding EntityType enum constant for an entityName
@param entityName String, case-insensitive
@return EntityType enum constant, uppercase */
public static @Nullable EntityType getEntityEnum(String entityName) {
@@ -81,12 +92,7 @@ public final class EnumHandler {
}
}
- /** Returns all block names in lowercase */
- public static List getBlockNames() {
- return blockNames;
- }
-
- /** Returns corresponding block enum constant for a materialName
+ /** Returns the corresponding Material enum constant for a materialName
@param materialName String, case-insensitive
@return Material enum constant, uppercase */
public static @Nullable Material getBlockEnum(String materialName) {
@@ -96,6 +102,17 @@ public final class EnumHandler {
return (block != null && block.isBlock()) ? block : null;
}
+ /** Returns the statistic enum constant, or null if that failed.
+ @param statName String, case-insensitive */
+ public static @Nullable Statistic getStatEnum(@NotNull String statName) {
+ try {
+ return Statistic.valueOf(statName.toUpperCase());
+ }
+ catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
/** Checks if string is a valid statistic
@param statName String, case-insensitive */
public static boolean isStatistic(@NotNull String statName) {
@@ -108,20 +125,10 @@ public final class EnumHandler {
statName.equalsIgnoreCase(Statistic.KILL_ENTITY.toString());
}
- /** Returns the names of all general statistics in lowercase */
- public static List getStatNames() {
- return statNames;
- }
-
- /** Returns the statistic enum constant, or null if that failed.
- @param statName String, case-insensitive */
- public static @Nullable Statistic getStatEnum(@NotNull String statName) {
- try {
- return Statistic.valueOf(statName.toUpperCase());
- }
- catch (IllegalArgumentException e) {
- return null;
- }
+ /** Checks if this statistic is a subStatEntry, meaning it is a block, item or entity
+ @param statName String, case-insensitive*/
+ public static boolean isSubStatEntry(@NotNull String statName) {
+ return subStatNames.contains(statName.toLowerCase());
}
/** Returns "block", "entity", "item", or "sub-statistic" if the provided Type is null. */
@@ -135,10 +142,4 @@ public final class EnumHandler {
}
return subStat;
}
-
- /** Checks if this statistic is a subStatEntry, meaning it is a block, item or entity
- @param statName String, case-insensitive*/
- public static boolean isSubStatEntry(@NotNull String statName) {
- return subStatNames.contains(statName.toLowerCase());
- }
}
\ No newline at end of file
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index b501218..ece4331 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,7 +1,7 @@
# ------------------------------------------------------------------------------------------------------ #
# PlayerStats Configuration #
# ------------------------------------------------------------------------------------------------------ #
-config-version: 5
+config-version: 6
# # ------------------------------- # #
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index edeef0d..f8408b2 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
main: com.gmail.artemis.the.gr8.playerstats.Main
name: PlayerStats
-version: 1.5
+version: 1.6
api-version: 1.18
description: adds commands to view player statistics in chat
author: Artemis_the_gr8