Improved config explanations, improved shading and relocating for potential use on Minecraft 1.17 (#47), more minor improvements

This commit is contained in:
Artemis-the-gr8 2022-07-12 16:26:47 +02:00
parent aa8f31c6fb
commit 8619b0af4e
10 changed files with 90 additions and 44 deletions

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.artemis-the-gr8</groupId>
<groupId>com.gmail.artemis.the.gr8</groupId>
<artifactId>PlayerStats</artifactId>
<version>1.5</version>
<version>1.6</version>
<build>
<plugins>
<plugin>
@ -16,7 +16,7 @@
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
@ -36,6 +36,16 @@
<exclude>org.jetbrains:annotations</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>com.gmail.artemis.the.gr8.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>com.tchristofferson</pattern>
<shadedPattern>com.gmail.artemis.the.gr8.tchristofferson</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
@ -45,6 +55,18 @@
<exclude>images/**</exclude>
</excludes>
</filter>
<filter>
<artifact>net.kyori:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.tchristofferson:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>

26
pom.xml
View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.artemis-the-gr8</groupId>
<groupId>com.gmail.artemis.the.gr8</groupId>
<artifactId>PlayerStats</artifactId>
<version>1.6</version>
@ -85,7 +85,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
@ -106,6 +106,16 @@
<exclude>org.jetbrains:annotations</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>com.gmail.artemis.the.gr8.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>com.tchristofferson</pattern>
<shadedPattern>com.gmail.artemis.the.gr8.tchristofferson</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
@ -115,6 +125,18 @@
<exclude>images/**</exclude>
</excludes>
</filter>
<filter>
<artifact>net.kyori:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.tchristofferson:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>

View File

@ -7,17 +7,13 @@ import com.gmail.artemis.the.gr8.playerstats.commands.TabCompleter;
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.gmail.artemis.the.gr8.playerstats.listeners.JoinListener;
import com.gmail.artemis.the.gr8.playerstats.msg.MessageWriter;
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
import com.gmail.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public class Main extends JavaPlugin {
private static BukkitAudiences adventure;

View File

@ -2,6 +2,7 @@ package com.gmail.artemis.the.gr8.playerstats.config;
import com.gmail.artemis.the.gr8.playerstats.Main;
import com.gmail.artemis.the.gr8.playerstats.enums.Target;
import com.gmail.artemis.the.gr8.playerstats.msg.MessageWriter;
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;

View File

@ -1,6 +1,7 @@
package com.gmail.artemis.the.gr8.playerstats.config;
import com.gmail.artemis.the.gr8.playerstats.Main;
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
@ -19,8 +20,8 @@ public class ConfigUpdateHandler {
try {
configuration.save(configFile);
ConfigUpdater.update(plugin, configFile.getName(), configFile);
plugin.getLogger().warning("Your config has been updated to version " + configVersion +
". This version includes some slight changes in the default color scheme, but none of your custom settings should have been changed!");
MyLogger.logMsg("Your config has been updated to version " + configVersion +
", but all of your custom settings should still be there!");
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -57,7 +57,7 @@ public class ComponentFactory {
return text(content).color(PluginColor.GRAY.getColor()).decorate(TextDecoration.ITALIC);
}
/** Returns a TextComponents that represents a full message, with [PlayerStats] prepended. */
/** Returns a TextComponents in the style of a default plugin message, with color Medium_Blue. */
public TextComponent messageComponent() {
return text().color(PluginColor.MEDIUM_BLUE.getColor()).build();
}

View File

@ -131,7 +131,7 @@ public class ReloadThread extends Thread {
MyLogger.actionFinished(1);
MyLogger.logTimeTaken("ReloadThread",
("loaded " + offlinePlayerHandler.getOfflinePlayerCount() + " offline players"), time);
("loaded " + playerMap.size() + " offline players"), time);
return playerMap;
}
}

View File

@ -12,7 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.RecursiveAction;
public final class TopStatAction extends RecursiveAction {
public final class StatAction extends RecursiveAction {
private static int threshold;
@ -29,7 +29,7 @@ public final class TopStatAction extends RecursiveAction {
* @param statRequest a validated statRequest
* @param playerStats the ConcurrentHashMap to put the results on
*/
public TopStatAction(OfflinePlayerHandler offlinePlayerHandler, ImmutableList<String> playerNames, StatRequest statRequest, ConcurrentHashMap<String, Integer> playerStats) {
public StatAction(OfflinePlayerHandler offlinePlayerHandler, ImmutableList<String> playerNames, StatRequest statRequest, ConcurrentHashMap<String, Integer> playerStats) {
threshold = ThreadManager.getTaskThreshold();
this.offlinePlayerHandler = offlinePlayerHandler;
@ -46,8 +46,8 @@ public final class TopStatAction extends RecursiveAction {
getStatsDirectly();
}
else {
final TopStatAction subTask1 = new TopStatAction(offlinePlayerHandler, playerNames.subList(0, playerNames.size()/2), request, playerStats);
final TopStatAction subTask2 = new TopStatAction(offlinePlayerHandler, playerNames.subList(playerNames.size()/2, playerNames.size()), request, playerStats);
final StatAction subTask1 = new StatAction(offlinePlayerHandler, playerNames.subList(0, playerNames.size()/2), request, playerStats);
final StatAction subTask2 = new StatAction(offlinePlayerHandler, playerNames.subList(playerNames.size()/2, playerNames.size()), request, playerStats);
//queue and compute all subtasks in the right order
invokeAll(subTask1, subTask2);

View File

@ -118,7 +118,7 @@ public class StatThread extends Thread {
ConcurrentHashMap<String, Integer> playerStats = new ConcurrentHashMap<>(size);
ImmutableList<String> playerNames = ImmutableList.copyOf(offlinePlayerHandler.getOfflinePlayerNames());
TopStatAction task = new TopStatAction(offlinePlayerHandler, playerNames, request, playerStats);
StatAction task = new StatAction(offlinePlayerHandler, playerNames, request, playerStats);
MyLogger.actionCreated(playerNames.size());
ForkJoinPool commonPool = ForkJoinPool.commonPool();

View File

@ -15,7 +15,7 @@ config-version: 6
debug-level: 1
# Whether players have to wait for their lookup to finish before they can request another statistic
# Warning: disabling this could allow players to stress out your server by spamming the stat-command!
# Warning: disabling this could put stress on your server if players spam the stat-command!
only-allow-one-lookup-at-a-time-per-player: true
# Whether statistics can be shared with everyone in chat
@ -45,31 +45,6 @@ translate-to-client-language: true
# Use hover-text for additional info about statistic numbers
enable-hover-text: true
# The unit to display certain statistics in.
# Minecraft measures distance in cm. PlayerStats supports: blocks, cm, m (= blocks), miles, km
distance-unit: blocks
distance-unit-for-hover-text: km
# Minecraft measures damage in 0.5 hearts (1HP). PlayerStats supports: hp, hearts
damage-unit: hearts
damage-unit-for-hover-text: hp
# Minecraft measures time in ticks. With the below settings, PlayerStats will:
# Auto-detect the best maximum unit to use (weeks/days/hours/minutes/seconds) for your players' statistics
# Show a specified amount of additional smaller units (example: "x days" would become "x days, y hours, z minutes")
auto-detect-biggest-time-unit: true
number-of-extra-units: 1
auto-detect-biggest-time-unit-for-hover-text: false
number-of-extra-units-for-hover-text: 0
# If you don't want the unit to be auto-detected, set the auto-detect settings to false and specify your own range here
# If the max and min are the same, only that unit will be displayed
# PlayerStats supports: days, hours, minutes, seconds (and ticks if you want the original number)
biggest-time-unit: days
smallest-time-unit: hours
biggest-time-unit-for-hover-text: hours
smallest-time-unit-for-hover-text: seconds
# Automatically use themed formatting for the duration of certain holidays or festivals
enable-festive-formatting: true
@ -91,6 +66,35 @@ total-server-stat-title: 'Total on'
your-server-name: 'this server'
# # ------------------------------- # #
# # Units # #
# # ------------------------------- # #
# Minecraft measures distance in cm. PlayerStats supports: blocks, cm, m (= blocks), miles, km
distance-unit: blocks
distance-unit-for-hover-text: km
# Minecraft measures damage in 0.5 hearts (1HP). PlayerStats supports: hp, hearts
damage-unit: hearts
damage-unit-for-hover-text: hp
# Minecraft measures time in ticks. With the below settings, PlayerStats will:
# Auto-detect the biggest unit to use (weeks/days/hours/minutes/seconds) for your players' statistics
# Show as many additional smaller units as you choose (so for 3 extra units, "9D" would become "9D 5H 20M")
auto-detect-biggest-time-unit: true
number-of-extra-units: 1
auto-detect-biggest-time-unit-for-hover-text: false
number-of-extra-units-for-hover-text: 0
# To always use the same units, set the auto-detect settings to false and select your own unit range here
# If the biggest and smallest unit are the same, only that unit will be displayed
# PlayerStats supports: days, hours, minutes, seconds (and ticks if you want the original number)
biggest-time-unit: days
smallest-time-unit: hours
biggest-time-unit-for-hover-text: hours
smallest-time-unit-for-hover-text: seconds
# # ------------------------------- # #
# # Color & Style # #
# # ------------------------------- # #