Small refactoring

This commit is contained in:
filoghost 2021-08-14 10:17:42 +02:00
parent f61ba7a02c
commit e1009b8cd8
18 changed files with 135 additions and 155 deletions

View File

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

View File

@ -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<String> getAliases() {
public final @NotNull List<String> getAliases() {
return aliases;
}

View File

@ -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("<hologram> <text>");
setDescription("Adds a line to a hologram.");

View File

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

View File

@ -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>", hologram.getName());
if (sender instanceof Player) {
List<String> 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>", hologram.getName()),
subCommand.getDescription(context));
}
}
if (sender instanceof Player) {
HelpCommand.sendHoverTip((Player) sender);
DisplayFormat.sendHoverCommandDescriptionTip((Player) sender);
}
}

View File

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

View File

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

View File

@ -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("<hologram> <lineNumber> <text>");
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) + ".");

View File

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

View File

@ -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("<hologram>");
setDescription("Moves a hologram to your position.");

View File

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

View File

@ -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("<hologram> <imageWithExtension> <width>");

View File

@ -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("<hologram> <fileWithExtension>");
@ -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.");

View File

@ -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("<hologram> <lineNumber>");
setDescription("Removes a line from a hologram.");

View File

@ -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("<hologram> <lineNumber> <newText>");
setDescription("Changes a line of a hologram.");

View File

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

View File

@ -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<String> description) {
if (sender instanceof Player) {
List<String> 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());
}
}

View File

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