mirror of
https://github.com/itHotL/PlayerStats.git
synced 2024-11-22 11:55:17 +01:00
Reworked usage-message to account for lack of hover text
This commit is contained in:
parent
28da2e95cb
commit
bf3feda8cc
2
pom.xml
2
pom.xml
@ -21,7 +21,7 @@
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sonatype-oss-snapshots1</id>
|
||||
<id>sonatype-oss-snapshots1</id> <!-- the Adventure repository for development builds -->
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.Statistic;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -30,7 +31,17 @@ public class StatCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length >= 1) { //part 1: collecting all relevant information from the args
|
||||
if (args.length == 0) { //in case of less than 1 argument, display the help message
|
||||
adventure.sender(sender).sendMessage(messageFactory.helpMsg(sender instanceof ConsoleCommandSender));
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("examples")) { //in case of "statistic examples", show examples
|
||||
adventure.sender(sender).sendMessage(messageFactory.usageExamples(sender instanceof ConsoleCommandSender));
|
||||
return true;
|
||||
}
|
||||
|
||||
else { //part 1: collecting all relevant information from the args
|
||||
StatRequest request = generateRequest(sender, args);
|
||||
|
||||
if (isValidStatRequest(request)) { //part 2: sending the information to the StatThread
|
||||
@ -42,11 +53,6 @@ public class StatCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else { //in case of less than 1 argument, display the help message
|
||||
adventure.sender(sender).sendMessage(messageFactory.helpMsg());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//create a StatRequest Object with all the relevant information from the args
|
||||
|
@ -66,9 +66,9 @@ public class ConfigHandler {
|
||||
return config.getInt("number-of-days-since-last-joined", 0);
|
||||
}
|
||||
|
||||
/** Returns the config setting for top-list-max-size, or the default value of 10 if no value can be retrieved. */
|
||||
public int getTopListMaxSize() {
|
||||
return config.getInt("top-list-max-size", 10);
|
||||
|
||||
public boolean useHoverText() {
|
||||
return config.getBoolean("enable-hover-text", true);
|
||||
}
|
||||
|
||||
/** Returns the config setting for use-dots, or the default value "true" if no value can be retrieved. */
|
||||
@ -76,16 +76,20 @@ public class ConfigHandler {
|
||||
return config.getBoolean("use-dots", true);
|
||||
}
|
||||
|
||||
/** Returns the config setting for top-list-max-size, or the default value of 10 if no value can be retrieved. */
|
||||
public int getTopListMaxSize() {
|
||||
return config.getInt("top-list-max-size", 10);
|
||||
}
|
||||
|
||||
public String getServerTitle() {
|
||||
return config.getString("total-server-stat-title", "Total on");
|
||||
}
|
||||
|
||||
/** Returns the specified server name, or "this server" if no value can be retrieved. */
|
||||
public String getServerName() {
|
||||
return config.getString("your-server-name", "this server");
|
||||
}
|
||||
|
||||
|
||||
public String getServerTitle() {
|
||||
return config.getString("total-server-stat-title", "In total on");
|
||||
}
|
||||
|
||||
/** Returns a String that represents either a Chat Color, hex color code, or Style. Default values are "none" for Style,
|
||||
and "green" or "gold" for Color (for top or individual color). */
|
||||
public String getPlayerNameFormatting(Query selection, boolean isStyle) {
|
||||
|
@ -23,10 +23,10 @@ public class MessageFactory {
|
||||
|
||||
private static ConfigHandler config;
|
||||
|
||||
private static final TextColor msgColor = TextColor.fromHexString("#55AAFF");
|
||||
private static final TextColor hoverBaseColor = TextColor.fromHexString("#55C6FF");
|
||||
private static final TextColor hoverAccentColor1 = TextColor.fromHexString("#FFB80E");
|
||||
private static final TextColor hoverAccentColor2 = TextColor.fromHexString("#FFD52B");
|
||||
private static final TextColor msgColor = TextColor.fromHexString("#55AAFF"); //my favorite shade of light blue, somewhere between blue and aqua
|
||||
private static final TextColor hoverBaseColor = TextColor.fromHexString("#55C6FF"); //light blue - one shade lighter than msgColor
|
||||
private static final TextColor accentColor1 = TextColor.fromHexString("#FFB80E"); //gold - one shade lighter than standard gold
|
||||
private static final TextColor accentColor2 = TextColor.fromHexString("#FFD52B"); //yellow - a few shades darker than standard yellow
|
||||
|
||||
|
||||
public MessageFactory(ConfigHandler c) {
|
||||
@ -101,71 +101,50 @@ public class MessageFactory {
|
||||
.color(msgColor));
|
||||
}
|
||||
|
||||
public TextComponent helpMsg() {
|
||||
TextComponent spaces = text(" ");
|
||||
TextComponent underscores = text("____________").color(TextColor.fromHexString("#6E3485"));
|
||||
TextComponent arrow = text("→ ").color(NamedTextColor.GOLD);
|
||||
TextColor arguments = NamedTextColor.YELLOW;
|
||||
public TextComponent helpMsg(boolean isConsoleSender) {
|
||||
if (!isConsoleSender) {
|
||||
return config.useHoverText() ? helpMsgHover() : helpMsgPlain(false);
|
||||
}
|
||||
else {
|
||||
return helpMsgPlain(true);
|
||||
}
|
||||
}
|
||||
|
||||
public TextComponent usageExamples(boolean isConsoleSender) {
|
||||
TextComponent spaces = text(" "); //4 spaces
|
||||
TextComponent underscores = text("_____________").color(TextColor.fromHexString("#6E3485"));
|
||||
TextComponent arrow = text("→ ").color(NamedTextColor.GOLD);
|
||||
TextColor accentColor = TextColor.fromHexString("#FFE339");
|
||||
|
||||
if (isConsoleSender) {
|
||||
arrow = text("-> ").color(NamedTextColor.GOLD);
|
||||
accentColor = NamedTextColor.YELLOW;
|
||||
}
|
||||
|
||||
return Component.newline()
|
||||
.append(underscores).append(spaces).append(pluginPrefix()).append(spaces).append(underscores)
|
||||
.append(newline())
|
||||
.append(text("Hover over the arguments for more information!").color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC))
|
||||
.append(newline())
|
||||
.append(text("Usage: ").color(NamedTextColor.GOLD)).append(text("/statistic").color(arguments))
|
||||
.append(text("Examples: ").color(NamedTextColor.GOLD))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("name").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(text("The name that describes the statistic").color(hoverBaseColor)
|
||||
.append(newline())
|
||||
.append(text("Example: ").color(hoverAccentColor1))
|
||||
.append(text("\"animals_bred\"").color(hoverAccentColor2)))))
|
||||
.append(text("/statistic animals_bred top").color(accentColor))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("sub-statistic").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("Some statistics need an item, block or entity as sub-statistic").color(hoverBaseColor)
|
||||
.append(newline())
|
||||
.append(text("Example: ").color(hoverAccentColor1)
|
||||
.append(text("\"mine_block diorite\"").color(hoverAccentColor2))))))
|
||||
.append(newline())
|
||||
.append(spaces)
|
||||
.append(text("→").color(NamedTextColor.GOLD)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("Choose one").color(TextColor.fromHexString("#6E3485")))))
|
||||
.append(space())
|
||||
.append(text("me").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("See your own statistic").color(hoverBaseColor))))
|
||||
.append(text(" | ").color(arguments))
|
||||
.append(text("player").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("Choose any player that has played on your server").color(hoverBaseColor))))
|
||||
.append(text(" | ").color(arguments))
|
||||
.append(text("server").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("See the combined total for everyone on your server").color(hoverBaseColor))))
|
||||
.append(text(" | ").color(arguments))
|
||||
.append(text("top").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("See the top ").color(hoverBaseColor)
|
||||
.append(text(config.getTopListMaxSize()).color(hoverBaseColor)))))
|
||||
.append(text("/statistic mine_block diorite me").color(accentColor))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("player-name").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("In case you typed ").color(hoverBaseColor)
|
||||
.append(text("\"player\"").color(hoverAccentColor2)
|
||||
.append(text(", add the player's name").color(hoverBaseColor))))));
|
||||
.append(text("/statistic deaths player Artemis_the_gr8").color(accentColor))
|
||||
.append(newline());
|
||||
}
|
||||
|
||||
public TextComponent formatPlayerStat(String playerName, String statName, String subStatEntryName, int stat) {
|
||||
TextComponent.Builder singleStat = Component.text();
|
||||
|
||||
singleStat.append(playerNameComponent(Query.PLAYER, playerName + ": "))
|
||||
.append(statNumberComponent(Query.PLAYER, stat)).append(space())
|
||||
.append(statNumberComponent(Query.PLAYER, stat))
|
||||
.append(space())
|
||||
.append(statNameComponent(Query.PLAYER, statName))
|
||||
.append(space())
|
||||
.append(subStatNameComponent(Query.PLAYER, subStatEntryName));
|
||||
|
||||
return singleStat.build();
|
||||
@ -344,4 +323,118 @@ public class MessageFactory {
|
||||
return styles.value(configString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//returns the usage-explanation with hovering text
|
||||
private TextComponent helpMsgHover() {
|
||||
TextComponent spaces = text(" "); //4 spaces
|
||||
TextComponent underscores = text("____________").color(TextColor.fromHexString("#6E3485")); //12 underscores
|
||||
TextComponent arrow = text("→ ").color(NamedTextColor.GOLD); //alt + 26
|
||||
TextColor arguments = NamedTextColor.YELLOW;
|
||||
|
||||
return Component.newline()
|
||||
.append(underscores).append(spaces).append(pluginPrefix()).append(spaces).append(underscores)
|
||||
.append(newline())
|
||||
.append(text("Hover over the arguments for more information!").color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC))
|
||||
.append(newline())
|
||||
.append(text("Usage: ").color(NamedTextColor.GOLD)).append(text("/statistic").color(arguments))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("name").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(text("The name that describes the statistic").color(hoverBaseColor)
|
||||
.append(newline())
|
||||
.append(text("Example: ").color(accentColor1))
|
||||
.append(text("\"animals_bred\"").color(accentColor2)))))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("sub-statistic").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("Some statistics need an item, block or entity as extra input").color(hoverBaseColor)
|
||||
.append(newline())
|
||||
.append(text("Example: ").color(accentColor1)
|
||||
.append(text("\"mine_block diorite\"").color(accentColor2))))))
|
||||
.append(newline())
|
||||
.append(spaces)
|
||||
.append(text("→").color(NamedTextColor.GOLD)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("Choose one").color(TextColor.fromHexString("#6E3485")))))
|
||||
.append(space())
|
||||
.append(text("me").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("See your own statistic").color(hoverBaseColor))))
|
||||
.append(text(" | ").color(arguments))
|
||||
.append(text("player").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("Choose any player that has played on your server").color(hoverBaseColor))))
|
||||
.append(text(" | ").color(arguments))
|
||||
.append(text("server").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("See the combined total for everyone on your server").color(hoverBaseColor))))
|
||||
.append(text(" | ").color(arguments))
|
||||
.append(text("top").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("See the top ").color(hoverBaseColor)
|
||||
.append(text(config.getTopListMaxSize()).color(hoverBaseColor)))))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("player-name").color(arguments)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("In case you typed ").color(hoverBaseColor)
|
||||
.append(text("\"player\"").color(accentColor2)
|
||||
.append(text(", add the player's name").color(hoverBaseColor))))));
|
||||
}
|
||||
|
||||
//returns the usage-explanation without any hovering text
|
||||
private TextComponent helpMsgPlain(boolean isConsoleSender) {
|
||||
TextComponent underscores = text("____________").color(TextColor.fromHexString("#6E3485")); //12 underscores
|
||||
TextComponent spaces = text(" "); //4 spaces
|
||||
TextComponent arrow = text("→ ").color(NamedTextColor.GOLD); //alt + 26;
|
||||
TextComponent bullet = text("• ").color(NamedTextColor.GOLD); //alt + 7
|
||||
TextColor arguments = NamedTextColor.YELLOW;
|
||||
TextColor accentColor = accentColor2;
|
||||
|
||||
if (isConsoleSender) {
|
||||
arrow = text("-> ").color(NamedTextColor.GOLD);
|
||||
bullet = text("* ").color(NamedTextColor.GOLD);
|
||||
accentColor = NamedTextColor.GOLD;
|
||||
}
|
||||
|
||||
return Component.newline()
|
||||
.append(underscores).append(spaces).append(pluginPrefix()).append(spaces).append(underscores)
|
||||
.append(newline())
|
||||
.append(text("Type \"/statistic examples\" to see examples!").color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC))
|
||||
.append(newline())
|
||||
.append(text("Usage: ").color(NamedTextColor.GOLD))
|
||||
.append(text("/statistic").color(arguments))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("name").color(arguments))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("{sub-statistic}").color(arguments))
|
||||
.append(space())
|
||||
.append(text("(a block, item or entity)").color(NamedTextColor.GRAY))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("me | player | server | top").color(arguments))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet)
|
||||
.append(text("me:").color(accentColor))
|
||||
.append(space()).append(text("your own statistic").color(NamedTextColor.GRAY))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet)
|
||||
.append(text("player:").color(accentColor))
|
||||
.append(space()).append(text("choose a player").color(NamedTextColor.GRAY))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet)
|
||||
.append(text("server:").color(accentColor))
|
||||
.append(space()).append(text("everyone on the server combined").color(NamedTextColor.GRAY))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet)
|
||||
.append(text("top:").color(accentColor))
|
||||
.append(space()).append(text("the top").color(NamedTextColor.GRAY)
|
||||
.append(space()).append(text(config.getTopListMaxSize())))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow)
|
||||
.append(text("{player-name}").color(arguments));
|
||||
}
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
# -------------------------------------------------------------------------------------------------------- #
|
||||
# PlayerStats Configuration #
|
||||
# -------------------------------------------------------------------------------------------------------- #
|
||||
# ------------------------------------------------------------------------------------------------------ #
|
||||
# PlayerStats Configuration #
|
||||
# ------------------------------------------------------------------------------------------------------ #
|
||||
config-version: 2
|
||||
|
||||
|
||||
# ------------------------------- #
|
||||
# General #
|
||||
# ------------------------------- #
|
||||
# If true, OP players will receive a message when they join the server if the config version is outdated
|
||||
# Send OP players a message if the config-version is outdated when they join the server
|
||||
outdated-config-notifications: true
|
||||
|
||||
# Filtering options to control which players should be included in statistic calculations
|
||||
@ -22,6 +22,9 @@ number-of-days-since-last-joined: 0
|
||||
# ------------------------------- #
|
||||
# Format & Display #
|
||||
# ------------------------------- #
|
||||
# Use hover-text for additional info in the usage explanation
|
||||
enable-hover-text: false
|
||||
|
||||
# If true, the stat-numbers in the top list will be aligned with dots
|
||||
use-dots: true
|
||||
|
||||
@ -32,7 +35,7 @@ top-list-max-size: 10
|
||||
top-list-title: 'Top [x]'
|
||||
|
||||
# The text you want displayed for a total-on-this-server statistic
|
||||
# This will be put on the same line ('In total on this server: [x] animals bred', for example)
|
||||
# This will be put on the same line ('Total on this server: [x] animals bred', for example)
|
||||
total-server-stat-title: 'Total on'
|
||||
your-server-name: 'this server'
|
||||
|
||||
|
BIN
src/main/resources/images/no_hover_usage.png
Normal file
BIN
src/main/resources/images/no_hover_usage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Loading…
Reference in New Issue
Block a user