diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java index 4d37273c..e5e177b7 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java @@ -10,7 +10,7 @@ import me.filoghost.fcommons.command.sub.SubCommand; import me.filoghost.fcommons.command.sub.SubCommandContext; import me.filoghost.fcommons.command.sub.SubCommandManager; import me.filoghost.holographicdisplays.plugin.HolographicDisplays; -import me.filoghost.holographicdisplays.plugin.commands.subs.AddlineCommand; +import me.filoghost.holographicdisplays.plugin.commands.subs.AddLineCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.AlignCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.CopyCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.CreateCommand; @@ -19,16 +19,16 @@ import me.filoghost.holographicdisplays.plugin.commands.subs.DeleteCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.EditCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.HelpCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.InfoCommand; -import me.filoghost.holographicdisplays.plugin.commands.subs.InsertlineCommand; +import me.filoghost.holographicdisplays.plugin.commands.subs.InsertLineCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.ListCommand; -import me.filoghost.holographicdisplays.plugin.commands.subs.MovehereCommand; +import me.filoghost.holographicdisplays.plugin.commands.subs.MoveHereCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.NearCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.QuickEditCommand; -import me.filoghost.holographicdisplays.plugin.commands.subs.ReadimageCommand; -import me.filoghost.holographicdisplays.plugin.commands.subs.ReadtextCommand; +import me.filoghost.holographicdisplays.plugin.commands.subs.ReadImageCommand; +import me.filoghost.holographicdisplays.plugin.commands.subs.ReadTextCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.ReloadCommand; -import me.filoghost.holographicdisplays.plugin.commands.subs.RemovelineCommand; -import me.filoghost.holographicdisplays.plugin.commands.subs.SetlineCommand; +import me.filoghost.holographicdisplays.plugin.commands.subs.RemoveLineCommand; +import me.filoghost.holographicdisplays.plugin.commands.subs.SetLineCommand; import me.filoghost.holographicdisplays.plugin.commands.subs.TeleportCommand; import me.filoghost.holographicdisplays.plugin.config.ConfigManager; import me.filoghost.holographicdisplays.plugin.config.Settings; @@ -65,23 +65,23 @@ public class HologramCommandManager extends SubCommandManager { this.helpCommand = new HelpCommand(this); this.subCommands = new ArrayList<>(); - subCommands.add(new AddlineCommand(this, hologramEditor)); + subCommands.add(new AddLineCommand(this, hologramEditor)); subCommands.add(new CreateCommand(hologramEditor)); subCommands.add(new DeleteCommand(hologramEditor)); subCommands.add(new EditCommand(this, hologramEditor)); subCommands.add(new ListCommand(hologramEditor)); subCommands.add(new NearCommand(hologramEditor)); subCommands.add(new TeleportCommand(hologramEditor)); - subCommands.add(new MovehereCommand(hologramEditor)); + subCommands.add(new MoveHereCommand(hologramEditor)); subCommands.add(new AlignCommand(hologramEditor)); subCommands.add(new CopyCommand(hologramEditor)); subCommands.add(new ReloadCommand(holographicDisplays)); - subCommands.add(new RemovelineCommand(this, hologramEditor)); - subCommands.add(new SetlineCommand(this, hologramEditor)); - subCommands.add(new InsertlineCommand(this, hologramEditor)); - subCommands.add(new ReadtextCommand(hologramEditor)); - subCommands.add(new ReadimageCommand(hologramEditor)); + subCommands.add(new RemoveLineCommand(this, hologramEditor)); + subCommands.add(new SetLineCommand(this, hologramEditor)); + subCommands.add(new InsertLineCommand(this, hologramEditor)); + subCommands.add(new ReadTextCommand(hologramEditor)); + subCommands.add(new ReadImageCommand(hologramEditor)); subCommands.add(new InfoCommand(this, hologramEditor)); subCommands.add(new DebugCommand()); @@ -95,11 +95,9 @@ public class HologramCommandManager extends SubCommandManager { return subCommand; } - if (subCommand.getAliases() != null) { - for (String alias : subCommand.getAliases()) { - if (alias.equalsIgnoreCase(name)) { - return subCommand; - } + for (String alias : subCommand.getAliases()) { + if (alias.equalsIgnoreCase(name)) { + return subCommand; } } } @@ -153,10 +151,10 @@ public class HologramCommandManager extends SubCommandManager { protected void sendNoArgsMessage(CommandContext context) { CommandSender sender = context.getSender(); String version = holographicDisplays.getDescription().getVersion(); - sender.sendMessage(ColorScheme.PRIMARY_DARKER + "Server is running " + ColorScheme.PRIMARY + "Holographic Displays " - + ColorScheme.PRIMARY_DARKER + "v" + version + " by " + ColorScheme.PRIMARY + "filoghost"); + sender.sendMessage(ColorScheme.PRIMARY_DARK + "Server is running " + ColorScheme.PRIMARY + "Holographic Displays " + + ColorScheme.PRIMARY_DARK + "v" + version + " by " + ColorScheme.PRIMARY + "filoghost"); if (helpCommand.hasPermission(sender)) { - sender.sendMessage(ColorScheme.PRIMARY_DARKER + "Commands: " + ColorScheme.PRIMARY + helpCommand.getFullUsageText(context)); + sender.sendMessage(ColorScheme.PRIMARY_DARK + "Commands: " + ColorScheme.PRIMARY + helpCommand.getFullUsageText(context)); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java index 0130bba6..286af798 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java @@ -8,6 +8,7 @@ package me.filoghost.holographicdisplays.plugin.commands; import me.filoghost.fcommons.command.CommandContext; import me.filoghost.fcommons.command.sub.SubCommand; import me.filoghost.holographicdisplays.plugin.Permissions; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.Collections; @@ -70,7 +71,7 @@ public abstract class HologramSubCommand implements SubCommand { this.minArgs = minArgs; } - public final List getAliases() { + public final @NotNull List getAliases() { return aliases; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddlineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddLineCommand.java similarity index 92% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddlineCommand.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddLineCommand.java index 7da577d9..60da84c8 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddlineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddLineCommand.java @@ -16,13 +16,13 @@ import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologra import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologramLine; import org.bukkit.command.CommandSender; -public class AddlineCommand extends LineEditingCommand implements QuickEditCommand { +public class AddLineCommand extends LineEditingCommand implements QuickEditCommand { private final HologramCommandManager commandManager; private final InternalHologramEditor hologramEditor; - public AddlineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { - super("addline"); + public AddLineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { + super("addLine"); setMinArgs(2); setUsageArgs(" "); setDescription("Adds a line to a hologram."); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java index 16fe3254..1b6f635e 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java @@ -16,7 +16,7 @@ import me.filoghost.holographicdisplays.plugin.format.ColorScheme; import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramPosition; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologram; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologramLine; -import org.bukkit.ChatColor; +import net.md_5.bungee.api.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -59,7 +59,7 @@ public class CreateCommand extends HologramSubCommand { if (args.length > 1) { String text = Strings.joinFrom(" ", args, 1); line = hologramEditor.parseHologramLine(hologram, text); - player.sendMessage(ColorScheme.SECONDARY_DARKER + "(Change the lines with /" + context.getRootLabel() + player.sendMessage(ColorScheme.SECONDARY_DARK + "(Change the lines with /" + context.getRootLabel() + " edit " + hologram.getName() + ")"); } else { String defaultText = "Default hologram. Change it with " @@ -74,9 +74,9 @@ public class CreateCommand extends HologramSubCommand { player.sendMessage(ColorScheme.PRIMARY + "Hologram named \"" + hologram.getName() + "\" created."); if (moveUp) { - player.sendMessage(ColorScheme.SECONDARY_DARKER + "(You were on the ground," + player.sendMessage(ColorScheme.SECONDARY_DARK + "(You were on the ground," + " the hologram was automatically moved up." - + " If you use /" + context.getRootLabel() + " movehere " + hologram.getName() + "," + + " If you use /" + context.getRootLabel() + " moveHere " + hologram.getName() + "," + " the hologram will be moved to your feet)"); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java index 1da396c6..8804d291 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java @@ -10,20 +10,11 @@ import me.filoghost.fcommons.command.validation.CommandException; import me.filoghost.holographicdisplays.plugin.commands.HologramCommandManager; import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand; import me.filoghost.holographicdisplays.plugin.commands.InternalHologramEditor; -import me.filoghost.holographicdisplays.plugin.format.ColorScheme; import me.filoghost.holographicdisplays.plugin.format.DisplayFormat; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologram; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.List; - public class EditCommand extends HologramSubCommand { private final HologramCommandManager commandManager; @@ -43,33 +34,18 @@ public class EditCommand extends HologramSubCommand { public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = hologramEditor.getExistingHologram(args[0]); - sender.sendMessage(""); DisplayFormat.sendTitle(sender, "How to edit the hologram \"" + hologram.getName() + "\""); for (HologramSubCommand subCommand : commandManager.getSubCommands()) { if (subCommand instanceof LineEditingCommand) { - String usage = subCommand.getFullUsageText(context).replace("", hologram.getName()); - - if (sender instanceof Player) { - List help = new ArrayList<>(); - help.add(ColorScheme.PRIMARY + usage); - for (String tutLine : subCommand.getDescription(context)) { - help.add(ColorScheme.SECONDARY_DARKER + tutLine); - } - - ((Player) sender).spigot().sendMessage(new ComponentBuilder(usage) - .color(ChatColor.AQUA) - .event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage)) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help)))) - .create()); - - } else { - sender.sendMessage(ColorScheme.PRIMARY + usage); - } + DisplayFormat.sendCommandDescription( + sender, + subCommand.getFullUsageText(context).replace("", hologram.getName()), + subCommand.getDescription(context)); } } if (sender instanceof Player) { - HelpCommand.sendHoverTip((Player) sender); + DisplayFormat.sendHoverCommandDescriptionTip((Player) sender); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java index abac3a51..736051b3 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java @@ -8,20 +8,10 @@ package me.filoghost.holographicdisplays.plugin.commands.subs; import me.filoghost.fcommons.command.sub.SubCommandContext; import me.filoghost.holographicdisplays.plugin.commands.HologramCommandManager; import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand; -import me.filoghost.holographicdisplays.plugin.format.ColorScheme; import me.filoghost.holographicdisplays.plugin.format.DisplayFormat; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.List; - public class HelpCommand extends HologramSubCommand { private final HologramCommandManager commandManager; @@ -36,49 +26,19 @@ public class HelpCommand extends HologramSubCommand { @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) { - sender.sendMessage(""); DisplayFormat.sendTitle(sender, "Holographic Displays Commands"); for (HologramSubCommand subCommand : commandManager.getSubCommands()) { if (subCommand.isShowInHelpCommand()) { - String usage = subCommand.getFullUsageText(context); - - if (sender instanceof Player) { - List help = new ArrayList<>(); - help.add(ColorScheme.PRIMARY + usage); - for (String tutLine : subCommand.getDescription(context)) { - help.add(ColorScheme.SECONDARY_DARKER + tutLine); - } - - ((Player) sender).spigot().sendMessage(new ComponentBuilder(usage) - .color(ChatColor.AQUA) - .event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage)) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help)))) - .create()); - - } else { - sender.sendMessage(ColorScheme.PRIMARY + usage); - } + DisplayFormat.sendCommandDescription( + sender, + subCommand.getFullUsageText(context), + subCommand.getDescription(context)); } } if (sender instanceof Player) { - sendHoverTip((Player) sender); + DisplayFormat.sendHoverCommandDescriptionTip((Player) sender); } } - public static void sendHoverTip(Player player) { - player.sendMessage(""); - player.spigot().sendMessage(new ComponentBuilder("TIP:").color(ChatColor.YELLOW).bold(true) - .append(" Try to ", FormatRetention.NONE).color(ChatColor.GRAY) - .append("hover").color(ChatColor.WHITE).underlined(true) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Hover on the commands to see the description."))) - .append(" or ", FormatRetention.NONE).color(ChatColor.GRAY) - .append("click").color(ChatColor.WHITE).underlined(true) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Click on the commands to insert them in the chat."))) - .append(" on the commands.", FormatRetention.NONE).color(ChatColor.GRAY) - .create()); - } - } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java index 355f4609..fb0ae0f2 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java @@ -34,13 +34,12 @@ public class InfoCommand extends LineEditingCommand implements QuickEditCommand public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = hologramEditor.getExistingHologram(args[0]); - sender.sendMessage(""); DisplayFormat.sendTitle(sender, "Lines of the hologram \"" + hologram.getName() + "\""); int index = 0; for (InternalHologramLine line : hologram.getLines()) { index++; - sender.sendMessage(ColorScheme.SECONDARY_BOLD + index + ColorScheme.SECONDARY_DARKER + ". " + sender.sendMessage(ColorScheme.SECONDARY_BOLD + index + ColorScheme.SECONDARY_DARK + ". " + ColorScheme.SECONDARY + line.getSerializedConfigValue()); } commandManager.sendQuickEditCommands(context, hologram); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertlineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertLineCommand.java similarity index 93% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertlineCommand.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertLineCommand.java index e41bcaa2..d4af2a94 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertlineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertLineCommand.java @@ -18,13 +18,13 @@ import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologra import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologramLine; import org.bukkit.command.CommandSender; -public class InsertlineCommand extends LineEditingCommand implements QuickEditCommand { +public class InsertLineCommand extends LineEditingCommand implements QuickEditCommand { private final HologramCommandManager commandManager; private final InternalHologramEditor hologramEditor; - public InsertlineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { - super("insertline"); + public InsertLineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { + super("insertLine"); setMinArgs(3); setUsageArgs(" "); setDescription( @@ -55,7 +55,7 @@ public class InsertlineCommand extends LineEditingCommand implements QuickEditCo sender.sendMessage(ColorScheme.PRIMARY + "Line inserted before the first line."); } else if (insertAfterIndex == oldLinesAmount) { sender.sendMessage(ColorScheme.PRIMARY + "Line appended at the end."); - DisplayFormat.sendTip(sender, "You can use \"/" + context.getRootLabel() + " addline\" to append a line at the end."); + DisplayFormat.sendTip(sender, "You can use \"/" + context.getRootLabel() + " addLine\" to append a line at the end."); } else { sender.sendMessage(ColorScheme.PRIMARY + "Line inserted between the lines " + insertAfterIndex + " and " + (insertAfterIndex + 1) + "."); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java index 928c7fc7..63aa13f5 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java @@ -12,7 +12,6 @@ import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand; import me.filoghost.holographicdisplays.plugin.commands.InternalHologramEditor; import me.filoghost.holographicdisplays.plugin.format.ColorScheme; import me.filoghost.holographicdisplays.plugin.format.DisplayFormat; -import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramPosition; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologram; import org.bukkit.command.CommandSender; @@ -44,22 +43,17 @@ public class ListCommand extends HologramSubCommand { totalPages++; } - CommandValidate.check(holograms.size() > 0, + CommandValidate.check( + holograms.size() > 0, "There are no holograms yet. Create one with /" + context.getRootLabel() + " create."); - sender.sendMessage(""); DisplayFormat.sendTitle(sender, "Holograms list " + ColorScheme.SECONDARY + "(Page " + page + " of " + totalPages + ")"); int fromIndex = (page - 1) * HOLOGRAMS_PER_PAGE; int toIndex = fromIndex + HOLOGRAMS_PER_PAGE; for (int i = fromIndex; i < toIndex; i++) { if (i < holograms.size()) { - InternalHologram hologram = holograms.get(i); - BaseHologramPosition position = hologram.getBasePosition(); - sender.sendMessage(ColorScheme.SECONDARY_DARKER + "- " + ColorScheme.SECONDARY_BOLD + hologram.getName() - + " " + ColorScheme.SECONDARY_DARKER + "at" - + " x: " + position.getBlockX() + ", y: " + position.getBlockY() + ", z: " + position.getBlockZ() - + " (lines: " + hologram.getLines().size() + ", world: \"" + position.getWorldName() + "\")"); + DisplayFormat.sendHologramSummary(sender, holograms.get(i), true); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MovehereCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MoveHereCommand.java similarity index 91% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MovehereCommand.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MoveHereCommand.java index fd98c61f..ea745505 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MovehereCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MoveHereCommand.java @@ -16,12 +16,12 @@ import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologra import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class MovehereCommand extends HologramSubCommand { +public class MoveHereCommand extends HologramSubCommand { private final InternalHologramEditor hologramEditor; - public MovehereCommand(InternalHologramEditor hologramEditor) { - super("movehere"); + public MoveHereCommand(InternalHologramEditor hologramEditor) { + super("moveHere"); setMinArgs(1); setUsageArgs(""); setDescription("Moves a hologram to your position."); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java index 5b2c065f..6e46d603 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java @@ -10,7 +10,6 @@ import me.filoghost.fcommons.command.validation.CommandException; import me.filoghost.fcommons.command.validation.CommandValidate; import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand; import me.filoghost.holographicdisplays.plugin.commands.InternalHologramEditor; -import me.filoghost.holographicdisplays.plugin.format.ColorScheme; import me.filoghost.holographicdisplays.plugin.format.DisplayFormat; import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramPosition; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologram; @@ -54,11 +53,7 @@ public class NearCommand extends HologramSubCommand { DisplayFormat.sendTitle(player, "Near holograms"); for (InternalHologram nearHologram : nearHolograms) { - BaseHologramPosition position = nearHologram.getBasePosition(); - player.sendMessage(ColorScheme.SECONDARY_DARKER + "- " - + ColorScheme.SECONDARY_BOLD + nearHologram.getName() + " " + ColorScheme.SECONDARY_DARKER + "at" - + " x: " + position.getBlockX() + ", y: " + position.getBlockY() + ", z: " + position.getBlockZ() - + " (lines: " + nearHologram.getLines().size() + ")"); + DisplayFormat.sendHologramSummary(player, nearHologram, false); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadimageCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadImageCommand.java similarity index 96% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadimageCommand.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadImageCommand.java index aa275c55..c6e21357 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadimageCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadImageCommand.java @@ -20,7 +20,7 @@ import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalTextLin import me.filoghost.holographicdisplays.plugin.image.ImageMessage; import me.filoghost.holographicdisplays.plugin.image.ImageReadException; import me.filoghost.holographicdisplays.plugin.image.ImageReader; -import org.bukkit.ChatColor; +import net.md_5.bungee.api.ChatColor; import org.bukkit.command.CommandSender; import java.awt.image.BufferedImage; @@ -33,12 +33,12 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; -public class ReadimageCommand extends LineEditingCommand { +public class ReadImageCommand extends LineEditingCommand { private final InternalHologramEditor hologramEditor; - public ReadimageCommand(InternalHologramEditor hologramEditor) { - super("readimage", "image"); + public ReadImageCommand(InternalHologramEditor hologramEditor) { + super("readImage", "image"); setMinArgs(3); setUsageArgs(" "); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadtextCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadTextCommand.java similarity index 94% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadtextCommand.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadTextCommand.java index 7530372f..ca3561e3 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadtextCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadTextCommand.java @@ -18,7 +18,7 @@ import me.filoghost.holographicdisplays.plugin.format.DisplayFormat; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologram; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologramLine; import me.filoghost.holographicdisplays.plugin.util.FileUtils; -import org.bukkit.ChatColor; +import net.md_5.bungee.api.ChatColor; import org.bukkit.command.CommandSender; import java.io.IOException; @@ -28,12 +28,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class ReadtextCommand extends LineEditingCommand { +public class ReadTextCommand extends LineEditingCommand { private final InternalHologramEditor hologramEditor; - public ReadtextCommand(InternalHologramEditor hologramEditor) { - super("readtext", "readlines"); + public ReadTextCommand(InternalHologramEditor hologramEditor) { + super("readText", "readLines"); setMinArgs(2); setUsageArgs(" "); @@ -90,7 +90,7 @@ public class ReadtextCommand extends LineEditingCommand { if (FileUtils.hasFileExtension(fileToRead, "jpg", "png", "jpeg", "gif")) { DisplayFormat.sendWarning(sender, "It looks like the file is an image." - + " If it is, you should use instead /" + context.getRootLabel() + " readimage."); + + " If it is, you should use instead /" + context.getRootLabel() + " readImage."); } sender.sendMessage(ColorScheme.PRIMARY + "Hologram content replaced with " + linesAmount + " lines from the file."); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemovelineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemoveLineCommand.java similarity index 93% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemovelineCommand.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemoveLineCommand.java index e688eeb5..d7fc5df5 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemovelineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemoveLineCommand.java @@ -15,13 +15,13 @@ import me.filoghost.holographicdisplays.plugin.format.ColorScheme; import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologram; import org.bukkit.command.CommandSender; -public class RemovelineCommand extends LineEditingCommand implements QuickEditCommand { +public class RemoveLineCommand extends LineEditingCommand implements QuickEditCommand { private final HologramCommandManager commandManager; private final InternalHologramEditor hologramEditor; - public RemovelineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { - super("removeline"); + public RemoveLineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { + super("removeLine"); setMinArgs(2); setUsageArgs(" "); setDescription("Removes a line from a hologram."); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetlineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetLineCommand.java similarity index 93% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetlineCommand.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetLineCommand.java index 567f2bd5..c2899b2d 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetlineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetLineCommand.java @@ -17,13 +17,13 @@ import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologra import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologramLine; import org.bukkit.command.CommandSender; -public class SetlineCommand extends LineEditingCommand implements QuickEditCommand { +public class SetLineCommand extends LineEditingCommand implements QuickEditCommand { private final HologramCommandManager commandManager; private final InternalHologramEditor hologramEditor; - public SetlineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { - super("setline"); + public SetLineCommand(HologramCommandManager commandManager, InternalHologramEditor hologramEditor) { + super("setLine"); setMinArgs(3); setUsageArgs(" "); setDescription("Changes a line of a hologram."); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/ColorScheme.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/ColorScheme.java index 62a190e8..1095830a 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/ColorScheme.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/ColorScheme.java @@ -5,16 +5,16 @@ */ package me.filoghost.holographicdisplays.plugin.format; -import org.bukkit.ChatColor; +import net.md_5.bungee.api.ChatColor; public class ColorScheme { - public static final String PRIMARY = "" + ChatColor.AQUA; - public static final String PRIMARY_DARKER = "" + ChatColor.DARK_AQUA; + public static final ChatColor PRIMARY = ChatColor.AQUA; + public static final ChatColor PRIMARY_DARK = ChatColor.DARK_AQUA; - public static final String SECONDARY = "" + ChatColor.WHITE; + public static final ChatColor SECONDARY = ChatColor.WHITE; public static final String SECONDARY_BOLD = "" + SECONDARY + ChatColor.BOLD; - public static final String SECONDARY_DARKER = "" + ChatColor.GRAY; + public static final ChatColor SECONDARY_DARK = ChatColor.GRAY; public static final String ERROR = "" + ChatColor.RED; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java index 3fc70665..822e43b6 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/format/DisplayFormat.java @@ -8,8 +8,19 @@ package me.filoghost.holographicdisplays.plugin.format; import me.filoghost.fcommons.Colors; import me.filoghost.holographicdisplays.plugin.config.StaticReplacements; -import org.bukkit.ChatColor; +import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramPosition; +import me.filoghost.holographicdisplays.plugin.hologram.internal.InternalHologram; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; public class DisplayFormat { @@ -26,17 +37,63 @@ public class DisplayFormat { public static void sendTitle(CommandSender recipient, String title) { recipient.sendMessage(""); - recipient.sendMessage(ColorScheme.PRIMARY_DARKER + ChatColor.BOLD + "----- " - + title + ColorScheme.PRIMARY_DARKER + ChatColor.BOLD + " -----"); + recipient.sendMessage("" + ColorScheme.PRIMARY_DARK + ChatColor.BOLD + "----- " + + title + ColorScheme.PRIMARY_DARK + ChatColor.BOLD + " -----"); } public static void sendTip(CommandSender recipient, String tip) { - recipient.sendMessage("" + ChatColor.YELLOW + ChatColor.BOLD + "TIP:" + ColorScheme.SECONDARY_DARKER + " " + tip); + recipient.sendMessage("" + ChatColor.YELLOW + ChatColor.BOLD + "TIP:" + ColorScheme.SECONDARY_DARK + " " + tip); } public static void sendWarning(CommandSender recipient, String warning) { recipient.sendMessage(ChatColor.RED + "( " + ChatColor.DARK_RED + ChatColor.BOLD + "!" + ChatColor.RED + " ) " - + ColorScheme.SECONDARY_DARKER + warning); + + ColorScheme.SECONDARY_DARK + warning); + } + + public static void sendCommandDescription(CommandSender sender, String usage, List description) { + if (sender instanceof Player) { + List tooltipLines = new ArrayList<>(); + tooltipLines.add(ColorScheme.PRIMARY + usage); + for (String descriptionLine : description) { + tooltipLines.add(ColorScheme.SECONDARY_DARK + descriptionLine); + } + + ((Player) sender).spigot().sendMessage(new ComponentBuilder(usage) + .color(ColorScheme.PRIMARY) + .event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage)) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", tooltipLines)))) + .create()); + + } else { + sender.sendMessage(ColorScheme.PRIMARY + usage); + } + } + + public static void sendHoverCommandDescriptionTip(Player player) { + player.sendMessage(""); + player.spigot().sendMessage(new ComponentBuilder("TIP:").color(ChatColor.YELLOW).bold(true) + .append(" Try to ", FormatRetention.NONE).color(ColorScheme.SECONDARY_DARK) + .append("hover").color(ColorScheme.SECONDARY).underlined(true) + .event(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Hover on the commands to see the description."))) + .append(" or ", FormatRetention.NONE).color(ColorScheme.SECONDARY_DARK) + .append("click").color(ColorScheme.SECONDARY).underlined(true) + .event(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Click on the commands to insert them in the chat."))) + .append(" on the commands.", FormatRetention.NONE).color(ColorScheme.SECONDARY_DARK) + .create()); + } + + public static void sendHologramSummary(CommandSender sender, InternalHologram hologram, boolean showWorld) { + BaseHologramPosition position = hologram.getBasePosition(); + sender.sendMessage(ColorScheme.SECONDARY_DARK + "- " + ColorScheme.SECONDARY_BOLD + hologram.getName() + + ColorScheme.SECONDARY_DARK + " (" + hologram.getLines().size() + " lines) at " + + (showWorld ? "world: \"" + position.getWorldName() + "\", " : "") + + "x: " + position.getBlockX() + ", " + + "y: " + position.getBlockY() + ", " + + "z: " + position.getBlockZ()); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java index 1c4b2743..0d6b83ff 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java @@ -39,9 +39,9 @@ public class UpdateNotificationListener implements Listener { Player player = event.getPlayer(); if (player.hasPermission(Permissions.UPDATE_NOTIFICATION)) { - player.sendMessage(ColorScheme.PRIMARY_DARKER + "[HolographicDisplays] " + player.sendMessage(ColorScheme.PRIMARY_DARK + "[HolographicDisplays] " + ColorScheme.PRIMARY + "Found an update: " + newVersion + ". Download:"); - player.sendMessage(ColorScheme.PRIMARY_DARKER + ">> " + player.sendMessage(ColorScheme.PRIMARY_DARK + ">> " + ColorScheme.PRIMARY + "https://dev.bukkit.org/projects/holographic-displays"); } }