Separated internal code from api code to improve future maintainability

This commit is contained in:
Artemis-the-gr8 2022-11-01 14:18:25 +01:00
parent fc1ac7c07e
commit c4b963a057
57 changed files with 395 additions and 334 deletions

View File

@ -49,7 +49,7 @@
<configuration>
<transformers>
<transformer>
<mainClass>com.artemis.the.gr8.playerstats.Main</mainClass>
<mainClass>com.artemis.the.gr8.playerstats.core.Main</mainClass>
</transformer>
</transformers>
<artifactSet>

View File

@ -141,7 +141,7 @@
<transformers>
<transformer
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>
</transformers>
<artifactSet>

View File

@ -1,7 +1,6 @@
package com.artemis.the.gr8.playerstats.api;
import com.artemis.the.gr8.playerstats.Main;
import com.artemis.the.gr8.playerstats.statistic.RequestManager;
import com.artemis.the.gr8.playerstats.core.Main;
import org.jetbrains.annotations.Contract;
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
* access any of the further methods.
*
* @see RequestManager
* @see StatFormatter
* @see StatManager
* @see StatTextFormatter
* @see StatNumberFormatter
*/
public interface PlayerStats {
@ -41,5 +41,7 @@ public interface PlayerStats {
StatManager getStatManager();
StatFormatter getFormatter();
StatTextFormatter getStatTextFormatter();
StatNumberFormatter getStatNumberFormatter();
}

View File

@ -1,7 +1,5 @@
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.Statistic;
import org.bukkit.entity.EntityType;

View File

@ -1,8 +1,5 @@
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;
public interface StatManager {
@ -70,4 +67,4 @@ public interface StatManager {
* @see StatResult
*/
StatResult<LinkedHashMap<String, Integer>> executeTopRequest(StatRequest<LinkedHashMap<String, Integer>> request);
}
}

View File

@ -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);
}

View File

@ -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.enums.Target;
import com.artemis.the.gr8.playerstats.api.enums.Target;
import org.bukkit.Material;
import org.bukkit.Statistic;
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() {
switch (settings.statistic.getType()) {
case BLOCK -> {
@ -61,6 +105,7 @@ public abstract class StatRequest<T> {
}
}
public static final class Settings {
private final CommandSender sender;
private Statistic statistic;
@ -80,50 +125,6 @@ public abstract class StatRequest<T> {
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() {
return sender;

View File

@ -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.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>
* 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,
* 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) {

View File

@ -1,8 +1,6 @@
package com.artemis.the.gr8.playerstats.api;
import com.artemis.the.gr8.playerstats.enums.Unit;
import com.artemis.the.gr8.playerstats.msg.msgutils.NumberFormatter;
import com.artemis.the.gr8.playerstats.statistic.StatResult;
import com.artemis.the.gr8.playerstats.api.enums.Unit;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.Statistic;
import org.jetbrains.annotations.Nullable;
@ -15,16 +13,7 @@ import org.jetbrains.annotations.Nullable;
* @see StatResult
*/
public interface StatFormatter {
/**
* Gets a {@link NumberFormatter} to format raw numbers into something more readable.
*
* @return the <code>NumberFormatter</code>
*/
default NumberFormatter getNumberFormatter() {
return new NumberFormatter();
}
public interface StatTextFormatter {
/**
* Turns a TextComponent into its String representation. This method is equipped

View File

@ -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

View File

@ -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.jetbrains.annotations.NotNull;

View File

@ -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.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.commands.*;
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
import com.artemis.the.gr8.playerstats.statistic.RequestManager;
import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.listeners.JoinListener;
import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
import com.artemis.the.gr8.playerstats.share.ShareManager;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.core.commands.*;
import com.artemis.the.gr8.playerstats.core.msg.msgutils.NumberFormatter;
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
import com.artemis.the.gr8.playerstats.core.statrequest.RequestManager;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.listeners.JoinListener;
import com.artemis.the.gr8.playerstats.core.msg.msgutils.LanguageKeyHandler;
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 me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
@ -176,7 +178,13 @@ public final class Main extends JavaPlugin implements PlayerStats {
}
@Override
public StatFormatter getFormatter() {
public StatTextFormatter getStatTextFormatter() {
return outputManager.getMainMessageBuilder();
}
@Contract(" -> new")
@Override
public @NotNull StatNumberFormatter getStatNumberFormatter() {
return new NumberFormatter();
}
}

View File

@ -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.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

@ -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.CommandExecutor;

View File

@ -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.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.artemis.the.gr8.playerstats.share.StoredResult;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.core.sharing.ShareManager;
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.sharing.StoredResult;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

@ -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.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.enums.Target;
import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.artemis.the.gr8.playerstats.statistic.*;
import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.api.enums.Target;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.statrequest.PlayerStatRequest;
import com.artemis.the.gr8.playerstats.core.statrequest.ServerStatRequest;
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.Statistic;
import org.bukkit.command.Command;

View File

@ -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.utils.OfflinePlayerHandler;
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.Statistic;
import org.bukkit.command.Command;

View File

@ -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.enums.Unit;
import com.artemis.the.gr8.playerstats.utils.FileHandler;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.api.enums.Target;
import com.artemis.the.gr8.playerstats.api.enums.Unit;
import com.artemis.the.gr8.playerstats.core.utils.FileHandler;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.Nullable;

View File

@ -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;

View File

@ -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.

View File

@ -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.TextColor;

View File

@ -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.

View File

@ -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.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

View File

@ -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.msg.components.*;
import com.artemis.the.gr8.playerstats.msg.msgutils.*;
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.enums.Target;
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.enums.Unit;
import com.artemis.the.gr8.playerstats.api.StatTextFormatter;
import com.artemis.the.gr8.playerstats.core.msg.components.*;
import com.artemis.the.gr8.playerstats.core.msg.msgutils.*;
import com.artemis.the.gr8.playerstats.api.StatRequest;
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import com.artemis.the.gr8.playerstats.api.enums.Target;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.api.enums.Unit;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
@ -34,11 +34,10 @@ import static net.kyori.adventure.text.Component.*;
* @see PrideComponentFactory
* @see BukkitConsoleComponentFactory
*/
public final class MessageBuilder implements StatFormatter {
public final class MessageBuilder implements StatTextFormatter {
private final ConfigHandler config;
private boolean useHoverText;
private boolean isConsoleBuilder;
private final boolean useHoverText;
private final ComponentFactory componentFactory;
private final LanguageKeyHandler languageKeyHandler;
@ -50,7 +49,11 @@ public final class MessageBuilder implements StatFormatter {
languageKeyHandler = LanguageKeyHandler.getInstance();
componentFactory = factory;
useHoverText = config.useHoverText();
if (componentFactory.isConsoleFactory()) {
useHoverText = false;
} else {
useHoverText = config.useHoverText();
}
formatter = new NumberFormatter();
serializer = new ComponentSerializer();
}
@ -65,18 +68,6 @@ public final class MessageBuilder implements StatFormatter {
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
public @NotNull String textComponentToString(TextComponent component) {
return serializer.getTranslatableComponentSerializer().serialize(component);
@ -186,7 +177,7 @@ public final class MessageBuilder implements StatFormatter {
public TextComponent helpMsg() {
int listSize = config.getTopListMaxSize();
if (!isConsoleBuilder && useHoverText) {
if (useHoverText) {
return HelpMessage.constructHoverMsg(componentFactory, listSize);
} else {
return HelpMessage.constructPlainMsg(componentFactory, listSize);
@ -638,16 +629,10 @@ public final class MessageBuilder implements StatFormatter {
*/
private @NotNull TextComponent getDamageUnitComponent(Unit unit, Target target) {
if (unit == Unit.HEART) {
TextComponent heartUnit;
if (isConsoleBuilder) {
heartUnit = componentFactory.consoleHeart();
} else if (useHoverText) {
heartUnit = componentFactory.clientHeartWithHoverText();
} else {
heartUnit = componentFactory.clientHeart(false);
}
return Component.space()
.append(heartUnit);
TextComponent heartUnit = useHoverText ?
componentFactory.heartBetweenBracketsWithHoverText() :
componentFactory.heartBetweenBrackets();
return Component.space().append(heartUnit);
}
return Component.space()
.append(componentFactory.statUnit(unit.getLabel(), target));
@ -702,7 +687,7 @@ public final class MessageBuilder implements StatFormatter {
}
private int getNumberOfDotsToAlign(String displayText) {
if (isConsoleBuilder) {
if (componentFactory.isConsoleFactory()) {
return FontUtils.getNumberOfDotsToAlignForConsole(displayText);
} else if (config.playerNameIsBold()) {
return FontUtils.getNumberOfDotsToAlignForBoldText(displayText);

View File

@ -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.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory;
import com.artemis.the.gr8.playerstats.msg.components.HalloweenComponentFactory;
import com.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory;
import com.artemis.the.gr8.playerstats.msg.msgutils.FormattingFunction;
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
import com.artemis.the.gr8.playerstats.api.StatTextFormatter;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.core.msg.components.ConsoleComponentFactory;
import com.artemis.the.gr8.playerstats.core.msg.components.PrideComponentFactory;
import com.artemis.the.gr8.playerstats.core.msg.components.BukkitConsoleComponentFactory;
import com.artemis.the.gr8.playerstats.core.msg.components.HalloweenComponentFactory;
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.text.Component;
import net.kyori.adventure.text.TextComponent;
@ -24,7 +25,7 @@ import java.util.EnumMap;
import java.util.LinkedHashMap;
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
@ -54,7 +55,7 @@ public final class OutputManager {
getMessageBuilders();
}
public StatFormatter getMainMessageBuilder() {
public StatTextFormatter getMainMessageBuilder() {
return messageBuilder;
}
@ -169,10 +170,8 @@ public final class OutputManager {
if (isBukkit()) {
consoleBuilder = MessageBuilder.fromComponentFactory(new BukkitConsoleComponentFactory());
} else {
consoleBuilder = getClientMessageBuilder();
consoleBuilder = MessageBuilder.fromComponentFactory(new ConsoleComponentFactory());
}
consoleBuilder.setConsoleBuilder(true);
consoleBuilder.toggleHoverUse(false);
return consoleBuilder;
}

View File

@ -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.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
@ -40,6 +40,29 @@ public class BukkitConsoleComponentFactory extends ComponentFactory {
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
protected TextComponent getComponent(String content, @NotNull TextColor color, @Nullable TextDecoration style) {
return getComponentBuilder(content, NamedTextColor.nearestTo(color), style).build();

View File

@ -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.enums.PluginColor;
import com.artemis.the.gr8.playerstats.enums.Target;
import com.artemis.the.gr8.playerstats.enums.Unit;
import com.artemis.the.gr8.playerstats.msg.MessageBuilder;
import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.enums.PluginColor;
import com.artemis.the.gr8.playerstats.api.enums.Target;
import com.artemis.the.gr8.playerstats.api.enums.Unit;
import com.artemis.the.gr8.playerstats.core.msg.msgutils.LanguageKeyHandler;
import com.artemis.the.gr8.playerstats.core.msg.MessageBuilder;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent;
@ -83,6 +83,10 @@ public class ComponentFactory {
.build();
}
public boolean isConsoleFactory() {
return false;
}
public TextComponent getExampleName() {
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) {
return statNumberWithHoverText(mainNumber, hoverNumber, null, null, clientHeart(true), target);
return statNumberWithHoverText(mainNumber, hoverNumber, null, null, heart(), target);
}
public TextComponent distanceNumber(String prettyNumber, Target target) {
@ -304,35 +308,33 @@ public class ComponentFactory {
return surroundWithBrackets(statUnit);
}
public TextComponent clientHeart(boolean isDisplayedInHoverText) {
TextComponent basicHeartComponent = basicHeartComponent('\u2764');
if (isDisplayedInHoverText) {
return basicHeartComponent;
}
return surroundWithBrackets(basicHeartComponent);
public TextComponent heart() {
return text()
.content(String.valueOf('\u2764'))
.color(HEARTS)
.build();
}
public TextComponent clientHeartWithHoverText() {
TextComponent basicHeartComponent = basicHeartComponent('\u2764')
public TextComponent heartBetweenBrackets() {
return surroundWithBrackets(heart());
}
public TextComponent heartBetweenBracketsWithHoverText() {
TextComponent heart = heart()
.toBuilder()
.hoverEvent(HoverEvent.showText(
text(Unit.HEART.getLabel())
.color(MSG_HOVER_ACCENT)))
.build();
return surroundWithBrackets(basicHeartComponent);
return surroundWithBrackets(heart);
}
public TextComponent consoleHeart() {
return surroundWithBrackets(basicHeartComponent('\u2665'));
public TextComponent arrow() {
return text("").color(INFO_MSG); //alt + 26
}
//console can do u2665, u2764 looks better in-game
@Contract("_ -> new")
private @NotNull TextComponent basicHeartComponent(char heartChar) {
return Component.text()
.content(String.valueOf(heartChar))
.color(HEARTS)
.build();
public TextComponent bulletPoint() {
return text("").color(INFO_MSG); //alt + 7
}
/**

View File

@ -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();
}
}

View File

@ -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.ComponentLike;
@ -29,25 +29,27 @@ public final class ExampleMessage implements TextComponent {
}
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
String arrowString = factory instanceof BukkitConsoleComponentFactory ? " -> " : ""; //4 spaces, alt + 26, 1 space
TextComponent arrow = text(arrowString).color(factory.INFO_MSG);
TextComponent spaces = text(" "); //4 spaces
return Component.newline()
.append(factory.pluginPrefixAsTitle())
.append(Component.newline())
.append(factory.subTitle("Examples: "))
.append(Component.newline())
.append(arrow)
.append(spaces).append(
factory.arrow()).append(Component.space())
.append(text("/stat ").color(factory.INFO_MSG)
.append(text("animals_bred ").color(factory.INFO_MSG_ACCENT_1)
.append(text("top").color(factory.INFO_MSG_ACCENT_2))))
.append(Component.newline())
.append(arrow)
.append(spaces).append(
factory.arrow()).append(Component.space())
.append(text("/stat ").color(factory.INFO_MSG)
.append(text("mine_block diorite ").color(factory.INFO_MSG_ACCENT_1)
.append(text("me").color(factory.INFO_MSG_ACCENT_2))))
.append(Component.newline())
.append(arrow)
.append(spaces).append(
factory.arrow()).append(Component.space())
.append(text("/stat ").color(factory.INFO_MSG)
.append(text("deaths ").color(factory.INFO_MSG_ACCENT_1)
.append(text("player ").color(factory.INFO_MSG_ACCENT_2)

View File

@ -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.ComponentLike;
@ -26,8 +26,7 @@ public final class ExcludeInfoMessage implements TextComponent {
}
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
String arrowString = factory instanceof BukkitConsoleComponentFactory ? " -> " : ""; //4 spaces, alt + 26, 1 space
TextComponent arrow = text(arrowString).color(factory.INFO_MSG);
TextComponent spaces = text(" ");
return Component.newline()
.append(factory.pluginPrefixAsTitle())
@ -36,11 +35,18 @@ public final class ExcludeInfoMessage implements TextComponent {
.append(Component.newline())
.append(factory.subTitle("specific players' results from /stat lookups"))
.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(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(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

View File

@ -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;

View File

@ -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.ComponentLike;
@ -40,16 +40,7 @@ public final class HelpMessage implements TextComponent {
}
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 arrow = text(arrowSymbol).color(factory.INFO_MSG);
TextComponent bullet = text(bulletSymbol).color(factory.INFO_MSG);
return Component.newline()
.append(factory.pluginPrefixAsTitle())
@ -59,39 +50,46 @@ public final class HelpMessage implements TextComponent {
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(spaces).append(
factory.arrow()).append(space())
.append(text("name").color(factory.MSG_HOVER_ACCENT))
.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("(a block, item or entity)").color(factory.BRACKETS))
.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(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("your own statistic").color(factory.BRACKETS))
.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("choose a player").color(factory.BRACKETS))
.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("everyone on the server combined").color(factory.BRACKETS))
.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("the top").color(factory.BRACKETS).append(space()).append(text(listSize)))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(spaces).append(
factory.arrow()).append(space())
.append(text("{player-name}").color(factory.MSG_HOVER_ACCENT));
}
private @NotNull TextComponent buildHoverMsg(@NotNull ComponentFactory factory, int listSize) {
TextComponent spaces = text(" ");
TextComponent arrow = text("").color(factory.INFO_MSG);
return Component.newline()
.append(factory.pluginPrefixAsTitle())
@ -101,14 +99,14 @@ public final class HelpMessage implements TextComponent {
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(spaces).append(factory.arrow()).append(space())
.append(text("name").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(text("The name that describes the statistic").color(factory.MSG_HOVER)
.append(newline())
.append(text("Example: ").color(factory.INFO_MSG))
.append(text("\"animals_bred\"").color(factory.MSG_HOVER_ACCENT)))))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(spaces).append(factory.arrow()).append(space())
.append(text("sub-statistic").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
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("\"mine_block diorite\"").color(factory.MSG_HOVER_ACCENT))))))
.append(newline())
.append(spaces).append(arrow
.append(spaces).append(factory.arrow()
.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)
.hoverEvent(HoverEvent.showText(
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())
.append(text(listSize)))))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(spaces).append(factory.arrow()).append(space())
.append(text("player-name").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
text("In case you typed").color(factory.MSG_HOVER).append(space())

View File

@ -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 org.jetbrains.annotations.Contract;

View File

@ -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.flattener.ComponentFlattener;

View File

@ -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 net.kyori.adventure.text.Component;

View File

@ -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;

View File

@ -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 org.bukkit.command.CommandSender;

View File

@ -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.utils.FileHandler;
import com.artemis.the.gr8.playerstats.enums.Unit;
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
import com.artemis.the.gr8.playerstats.core.utils.FileHandler;
import com.artemis.the.gr8.playerstats.api.enums.Unit;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.entity.EntityType;

View File

@ -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;
@ -10,7 +12,7 @@ import java.text.DecimalFormat;
* that are easier to understand (for example: from ticks to hours) and adds commas
* to break up large numbers.
*/
public final class NumberFormatter {
public final class NumberFormatter implements StatNumberFormatter {
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
* (number-of-times, time-, damage- or distance-based) according to the
* corresponding config settings, and adds commas in groups of 3.
* Adds commas in groups of 3.
*/
public String formatNumber(long number) {
public @NotNull String formatNumber(long 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.
* 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) {
return format.format(Math.round(number / 2.0));
} else {
@ -47,7 +48,8 @@ public final class NumberFormatter {
* and turns it into km or leaves it as cm otherwise,
* 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) {
case CM -> {
return format.format(number);
@ -69,6 +71,7 @@ public final class NumberFormatter {
* @return a String with the form "1D 2H 3M 4S"
* (depending on the Unit range selected)
*/
@Override
public String formatTimeNumber(long number, Unit biggestUnit, Unit smallestUnit) { //5 statistics
if (number <= 0) {
return "-";

View File

@ -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.Pattern;

View File

@ -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.utils.MyLogger;
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.utils.UnixTimeHandler;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.core.utils.UnixTimeHandler;
import org.bukkit.OfflinePlayer;
import java.util.UUID;

View File

@ -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.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.core.Main;
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.Nullable;

View File

@ -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.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.api.StatRequest;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;

View File

@ -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.statistic.RequestManager;
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
import com.artemis.the.gr8.playerstats.statistic.StatResult;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.statrequest.RequestManager;
import com.artemis.the.gr8.playerstats.api.StatRequest;
import com.artemis.the.gr8.playerstats.api.StatResult;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.Nullable;

View File

@ -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.msg.OutputManager;
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.core.Main;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.api.StatRequest;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;

View File

@ -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.utils.MyLogger;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;

View File

@ -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;

View File

@ -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.StatRequest;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Statistic;
@ -16,24 +17,24 @@ public final class PlayerStatRequest extends StatRequest<Integer> implements Req
public PlayerStatRequest(CommandSender sender, String playerName) {
super(sender);
super.getSettings().configureForPlayer(playerName);
super.configureForPlayer(playerName);
}
@Override
public StatRequest<Integer> untyped(@NotNull Statistic statistic) {
super.getSettings().configureUntyped(statistic);
super.configureUntyped(statistic);
return this;
}
@Override
public StatRequest<Integer> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
super.getSettings().configureBlockOrItemType(statistic, material);
super.configureBlockOrItemType(statistic, material);
return this;
}
@Override
public StatRequest<Integer> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
super.getSettings().configureEntityType(statistic, entityType);
super.configureEntityType(statistic, entityType);
return this;
}
}

View File

@ -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.StatManager;
import com.artemis.the.gr8.playerstats.msg.msgutils.FormattingFunction;
import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.artemis.the.gr8.playerstats.multithreading.ThreadManager;
import com.artemis.the.gr8.playerstats.share.ShareManager;
import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.api.StatRequest;
import com.artemis.the.gr8.playerstats.api.StatResult;
import com.artemis.the.gr8.playerstats.core.msg.msgutils.FormattingFunction;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
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 org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@ -41,39 +44,42 @@ public final class RequestManager implements StatManager {
};
}
@Contract("_ -> new")
@Override
public RequestGenerator<Integer> createPlayerStatRequest(String playerName) {
public @NotNull RequestGenerator<Integer> createPlayerStatRequest(String playerName) {
return new PlayerStatRequest(playerName);
}
@Override
public StatResult<Integer> executePlayerStatRequest(StatRequest<Integer> request) {
public @NotNull StatResult<Integer> executePlayerStatRequest(@NotNull StatRequest<Integer> request) {
return processor.processPlayerRequest(request.getSettings());
}
@Contract(" -> new")
@Override
public RequestGenerator<Long> createServerStatRequest() {
public @NotNull RequestGenerator<Long> createServerStatRequest() {
return new ServerStatRequest();
}
@Override
public StatResult<Long> executeServerStatRequest(StatRequest<Long> request) {
public @NotNull StatResult<Long> executeServerStatRequest(@NotNull StatRequest<Long> request) {
return processor.processServerRequest(request.getSettings());
}
@Contract("_ -> new")
@Override
public RequestGenerator<LinkedHashMap<String, Integer>> createTopStatRequest(int topListSize) {
public @NotNull RequestGenerator<LinkedHashMap<String, Integer>> createTopStatRequest(int topListSize) {
return new TopStatRequest(topListSize);
}
@Override
public RequestGenerator<LinkedHashMap<String, Integer>> createTotalTopStatRequest() {
public @NotNull RequestGenerator<LinkedHashMap<String, Integer>> createTotalTopStatRequest() {
int playerCount = offlinePlayerHandler.getOfflinePlayerCount();
return createTopStatRequest(playerCount);
}
@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());
}

View File

@ -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.StatRequest;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Statistic;
@ -17,24 +18,24 @@ public final class ServerStatRequest extends StatRequest<Long> implements Reques
public ServerStatRequest(CommandSender sender) {
super(sender);
super.getSettings().configureForServer();
super.configureForServer();
}
@Override
public StatRequest<Long> untyped(@NotNull Statistic statistic) {
super.getSettings().configureUntyped(statistic);
super.configureUntyped(statistic);
return this;
}
@Override
public StatRequest<Long> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
super.getSettings().configureBlockOrItemType(statistic, material);
super.configureBlockOrItemType(statistic, material);
return this;
}
@Override
public StatRequest<Long> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
super.getSettings().configureEntityType(statistic, entityType);
super.configureEntityType(statistic, entityType);
return this;
}
}

View File

@ -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.StatRequest;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Statistic;
@ -18,24 +19,24 @@ public final class TopStatRequest extends StatRequest<LinkedHashMap<String, Inte
public TopStatRequest(CommandSender sender, int topListSize) {
super(sender);
super.getSettings().configureForTop(topListSize);
super.configureForTop(topListSize);
}
@Override
public StatRequest<LinkedHashMap<String, Integer>> untyped(@NotNull Statistic statistic) {
super.getSettings().configureUntyped(statistic);
super.configureUntyped(statistic);
return this;
}
@Override
public StatRequest<LinkedHashMap<String, Integer>> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) {
super.getSettings().configureBlockOrItemType(statistic, material);
super.configureBlockOrItemType(statistic, material);
return this;
}
@Override
public StatRequest<LinkedHashMap<String, Integer>> entityType(@NotNull Statistic statistic, @NotNull EntityType entityType) {
super.getSettings().configureEntityType(statistic, entityType);
super.configureEntityType(statistic, entityType);
return this;
}
}

View File

@ -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.Statistic;

View File

@ -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 org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -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.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

View File

@ -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.multithreading.ThreadManager;
import com.artemis.the.gr8.playerstats.core.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.core.multithreading.ThreadManager;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.Contract;

View File

@ -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.

View File

@ -1,4 +1,4 @@
main: com.artemis.the.gr8.playerstats.Main
main: com.artemis.the.gr8.playerstats.core.Main
name: PlayerStats
version: 2.0
api-version: 1.13