mirror of
https://github.com/itHotL/PlayerStats.git
synced 2024-11-28 12:55:36 +01:00
Separated internal code from api code to improve future maintainability
This commit is contained in:
parent
fc1ac7c07e
commit
c4b963a057
@ -49,7 +49,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<transformers>
|
<transformers>
|
||||||
<transformer>
|
<transformer>
|
||||||
<mainClass>com.artemis.the.gr8.playerstats.Main</mainClass>
|
<mainClass>com.artemis.the.gr8.playerstats.core.Main</mainClass>
|
||||||
</transformer>
|
</transformer>
|
||||||
</transformers>
|
</transformers>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
|
2
pom.xml
2
pom.xml
@ -141,7 +141,7 @@
|
|||||||
<transformers>
|
<transformers>
|
||||||
<transformer
|
<transformer
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<mainClass>com.artemis.the.gr8.playerstats.Main</mainClass>
|
<mainClass>com.artemis.the.gr8.playerstats.core.Main</mainClass>
|
||||||
</transformer>
|
</transformer>
|
||||||
</transformers>
|
</transformers>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.api;
|
package com.artemis.the.gr8.playerstats.api;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.Main;
|
import com.artemis.the.gr8.playerstats.core.Main;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.RequestManager;
|
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -12,8 +11,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* and get an instance of PlayerStats. You can then use this object to
|
* and get an instance of PlayerStats. You can then use this object to
|
||||||
* access any of the further methods.
|
* access any of the further methods.
|
||||||
*
|
*
|
||||||
* @see RequestManager
|
* @see StatManager
|
||||||
* @see StatFormatter
|
* @see StatTextFormatter
|
||||||
|
* @see StatNumberFormatter
|
||||||
*/
|
*/
|
||||||
public interface PlayerStats {
|
public interface PlayerStats {
|
||||||
|
|
||||||
@ -41,5 +41,7 @@ public interface PlayerStats {
|
|||||||
|
|
||||||
StatManager getStatManager();
|
StatManager getStatManager();
|
||||||
|
|
||||||
StatFormatter getFormatter();
|
StatTextFormatter getStatTextFormatter();
|
||||||
|
|
||||||
|
StatNumberFormatter getStatNumberFormatter();
|
||||||
}
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package com.artemis.the.gr8.playerstats.api;
|
package com.artemis.the.gr8.playerstats.api;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.statistic.RequestManager;
|
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.artemis.the.gr8.playerstats.api;
|
package com.artemis.the.gr8.playerstats.api;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatResult;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
public interface StatManager {
|
public interface StatManager {
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.artemis.the.gr8.playerstats.api;
|
||||||
|
|
||||||
|
import com.artemis.the.gr8.playerstats.api.enums.Unit;
|
||||||
|
|
||||||
|
public interface StatNumberFormatter {
|
||||||
|
|
||||||
|
String formatDamageNumber(long number, Unit statUnit);
|
||||||
|
|
||||||
|
String formatDistanceNumber(long number, Unit statUnit);
|
||||||
|
|
||||||
|
String formatTimeNumber(long number, Unit biggestTimeUnit, Unit smallestTimeUnit);
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.statistic;
|
package com.artemis.the.gr8.playerstats.api;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.StatManager;
|
import com.artemis.the.gr8.playerstats.api.enums.Target;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Target;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -44,6 +43,51 @@ public abstract class StatRequest<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void configureForPlayer(String playerName) {
|
||||||
|
this.settings.target = Target.PLAYER;
|
||||||
|
this.settings.playerName = playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureForServer() {
|
||||||
|
this.settings.target = Target.SERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureForTop(int topListSize) {
|
||||||
|
this.settings.target = Target.TOP;
|
||||||
|
this.settings.topListSize = topListSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureUntyped(@NotNull Statistic statistic) {
|
||||||
|
if (statistic.getType() != Statistic.Type.UNTYPED) {
|
||||||
|
throw new IllegalArgumentException("This statistic is not of Type.Untyped");
|
||||||
|
}
|
||||||
|
this.settings.statistic = statistic;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureBlockOrItemType(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException {
|
||||||
|
Statistic.Type type = statistic.getType();
|
||||||
|
if (type == Statistic.Type.BLOCK && material.isBlock()) {
|
||||||
|
this.settings.block = material;
|
||||||
|
}
|
||||||
|
else if (type == Statistic.Type.ITEM && material.isItem()){
|
||||||
|
this.settings.item = material;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalArgumentException("Either this statistic is not of Type.Block or Type.Item, or no valid block or item has been provided");
|
||||||
|
}
|
||||||
|
this.settings.statistic = statistic;
|
||||||
|
this.settings.subStatEntryName = material.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureEntityType(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException {
|
||||||
|
if (statistic.getType() != Statistic.Type.ENTITY) {
|
||||||
|
throw new IllegalArgumentException("This statistic is not of Type.Entity");
|
||||||
|
}
|
||||||
|
this.settings.statistic = statistic;
|
||||||
|
this.settings.entity = entityType;
|
||||||
|
this.settings.subStatEntryName = entityType.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasMatchingSubStat() {
|
private boolean hasMatchingSubStat() {
|
||||||
switch (settings.statistic.getType()) {
|
switch (settings.statistic.getType()) {
|
||||||
case BLOCK -> {
|
case BLOCK -> {
|
||||||
@ -61,6 +105,7 @@ public abstract class StatRequest<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final class Settings {
|
public static final class Settings {
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private Statistic statistic;
|
private Statistic statistic;
|
||||||
@ -80,50 +125,6 @@ public abstract class StatRequest<T> {
|
|||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
void configureForPlayer(String playerName) {
|
|
||||||
this.target = Target.PLAYER;
|
|
||||||
this.playerName = playerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void configureForServer() {
|
|
||||||
this.target = Target.SERVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
void configureForTop(int topListSize) {
|
|
||||||
this.target = Target.TOP;
|
|
||||||
this.topListSize = topListSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void configureUntyped(@NotNull Statistic statistic) {
|
|
||||||
if (statistic.getType() != Statistic.Type.UNTYPED) {
|
|
||||||
throw new IllegalArgumentException("This statistic is not of Type.Untyped");
|
|
||||||
}
|
|
||||||
this.statistic = statistic;
|
|
||||||
}
|
|
||||||
|
|
||||||
void configureBlockOrItemType(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException {
|
|
||||||
Statistic.Type type = statistic.getType();
|
|
||||||
if (type == Statistic.Type.BLOCK && material.isBlock()) {
|
|
||||||
this.block = material;
|
|
||||||
}
|
|
||||||
else if (type == Statistic.Type.ITEM && material.isItem()){
|
|
||||||
this.item = material;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new IllegalArgumentException("Either this statistic is not of Type.Block or Type.Item, or no valid block or item has been provided");
|
|
||||||
}
|
|
||||||
this.statistic = statistic;
|
|
||||||
this.subStatEntryName = material.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void configureEntityType(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException {
|
|
||||||
if (statistic.getType() != Statistic.Type.ENTITY) {
|
|
||||||
throw new IllegalArgumentException("This statistic is not of Type.Entity");
|
|
||||||
}
|
|
||||||
this.statistic = statistic;
|
|
||||||
this.entity = entityType;
|
|
||||||
this.subStatEntryName = entityType.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull CommandSender getCommandSender() {
|
public @NotNull CommandSender getCommandSender() {
|
||||||
return sender;
|
return sender;
|
@ -1,6 +1,5 @@
|
|||||||
package com.artemis.the.gr8.playerstats.statistic;
|
package com.artemis.the.gr8.playerstats.api;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.StatFormatter;
|
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ import net.kyori.adventure.text.TextComponent;
|
|||||||
* same information in String-format. Don't use Adventure's <code>#content()</code>
|
* same information in String-format. Don't use Adventure's <code>#content()</code>
|
||||||
* or <code>#toString()</code> methods on the Components - those won't get the actual
|
* or <code>#toString()</code> methods on the Components - those won't get the actual
|
||||||
* message. And finally, if you want the results to be formatted differently,
|
* message. And finally, if you want the results to be formatted differently,
|
||||||
* you can get an instance of the {@link StatFormatter}.
|
* you can get an instance of the {@link StatTextFormatter}.
|
||||||
*/
|
*/
|
||||||
public record StatResult<T>(T value, TextComponent formattedComponent, String formattedString) {
|
public record StatResult<T>(T value, TextComponent formattedComponent, String formattedString) {
|
||||||
|
|
@ -1,8 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.api;
|
package com.artemis.the.gr8.playerstats.api;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.enums.Unit;
|
import com.artemis.the.gr8.playerstats.api.enums.Unit;
|
||||||
import com.artemis.the.gr8.playerstats.msg.msgutils.NumberFormatter;
|
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatResult;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -15,16 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
* @see StatResult
|
* @see StatResult
|
||||||
*/
|
*/
|
||||||
public interface StatFormatter {
|
public interface StatTextFormatter {
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a {@link NumberFormatter} to format raw numbers into something more readable.
|
|
||||||
*
|
|
||||||
* @return the <code>NumberFormatter</code>
|
|
||||||
*/
|
|
||||||
default NumberFormatter getNumberFormatter() {
|
|
||||||
return new NumberFormatter();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns a TextComponent into its String representation. This method is equipped
|
* Turns a TextComponent into its String representation. This method is equipped
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.enums;
|
package com.artemis.the.gr8.playerstats.api.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This enum represents the targets PlayerStats accepts
|
* This enum represents the targets PlayerStats accepts
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.enums;
|
package com.artemis.the.gr8.playerstats.api.enums;
|
||||||
|
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
@ -1,18 +1,20 @@
|
|||||||
package com.artemis.the.gr8.playerstats;
|
package com.artemis.the.gr8.playerstats.core;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.PlayerStats;
|
import com.artemis.the.gr8.playerstats.api.PlayerStats;
|
||||||
import com.artemis.the.gr8.playerstats.api.StatFormatter;
|
import com.artemis.the.gr8.playerstats.api.StatNumberFormatter;
|
||||||
|
import com.artemis.the.gr8.playerstats.api.StatTextFormatter;
|
||||||
import com.artemis.the.gr8.playerstats.api.StatManager;
|
import com.artemis.the.gr8.playerstats.api.StatManager;
|
||||||
import com.artemis.the.gr8.playerstats.commands.*;
|
import com.artemis.the.gr8.playerstats.core.commands.*;
|
||||||
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
|
import com.artemis.the.gr8.playerstats.core.msg.msgutils.NumberFormatter;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.RequestManager;
|
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.core.statrequest.RequestManager;
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.listeners.JoinListener;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
|
import com.artemis.the.gr8.playerstats.core.listeners.JoinListener;
|
||||||
import com.artemis.the.gr8.playerstats.share.ShareManager;
|
import com.artemis.the.gr8.playerstats.core.msg.msgutils.LanguageKeyHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.sharing.ShareManager;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
@ -176,7 +178,13 @@ public final class Main extends JavaPlugin implements PlayerStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatFormatter getFormatter() {
|
public StatTextFormatter getStatTextFormatter() {
|
||||||
return outputManager.getMainMessageBuilder();
|
return outputManager.getMainMessageBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract(" -> new")
|
||||||
|
@Override
|
||||||
|
public @NotNull StatNumberFormatter getStatNumberFormatter() {
|
||||||
|
return new NumberFormatter();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package com.artemis.the.gr8.playerstats.commands;
|
package com.artemis.the.gr8.playerstats.core.commands;
|
||||||
|
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
@ -1,6 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.commands;
|
package com.artemis.the.gr8.playerstats.core.commands;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
|
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
@ -1,10 +1,10 @@
|
|||||||
package com.artemis.the.gr8.playerstats.commands;
|
package com.artemis.the.gr8.playerstats.core.commands;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.share.ShareManager;
|
import com.artemis.the.gr8.playerstats.core.sharing.ShareManager;
|
||||||
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
|
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.share.StoredResult;
|
import com.artemis.the.gr8.playerstats.core.sharing.StoredResult;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
@ -1,14 +1,17 @@
|
|||||||
package com.artemis.the.gr8.playerstats.commands;
|
package com.artemis.the.gr8.playerstats.core.commands;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
|
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
|
||||||
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
|
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Target;
|
import com.artemis.the.gr8.playerstats.api.enums.Target;
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.*;
|
import com.artemis.the.gr8.playerstats.core.statrequest.PlayerStatRequest;
|
||||||
import com.artemis.the.gr8.playerstats.utils.EnumHandler;
|
import com.artemis.the.gr8.playerstats.core.statrequest.ServerStatRequest;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.statrequest.TopStatRequest;
|
||||||
|
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
|
||||||
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
@ -1,7 +1,7 @@
|
|||||||
package com.artemis.the.gr8.playerstats.commands;
|
package com.artemis.the.gr8.playerstats.core.commands;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.utils.EnumHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
@ -1,9 +1,9 @@
|
|||||||
package com.artemis.the.gr8.playerstats.config;
|
package com.artemis.the.gr8.playerstats.core.config;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.enums.Target;
|
import com.artemis.the.gr8.playerstats.api.enums.Target;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Unit;
|
import com.artemis.the.gr8.playerstats.api.enums.Unit;
|
||||||
import com.artemis.the.gr8.playerstats.utils.FileHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.FileHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.config;
|
package com.artemis.the.gr8.playerstats.core.config;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.enums;
|
package com.artemis.the.gr8.playerstats.core.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the debugging level that PlayerStats can use.
|
* Represents the debugging level that PlayerStats can use.
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.enums;
|
package com.artemis.the.gr8.playerstats.core.enums;
|
||||||
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.enums;
|
package com.artemis.the.gr8.playerstats.core.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All standard messages PlayerStats can send as feedback.
|
* All standard messages PlayerStats can send as feedback.
|
@ -1,6 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.listeners;
|
package com.artemis.the.gr8.playerstats.core.listeners;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
|
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
@ -1,14 +1,14 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg;
|
package com.artemis.the.gr8.playerstats.core.msg;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.StatFormatter;
|
import com.artemis.the.gr8.playerstats.api.StatTextFormatter;
|
||||||
import com.artemis.the.gr8.playerstats.msg.components.*;
|
import com.artemis.the.gr8.playerstats.core.msg.components.*;
|
||||||
import com.artemis.the.gr8.playerstats.msg.msgutils.*;
|
import com.artemis.the.gr8.playerstats.core.msg.msgutils.*;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import com.artemis.the.gr8.playerstats.utils.EnumHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Target;
|
import com.artemis.the.gr8.playerstats.api.enums.Target;
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Unit;
|
import com.artemis.the.gr8.playerstats.api.enums.Unit;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
@ -34,11 +34,10 @@ import static net.kyori.adventure.text.Component.*;
|
|||||||
* @see PrideComponentFactory
|
* @see PrideComponentFactory
|
||||||
* @see BukkitConsoleComponentFactory
|
* @see BukkitConsoleComponentFactory
|
||||||
*/
|
*/
|
||||||
public final class MessageBuilder implements StatFormatter {
|
public final class MessageBuilder implements StatTextFormatter {
|
||||||
|
|
||||||
private final ConfigHandler config;
|
private final ConfigHandler config;
|
||||||
private boolean useHoverText;
|
private final boolean useHoverText;
|
||||||
private boolean isConsoleBuilder;
|
|
||||||
|
|
||||||
private final ComponentFactory componentFactory;
|
private final ComponentFactory componentFactory;
|
||||||
private final LanguageKeyHandler languageKeyHandler;
|
private final LanguageKeyHandler languageKeyHandler;
|
||||||
@ -50,7 +49,11 @@ public final class MessageBuilder implements StatFormatter {
|
|||||||
languageKeyHandler = LanguageKeyHandler.getInstance();
|
languageKeyHandler = LanguageKeyHandler.getInstance();
|
||||||
componentFactory = factory;
|
componentFactory = factory;
|
||||||
|
|
||||||
|
if (componentFactory.isConsoleFactory()) {
|
||||||
|
useHoverText = false;
|
||||||
|
} else {
|
||||||
useHoverText = config.useHoverText();
|
useHoverText = config.useHoverText();
|
||||||
|
}
|
||||||
formatter = new NumberFormatter();
|
formatter = new NumberFormatter();
|
||||||
serializer = new ComponentSerializer();
|
serializer = new ComponentSerializer();
|
||||||
}
|
}
|
||||||
@ -65,18 +68,6 @@ public final class MessageBuilder implements StatFormatter {
|
|||||||
return new MessageBuilder(factory);
|
return new MessageBuilder(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether this {@link MessageBuilder} should use hoverText.
|
|
||||||
* By default, this follows the setting specified in the {@link ConfigHandler}.
|
|
||||||
*/
|
|
||||||
public void toggleHoverUse(boolean desiredSetting) {
|
|
||||||
useHoverText = desiredSetting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConsoleBuilder(boolean isConsoleBuilder) {
|
|
||||||
this.isConsoleBuilder = isConsoleBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String textComponentToString(TextComponent component) {
|
public @NotNull String textComponentToString(TextComponent component) {
|
||||||
return serializer.getTranslatableComponentSerializer().serialize(component);
|
return serializer.getTranslatableComponentSerializer().serialize(component);
|
||||||
@ -186,7 +177,7 @@ public final class MessageBuilder implements StatFormatter {
|
|||||||
|
|
||||||
public TextComponent helpMsg() {
|
public TextComponent helpMsg() {
|
||||||
int listSize = config.getTopListMaxSize();
|
int listSize = config.getTopListMaxSize();
|
||||||
if (!isConsoleBuilder && useHoverText) {
|
if (useHoverText) {
|
||||||
return HelpMessage.constructHoverMsg(componentFactory, listSize);
|
return HelpMessage.constructHoverMsg(componentFactory, listSize);
|
||||||
} else {
|
} else {
|
||||||
return HelpMessage.constructPlainMsg(componentFactory, listSize);
|
return HelpMessage.constructPlainMsg(componentFactory, listSize);
|
||||||
@ -638,16 +629,10 @@ public final class MessageBuilder implements StatFormatter {
|
|||||||
*/
|
*/
|
||||||
private @NotNull TextComponent getDamageUnitComponent(Unit unit, Target target) {
|
private @NotNull TextComponent getDamageUnitComponent(Unit unit, Target target) {
|
||||||
if (unit == Unit.HEART) {
|
if (unit == Unit.HEART) {
|
||||||
TextComponent heartUnit;
|
TextComponent heartUnit = useHoverText ?
|
||||||
if (isConsoleBuilder) {
|
componentFactory.heartBetweenBracketsWithHoverText() :
|
||||||
heartUnit = componentFactory.consoleHeart();
|
componentFactory.heartBetweenBrackets();
|
||||||
} else if (useHoverText) {
|
return Component.space().append(heartUnit);
|
||||||
heartUnit = componentFactory.clientHeartWithHoverText();
|
|
||||||
} else {
|
|
||||||
heartUnit = componentFactory.clientHeart(false);
|
|
||||||
}
|
|
||||||
return Component.space()
|
|
||||||
.append(heartUnit);
|
|
||||||
}
|
}
|
||||||
return Component.space()
|
return Component.space()
|
||||||
.append(componentFactory.statUnit(unit.getLabel(), target));
|
.append(componentFactory.statUnit(unit.getLabel(), target));
|
||||||
@ -702,7 +687,7 @@ public final class MessageBuilder implements StatFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getNumberOfDotsToAlign(String displayText) {
|
private int getNumberOfDotsToAlign(String displayText) {
|
||||||
if (isConsoleBuilder) {
|
if (componentFactory.isConsoleFactory()) {
|
||||||
return FontUtils.getNumberOfDotsToAlignForConsole(displayText);
|
return FontUtils.getNumberOfDotsToAlignForConsole(displayText);
|
||||||
} else if (config.playerNameIsBold()) {
|
} else if (config.playerNameIsBold()) {
|
||||||
return FontUtils.getNumberOfDotsToAlignForBoldText(displayText);
|
return FontUtils.getNumberOfDotsToAlignForBoldText(displayText);
|
@ -1,13 +1,14 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg;
|
package com.artemis.the.gr8.playerstats.core.msg;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.StatFormatter;
|
import com.artemis.the.gr8.playerstats.api.StatTextFormatter;
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
|
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
|
||||||
import com.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory;
|
import com.artemis.the.gr8.playerstats.core.msg.components.ConsoleComponentFactory;
|
||||||
import com.artemis.the.gr8.playerstats.msg.components.HalloweenComponentFactory;
|
import com.artemis.the.gr8.playerstats.core.msg.components.PrideComponentFactory;
|
||||||
import com.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory;
|
import com.artemis.the.gr8.playerstats.core.msg.components.BukkitConsoleComponentFactory;
|
||||||
import com.artemis.the.gr8.playerstats.msg.msgutils.FormattingFunction;
|
import com.artemis.the.gr8.playerstats.core.msg.components.HalloweenComponentFactory;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
import com.artemis.the.gr8.playerstats.core.msg.msgutils.FormattingFunction;
|
||||||
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
@ -24,7 +25,7 @@ import java.util.EnumMap;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static com.artemis.the.gr8.playerstats.enums.StandardMessage.*;
|
import static com.artemis.the.gr8.playerstats.core.enums.StandardMessage.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manages all PlayerStats output. It is the only
|
* This class manages all PlayerStats output. It is the only
|
||||||
@ -54,7 +55,7 @@ public final class OutputManager {
|
|||||||
getMessageBuilders();
|
getMessageBuilders();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatFormatter getMainMessageBuilder() {
|
public StatTextFormatter getMainMessageBuilder() {
|
||||||
return messageBuilder;
|
return messageBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,10 +170,8 @@ public final class OutputManager {
|
|||||||
if (isBukkit()) {
|
if (isBukkit()) {
|
||||||
consoleBuilder = MessageBuilder.fromComponentFactory(new BukkitConsoleComponentFactory());
|
consoleBuilder = MessageBuilder.fromComponentFactory(new BukkitConsoleComponentFactory());
|
||||||
} else {
|
} else {
|
||||||
consoleBuilder = getClientMessageBuilder();
|
consoleBuilder = MessageBuilder.fromComponentFactory(new ConsoleComponentFactory());
|
||||||
}
|
}
|
||||||
consoleBuilder.setConsoleBuilder(true);
|
|
||||||
consoleBuilder.toggleHoverUse(false);
|
|
||||||
return consoleBuilder;
|
return consoleBuilder;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.components;
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.enums.PluginColor;
|
import com.artemis.the.gr8.playerstats.core.enums.PluginColor;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
@ -40,6 +40,29 @@ public class BukkitConsoleComponentFactory extends ComponentFactory {
|
|||||||
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getConsoleColor();
|
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getConsoleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConsoleFactory() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextComponent heart() {
|
||||||
|
return text()
|
||||||
|
.content(String.valueOf('\u2665'))
|
||||||
|
.color(HEARTS)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextComponent arrow() {
|
||||||
|
return text("->").color(INFO_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextComponent bulletPoint() {
|
||||||
|
return text("*").color(INFO_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TextComponent getComponent(String content, @NotNull TextColor color, @Nullable TextDecoration style) {
|
protected TextComponent getComponent(String content, @NotNull TextColor color, @Nullable TextDecoration style) {
|
||||||
return getComponentBuilder(content, NamedTextColor.nearestTo(color), style).build();
|
return getComponentBuilder(content, NamedTextColor.nearestTo(color), style).build();
|
@ -1,11 +1,11 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.components;
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.enums.PluginColor;
|
import com.artemis.the.gr8.playerstats.core.enums.PluginColor;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Target;
|
import com.artemis.the.gr8.playerstats.api.enums.Target;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Unit;
|
import com.artemis.the.gr8.playerstats.api.enums.Unit;
|
||||||
import com.artemis.the.gr8.playerstats.msg.MessageBuilder;
|
import com.artemis.the.gr8.playerstats.core.msg.msgutils.LanguageKeyHandler;
|
||||||
import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
|
import com.artemis.the.gr8.playerstats.core.msg.MessageBuilder;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
@ -83,6 +83,10 @@ public class ComponentFactory {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConsoleFactory() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public TextComponent getExampleName() {
|
public TextComponent getExampleName() {
|
||||||
return text("Artemis_the_gr8").color(INFO_MSG_ACCENT_2);
|
return text("Artemis_the_gr8").color(INFO_MSG_ACCENT_2);
|
||||||
}
|
}
|
||||||
@ -271,7 +275,7 @@ public class ComponentFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent damageNumberWithHeartUnitInHoverText(String mainNumber, String hoverNumber, Target target) {
|
public TextComponent damageNumberWithHeartUnitInHoverText(String mainNumber, String hoverNumber, Target target) {
|
||||||
return statNumberWithHoverText(mainNumber, hoverNumber, null, null, clientHeart(true), target);
|
return statNumberWithHoverText(mainNumber, hoverNumber, null, null, heart(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent distanceNumber(String prettyNumber, Target target) {
|
public TextComponent distanceNumber(String prettyNumber, Target target) {
|
||||||
@ -304,35 +308,33 @@ public class ComponentFactory {
|
|||||||
return surroundWithBrackets(statUnit);
|
return surroundWithBrackets(statUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent clientHeart(boolean isDisplayedInHoverText) {
|
public TextComponent heart() {
|
||||||
TextComponent basicHeartComponent = basicHeartComponent('\u2764');
|
return text()
|
||||||
if (isDisplayedInHoverText) {
|
.content(String.valueOf('\u2764'))
|
||||||
return basicHeartComponent;
|
.color(HEARTS)
|
||||||
}
|
.build();
|
||||||
return surroundWithBrackets(basicHeartComponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent clientHeartWithHoverText() {
|
public TextComponent heartBetweenBrackets() {
|
||||||
TextComponent basicHeartComponent = basicHeartComponent('\u2764')
|
return surroundWithBrackets(heart());
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextComponent heartBetweenBracketsWithHoverText() {
|
||||||
|
TextComponent heart = heart()
|
||||||
.toBuilder()
|
.toBuilder()
|
||||||
.hoverEvent(HoverEvent.showText(
|
.hoverEvent(HoverEvent.showText(
|
||||||
text(Unit.HEART.getLabel())
|
text(Unit.HEART.getLabel())
|
||||||
.color(MSG_HOVER_ACCENT)))
|
.color(MSG_HOVER_ACCENT)))
|
||||||
.build();
|
.build();
|
||||||
return surroundWithBrackets(basicHeartComponent);
|
return surroundWithBrackets(heart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent consoleHeart() {
|
public TextComponent arrow() {
|
||||||
return surroundWithBrackets(basicHeartComponent('\u2665'));
|
return text("→").color(INFO_MSG); //alt + 26
|
||||||
}
|
}
|
||||||
|
|
||||||
//console can do u2665, u2764 looks better in-game
|
public TextComponent bulletPoint() {
|
||||||
@Contract("_ -> new")
|
return text("•").color(INFO_MSG); //alt + 7
|
||||||
private @NotNull TextComponent basicHeartComponent(char heartChar) {
|
|
||||||
return Component.text()
|
|
||||||
.content(String.valueOf(heartChar))
|
|
||||||
.color(HEARTS)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
|
||||||
|
public class ConsoleComponentFactory extends ComponentFactory {
|
||||||
|
|
||||||
|
public ConsoleComponentFactory() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConsoleFactory() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextComponent heart() {
|
||||||
|
return Component.text()
|
||||||
|
.content(String.valueOf('\u2665'))
|
||||||
|
.color(HEARTS)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.components;
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
@ -29,25 +29,27 @@ public final class ExampleMessage implements TextComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
|
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
|
||||||
String arrowString = factory instanceof BukkitConsoleComponentFactory ? " -> " : " → "; //4 spaces, alt + 26, 1 space
|
TextComponent spaces = text(" "); //4 spaces
|
||||||
TextComponent arrow = text(arrowString).color(factory.INFO_MSG);
|
|
||||||
|
|
||||||
return Component.newline()
|
return Component.newline()
|
||||||
.append(factory.pluginPrefixAsTitle())
|
.append(factory.pluginPrefixAsTitle())
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(factory.subTitle("Examples: "))
|
.append(factory.subTitle("Examples: "))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(arrow)
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(Component.space())
|
||||||
.append(text("/stat ").color(factory.INFO_MSG)
|
.append(text("/stat ").color(factory.INFO_MSG)
|
||||||
.append(text("animals_bred ").color(factory.INFO_MSG_ACCENT_1)
|
.append(text("animals_bred ").color(factory.INFO_MSG_ACCENT_1)
|
||||||
.append(text("top").color(factory.INFO_MSG_ACCENT_2))))
|
.append(text("top").color(factory.INFO_MSG_ACCENT_2))))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(arrow)
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(Component.space())
|
||||||
.append(text("/stat ").color(factory.INFO_MSG)
|
.append(text("/stat ").color(factory.INFO_MSG)
|
||||||
.append(text("mine_block diorite ").color(factory.INFO_MSG_ACCENT_1)
|
.append(text("mine_block diorite ").color(factory.INFO_MSG_ACCENT_1)
|
||||||
.append(text("me").color(factory.INFO_MSG_ACCENT_2))))
|
.append(text("me").color(factory.INFO_MSG_ACCENT_2))))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(arrow)
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(Component.space())
|
||||||
.append(text("/stat ").color(factory.INFO_MSG)
|
.append(text("/stat ").color(factory.INFO_MSG)
|
||||||
.append(text("deaths ").color(factory.INFO_MSG_ACCENT_1)
|
.append(text("deaths ").color(factory.INFO_MSG_ACCENT_1)
|
||||||
.append(text("player ").color(factory.INFO_MSG_ACCENT_2)
|
.append(text("player ").color(factory.INFO_MSG_ACCENT_2)
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.components;
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
@ -26,8 +26,7 @@ public final class ExcludeInfoMessage implements TextComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
|
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
|
||||||
String arrowString = factory instanceof BukkitConsoleComponentFactory ? " -> " : " → "; //4 spaces, alt + 26, 1 space
|
TextComponent spaces = text(" ");
|
||||||
TextComponent arrow = text(arrowString).color(factory.INFO_MSG);
|
|
||||||
|
|
||||||
return Component.newline()
|
return Component.newline()
|
||||||
.append(factory.pluginPrefixAsTitle())
|
.append(factory.pluginPrefixAsTitle())
|
||||||
@ -36,11 +35,18 @@ public final class ExcludeInfoMessage implements TextComponent {
|
|||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(factory.subTitle("specific players' results from /stat lookups"))
|
.append(factory.subTitle("specific players' results from /stat lookups"))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(text("Excluded players are:").color(factory.INFO_MSG))
|
.append(text("Excluded players are:")
|
||||||
|
.color(factory.INFO_MSG))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(arrow).append(text("not visible in the top 10").color(factory.INFO_MSG_ACCENT_1))
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(Component.space())
|
||||||
|
.append(text("not visible in the top 10")
|
||||||
|
.color(factory.INFO_MSG_ACCENT_1))
|
||||||
.append(Component.newline())
|
.append(Component.newline())
|
||||||
.append(arrow).append(text("not counted for the server total").color(factory.INFO_MSG_ACCENT_1));
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(Component.space())
|
||||||
|
.append(text("not counted for the server total")
|
||||||
|
.color(factory.INFO_MSG_ACCENT_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.components;
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.components;
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
@ -40,16 +40,7 @@ public final class HelpMessage implements TextComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull TextComponent buildPlainMsg(ComponentFactory factory, int listSize) {
|
private @NotNull TextComponent buildPlainMsg(ComponentFactory factory, int listSize) {
|
||||||
String arrowSymbol = "→"; //alt + 26
|
|
||||||
String bulletSymbol = "•"; //alt + 7
|
|
||||||
|
|
||||||
if (factory instanceof BukkitConsoleComponentFactory) {
|
|
||||||
arrowSymbol = "->";
|
|
||||||
bulletSymbol = "*";
|
|
||||||
}
|
|
||||||
TextComponent spaces = text(" "); //4 spaces
|
TextComponent spaces = text(" "); //4 spaces
|
||||||
TextComponent arrow = text(arrowSymbol).color(factory.INFO_MSG);
|
|
||||||
TextComponent bullet = text(bulletSymbol).color(factory.INFO_MSG);
|
|
||||||
|
|
||||||
return Component.newline()
|
return Component.newline()
|
||||||
.append(factory.pluginPrefixAsTitle())
|
.append(factory.pluginPrefixAsTitle())
|
||||||
@ -59,39 +50,46 @@ public final class HelpMessage implements TextComponent {
|
|||||||
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
|
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
|
||||||
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
|
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow).append(space())
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(space())
|
||||||
.append(text("name").color(factory.MSG_HOVER_ACCENT))
|
.append(text("name").color(factory.MSG_HOVER_ACCENT))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow).append(space())
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(space())
|
||||||
.append(text("{sub-statistic}").color(factory.MSG_HOVER_ACCENT)).append(space())
|
.append(text("{sub-statistic}").color(factory.MSG_HOVER_ACCENT)).append(space())
|
||||||
.append(text("(a block, item or entity)").color(factory.BRACKETS))
|
.append(text("(a block, item or entity)").color(factory.BRACKETS))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow).append(space())
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(space())
|
||||||
.append(text("me | player | server | top").color(factory.MSG_HOVER_ACCENT))
|
.append(text("me | player | server | top").color(factory.MSG_HOVER_ACCENT))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(spaces).append(bullet).append(space())
|
.append(spaces).append(spaces).append(
|
||||||
|
factory.bulletPoint()).append(space())
|
||||||
.append(text("me:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
.append(text("me:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
||||||
.append(text("your own statistic").color(factory.BRACKETS))
|
.append(text("your own statistic").color(factory.BRACKETS))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(spaces).append(bullet).append(space())
|
.append(spaces).append(spaces).append(
|
||||||
|
factory.bulletPoint()).append(space())
|
||||||
.append(text("player:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
.append(text("player:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
||||||
.append(text("choose a player").color(factory.BRACKETS))
|
.append(text("choose a player").color(factory.BRACKETS))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(spaces).append(bullet).append(space())
|
.append(spaces).append(spaces).append(
|
||||||
|
factory.bulletPoint()).append(space())
|
||||||
.append(text("server:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
.append(text("server:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
||||||
.append(text("everyone on the server combined").color(factory.BRACKETS))
|
.append(text("everyone on the server combined").color(factory.BRACKETS))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(spaces).append(bullet).append(space())
|
.append(spaces).append(spaces).append(
|
||||||
|
factory.bulletPoint()).append(space())
|
||||||
.append(text("top:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
.append(text("top:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
||||||
.append(text("the top").color(factory.BRACKETS).append(space()).append(text(listSize)))
|
.append(text("the top").color(factory.BRACKETS).append(space()).append(text(listSize)))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow).append(space())
|
.append(spaces).append(
|
||||||
|
factory.arrow()).append(space())
|
||||||
.append(text("{player-name}").color(factory.MSG_HOVER_ACCENT));
|
.append(text("{player-name}").color(factory.MSG_HOVER_ACCENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull TextComponent buildHoverMsg(@NotNull ComponentFactory factory, int listSize) {
|
private @NotNull TextComponent buildHoverMsg(@NotNull ComponentFactory factory, int listSize) {
|
||||||
TextComponent spaces = text(" ");
|
TextComponent spaces = text(" ");
|
||||||
TextComponent arrow = text("→").color(factory.INFO_MSG);
|
|
||||||
|
|
||||||
return Component.newline()
|
return Component.newline()
|
||||||
.append(factory.pluginPrefixAsTitle())
|
.append(factory.pluginPrefixAsTitle())
|
||||||
@ -101,14 +99,14 @@ public final class HelpMessage implements TextComponent {
|
|||||||
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
|
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
|
||||||
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
|
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow).append(space())
|
.append(spaces).append(factory.arrow()).append(space())
|
||||||
.append(text("name").color(factory.MSG_HOVER_ACCENT)
|
.append(text("name").color(factory.MSG_HOVER_ACCENT)
|
||||||
.hoverEvent(HoverEvent.showText(text("The name that describes the statistic").color(factory.MSG_HOVER)
|
.hoverEvent(HoverEvent.showText(text("The name that describes the statistic").color(factory.MSG_HOVER)
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(text("Example: ").color(factory.INFO_MSG))
|
.append(text("Example: ").color(factory.INFO_MSG))
|
||||||
.append(text("\"animals_bred\"").color(factory.MSG_HOVER_ACCENT)))))
|
.append(text("\"animals_bred\"").color(factory.MSG_HOVER_ACCENT)))))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow).append(space())
|
.append(spaces).append(factory.arrow()).append(space())
|
||||||
.append(text("sub-statistic").color(factory.MSG_HOVER_ACCENT)
|
.append(text("sub-statistic").color(factory.MSG_HOVER_ACCENT)
|
||||||
.hoverEvent(HoverEvent.showText(
|
.hoverEvent(HoverEvent.showText(
|
||||||
text("Some statistics need an item, block or entity as extra input").color(factory.MSG_HOVER)
|
text("Some statistics need an item, block or entity as extra input").color(factory.MSG_HOVER)
|
||||||
@ -116,9 +114,10 @@ public final class HelpMessage implements TextComponent {
|
|||||||
.append(text("Example: ").color(factory.INFO_MSG)
|
.append(text("Example: ").color(factory.INFO_MSG)
|
||||||
.append(text("\"mine_block diorite\"").color(factory.MSG_HOVER_ACCENT))))))
|
.append(text("\"mine_block diorite\"").color(factory.MSG_HOVER_ACCENT))))))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow
|
.append(spaces).append(factory.arrow()
|
||||||
.hoverEvent(HoverEvent.showText(
|
.hoverEvent(HoverEvent.showText(
|
||||||
text("Choose one").color(factory.MSG_CLICKED)))).append(space())
|
text("Choose one").color(factory.MSG_CLICKED))))
|
||||||
|
.append(space())
|
||||||
.append(text("me").color(factory.MSG_HOVER_ACCENT)
|
.append(text("me").color(factory.MSG_HOVER_ACCENT)
|
||||||
.hoverEvent(HoverEvent.showText(
|
.hoverEvent(HoverEvent.showText(
|
||||||
text("See your own statistic").color(factory.MSG_HOVER))))
|
text("See your own statistic").color(factory.MSG_HOVER))))
|
||||||
@ -136,7 +135,7 @@ public final class HelpMessage implements TextComponent {
|
|||||||
text("See the top").color(factory.MSG_HOVER).append(space())
|
text("See the top").color(factory.MSG_HOVER).append(space())
|
||||||
.append(text(listSize)))))
|
.append(text(listSize)))))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow).append(space())
|
.append(spaces).append(factory.arrow()).append(space())
|
||||||
.append(text("player-name").color(factory.MSG_HOVER_ACCENT)
|
.append(text("player-name").color(factory.MSG_HOVER_ACCENT)
|
||||||
.hoverEvent(HoverEvent.showText(
|
.hoverEvent(HoverEvent.showText(
|
||||||
text("In case you typed").color(factory.MSG_HOVER).append(space())
|
text("In case you typed").color(factory.MSG_HOVER).append(space())
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.components;
|
package com.artemis.the.gr8.playerstats.core.msg.components;
|
||||||
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.msgutils;
|
package com.artemis.the.gr8.playerstats.core.msg.msgutils;
|
||||||
|
|
||||||
import net.kyori.adventure.text.*;
|
import net.kyori.adventure.text.*;
|
||||||
import net.kyori.adventure.text.flattener.ComponentFlattener;
|
import net.kyori.adventure.text.flattener.ComponentFlattener;
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.msgutils;
|
package com.artemis.the.gr8.playerstats.core.msg.msgutils;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.msgutils;
|
package com.artemis.the.gr8.playerstats.core.msg.msgutils;
|
||||||
|
|
||||||
import org.bukkit.map.MinecraftFont;
|
import org.bukkit.map.MinecraftFont;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.msgutils;
|
package com.artemis.the.gr8.playerstats.core.msg.msgutils;
|
||||||
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
@ -1,8 +1,8 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.msgutils;
|
package com.artemis.the.gr8.playerstats.core.msg.msgutils;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.utils.EnumHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.FileHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.FileHandler;
|
||||||
import com.artemis.the.gr8.playerstats.enums.Unit;
|
import com.artemis.the.gr8.playerstats.api.enums.Unit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
@ -1,6 +1,8 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.msgutils;
|
package com.artemis.the.gr8.playerstats.core.msg.msgutils;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.enums.Unit;
|
import com.artemis.the.gr8.playerstats.api.StatNumberFormatter;
|
||||||
|
import com.artemis.the.gr8.playerstats.api.enums.Unit;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
@ -10,7 +12,7 @@ import java.text.DecimalFormat;
|
|||||||
* that are easier to understand (for example: from ticks to hours) and adds commas
|
* that are easier to understand (for example: from ticks to hours) and adds commas
|
||||||
* to break up large numbers.
|
* to break up large numbers.
|
||||||
*/
|
*/
|
||||||
public final class NumberFormatter {
|
public final class NumberFormatter implements StatNumberFormatter {
|
||||||
|
|
||||||
private final DecimalFormat format;
|
private final DecimalFormat format;
|
||||||
|
|
||||||
@ -21,11 +23,9 @@ public final class NumberFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns the input number into a more readable format depending on its type
|
* Adds commas in groups of 3.
|
||||||
* (number-of-times, time-, damage- or distance-based) according to the
|
|
||||||
* corresponding config settings, and adds commas in groups of 3.
|
|
||||||
*/
|
*/
|
||||||
public String formatNumber(long number) {
|
public @NotNull String formatNumber(long number) {
|
||||||
return format.format(number);
|
return format.format(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,8 @@ public final class NumberFormatter {
|
|||||||
* The unit of damage-based statistics is half a heart by default.
|
* The unit of damage-based statistics is half a heart by default.
|
||||||
* This method turns the number into hearts.
|
* This method turns the number into hearts.
|
||||||
*/
|
*/
|
||||||
public String formatDamageNumber(long number, Unit statUnit) { //7 statistics
|
@Override
|
||||||
|
public @NotNull String formatDamageNumber(long number, @NotNull Unit statUnit) { //7 statistics
|
||||||
if (statUnit == Unit.HEART) {
|
if (statUnit == Unit.HEART) {
|
||||||
return format.format(Math.round(number / 2.0));
|
return format.format(Math.round(number / 2.0));
|
||||||
} else {
|
} else {
|
||||||
@ -47,7 +48,8 @@ public final class NumberFormatter {
|
|||||||
* and turns it into km or leaves it as cm otherwise,
|
* and turns it into km or leaves it as cm otherwise,
|
||||||
* depending on the config settings.
|
* depending on the config settings.
|
||||||
*/
|
*/
|
||||||
public String formatDistanceNumber(long number, Unit statUnit) { //15 statistics
|
@Override
|
||||||
|
public @NotNull String formatDistanceNumber(long number, @NotNull Unit statUnit) { //15 statistics
|
||||||
switch (statUnit) {
|
switch (statUnit) {
|
||||||
case CM -> {
|
case CM -> {
|
||||||
return format.format(number);
|
return format.format(number);
|
||||||
@ -69,6 +71,7 @@ public final class NumberFormatter {
|
|||||||
* @return a String with the form "1D 2H 3M 4S"
|
* @return a String with the form "1D 2H 3M 4S"
|
||||||
* (depending on the Unit range selected)
|
* (depending on the Unit range selected)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String formatTimeNumber(long number, Unit biggestUnit, Unit smallestUnit) { //5 statistics
|
public String formatTimeNumber(long number, Unit biggestUnit, Unit smallestUnit) { //5 statistics
|
||||||
if (number <= 0) {
|
if (number <= 0) {
|
||||||
return "-";
|
return "-";
|
@ -1,6 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.msg.msgutils;
|
package com.artemis.the.gr8.playerstats.core.msg.msgutils;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
@ -1,9 +1,9 @@
|
|||||||
package com.artemis.the.gr8.playerstats.multithreading;
|
package com.artemis.the.gr8.playerstats.core.multithreading;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.UnixTimeHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.UnixTimeHandler;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
@ -1,9 +1,9 @@
|
|||||||
package com.artemis.the.gr8.playerstats.multithreading;
|
package com.artemis.the.gr8.playerstats.core.multithreading;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.Main;
|
import com.artemis.the.gr8.playerstats.core.Main;
|
||||||
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
|
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package com.artemis.the.gr8.playerstats.multithreading;
|
package com.artemis.the.gr8.playerstats.core.multithreading;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package com.artemis.the.gr8.playerstats.multithreading;
|
package com.artemis.the.gr8.playerstats.core.multithreading;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.RequestManager;
|
import com.artemis.the.gr8.playerstats.core.statrequest.RequestManager;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatResult;
|
import com.artemis.the.gr8.playerstats.api.StatResult;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
|
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
package com.artemis.the.gr8.playerstats.multithreading;
|
package com.artemis.the.gr8.playerstats.core.multithreading;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.Main;
|
import com.artemis.the.gr8.playerstats.core.Main;
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
|
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
|
||||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
@ -1,7 +1,7 @@
|
|||||||
package com.artemis.the.gr8.playerstats.share;
|
package com.artemis.the.gr8.playerstats.core.sharing;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.share;
|
package com.artemis.the.gr8.playerstats.core.sharing;
|
||||||
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
package com.artemis.the.gr8.playerstats.statistic;
|
package com.artemis.the.gr8.playerstats.core.statrequest;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
||||||
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
@ -16,24 +17,24 @@ public final class PlayerStatRequest extends StatRequest<Integer> implements Req
|
|||||||
|
|
||||||
public PlayerStatRequest(CommandSender sender, String playerName) {
|
public PlayerStatRequest(CommandSender sender, String playerName) {
|
||||||
super(sender);
|
super(sender);
|
||||||
super.getSettings().configureForPlayer(playerName);
|
super.configureForPlayer(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<Integer> untyped(@NotNull Statistic statistic) {
|
public StatRequest<Integer> untyped(@NotNull Statistic statistic) {
|
||||||
super.getSettings().configureUntyped(statistic);
|
super.configureUntyped(statistic);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<Integer> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
|
public StatRequest<Integer> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
|
||||||
super.getSettings().configureBlockOrItemType(statistic, material);
|
super.configureBlockOrItemType(statistic, material);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<Integer> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
|
public StatRequest<Integer> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
|
||||||
super.getSettings().configureEntityType(statistic, entityType);
|
super.configureEntityType(statistic, entityType);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,20 @@
|
|||||||
package com.artemis.the.gr8.playerstats.statistic;
|
package com.artemis.the.gr8.playerstats.core.statrequest;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
||||||
import com.artemis.the.gr8.playerstats.api.StatManager;
|
import com.artemis.the.gr8.playerstats.api.StatManager;
|
||||||
import com.artemis.the.gr8.playerstats.msg.msgutils.FormattingFunction;
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import com.artemis.the.gr8.playerstats.msg.OutputManager;
|
import com.artemis.the.gr8.playerstats.api.StatResult;
|
||||||
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
|
import com.artemis.the.gr8.playerstats.core.msg.msgutils.FormattingFunction;
|
||||||
import com.artemis.the.gr8.playerstats.share.ShareManager;
|
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
|
||||||
import com.artemis.the.gr8.playerstats.utils.MyLogger;
|
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
|
||||||
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
import com.artemis.the.gr8.playerstats.core.sharing.ShareManager;
|
||||||
|
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
|
||||||
|
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -41,39 +44,42 @@ public final class RequestManager implements StatManager {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract("_ -> new")
|
||||||
@Override
|
@Override
|
||||||
public RequestGenerator<Integer> createPlayerStatRequest(String playerName) {
|
public @NotNull RequestGenerator<Integer> createPlayerStatRequest(String playerName) {
|
||||||
return new PlayerStatRequest(playerName);
|
return new PlayerStatRequest(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatResult<Integer> executePlayerStatRequest(StatRequest<Integer> request) {
|
public @NotNull StatResult<Integer> executePlayerStatRequest(@NotNull StatRequest<Integer> request) {
|
||||||
return processor.processPlayerRequest(request.getSettings());
|
return processor.processPlayerRequest(request.getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract(" -> new")
|
||||||
@Override
|
@Override
|
||||||
public RequestGenerator<Long> createServerStatRequest() {
|
public @NotNull RequestGenerator<Long> createServerStatRequest() {
|
||||||
return new ServerStatRequest();
|
return new ServerStatRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatResult<Long> executeServerStatRequest(StatRequest<Long> request) {
|
public @NotNull StatResult<Long> executeServerStatRequest(@NotNull StatRequest<Long> request) {
|
||||||
return processor.processServerRequest(request.getSettings());
|
return processor.processServerRequest(request.getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract("_ -> new")
|
||||||
@Override
|
@Override
|
||||||
public RequestGenerator<LinkedHashMap<String, Integer>> createTopStatRequest(int topListSize) {
|
public @NotNull RequestGenerator<LinkedHashMap<String, Integer>> createTopStatRequest(int topListSize) {
|
||||||
return new TopStatRequest(topListSize);
|
return new TopStatRequest(topListSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestGenerator<LinkedHashMap<String, Integer>> createTotalTopStatRequest() {
|
public @NotNull RequestGenerator<LinkedHashMap<String, Integer>> createTotalTopStatRequest() {
|
||||||
int playerCount = offlinePlayerHandler.getOfflinePlayerCount();
|
int playerCount = offlinePlayerHandler.getOfflinePlayerCount();
|
||||||
return createTopStatRequest(playerCount);
|
return createTopStatRequest(playerCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatResult<LinkedHashMap<String, Integer>> executeTopRequest(StatRequest<LinkedHashMap<String, Integer>> request) {
|
public @NotNull StatResult<LinkedHashMap<String, Integer>> executeTopRequest(@NotNull StatRequest<LinkedHashMap<String, Integer>> request) {
|
||||||
return processor.processTopRequest(request.getSettings());
|
return processor.processTopRequest(request.getSettings());
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
package com.artemis.the.gr8.playerstats.statistic;
|
package com.artemis.the.gr8.playerstats.core.statrequest;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
||||||
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
@ -17,24 +18,24 @@ public final class ServerStatRequest extends StatRequest<Long> implements Reques
|
|||||||
|
|
||||||
public ServerStatRequest(CommandSender sender) {
|
public ServerStatRequest(CommandSender sender) {
|
||||||
super(sender);
|
super(sender);
|
||||||
super.getSettings().configureForServer();
|
super.configureForServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<Long> untyped(@NotNull Statistic statistic) {
|
public StatRequest<Long> untyped(@NotNull Statistic statistic) {
|
||||||
super.getSettings().configureUntyped(statistic);
|
super.configureUntyped(statistic);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<Long> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
|
public StatRequest<Long> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
|
||||||
super.getSettings().configureBlockOrItemType(statistic, material);
|
super.configureBlockOrItemType(statistic, material);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<Long> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
|
public StatRequest<Long> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
|
||||||
super.getSettings().configureEntityType(statistic, entityType);
|
super.configureEntityType(statistic, entityType);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.artemis.the.gr8.playerstats.statistic;
|
package com.artemis.the.gr8.playerstats.core.statrequest;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
import com.artemis.the.gr8.playerstats.api.RequestGenerator;
|
||||||
|
import com.artemis.the.gr8.playerstats.api.StatRequest;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
@ -18,24 +19,24 @@ public final class TopStatRequest extends StatRequest<LinkedHashMap<String, Inte
|
|||||||
|
|
||||||
public TopStatRequest(CommandSender sender, int topListSize) {
|
public TopStatRequest(CommandSender sender, int topListSize) {
|
||||||
super(sender);
|
super(sender);
|
||||||
super.getSettings().configureForTop(topListSize);
|
super.configureForTop(topListSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<LinkedHashMap<String, Integer>> untyped(@NotNull Statistic statistic) {
|
public StatRequest<LinkedHashMap<String, Integer>> untyped(@NotNull Statistic statistic) {
|
||||||
super.getSettings().configureUntyped(statistic);
|
super.configureUntyped(statistic);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<LinkedHashMap<String, Integer>> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
|
public StatRequest<LinkedHashMap<String, Integer>> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
|
||||||
super.getSettings().configureBlockOrItemType(statistic, material);
|
super.configureBlockOrItemType(statistic, material);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StatRequest<LinkedHashMap<String, Integer>> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
|
public StatRequest<LinkedHashMap<String, Integer>> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
|
||||||
super.getSettings().configureEntityType(statistic, entityType);
|
super.configureEntityType(statistic, entityType);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.utils;
|
package com.artemis.the.gr8.playerstats.core.utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
@ -1,6 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.utils;
|
package com.artemis.the.gr8.playerstats.core.utils;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.Main;
|
import com.artemis.the.gr8.playerstats.core.Main;
|
||||||
import com.tchristofferson.configupdater.ConfigUpdater;
|
import com.tchristofferson.configupdater.ConfigUpdater;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
@ -1,6 +1,6 @@
|
|||||||
package com.artemis.the.gr8.playerstats.utils;
|
package com.artemis.the.gr8.playerstats.core.utils;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.enums.DebugLevel;
|
import com.artemis.the.gr8.playerstats.core.enums.DebugLevel;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
@ -1,7 +1,7 @@
|
|||||||
package com.artemis.the.gr8.playerstats.utils;
|
package com.artemis.the.gr8.playerstats.core.utils;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
|
||||||
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
|
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
@ -1,4 +1,4 @@
|
|||||||
package com.artemis.the.gr8.playerstats.utils;
|
package com.artemis.the.gr8.playerstats.core.utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A small utility class that calculates with unix time.
|
* A small utility class that calculates with unix time.
|
@ -1,4 +1,4 @@
|
|||||||
main: com.artemis.the.gr8.playerstats.Main
|
main: com.artemis.the.gr8.playerstats.core.Main
|
||||||
name: PlayerStats
|
name: PlayerStats
|
||||||
version: 2.0
|
version: 2.0
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
Loading…
Reference in New Issue
Block a user