Add info command.

This commit is contained in:
filoghost 2014-12-31 12:34:54 +01:00
parent 07f722accc
commit d7b41c5176
2 changed files with 63 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import com.gmail.filoghost.holographicdisplays.commands.main.subs.DeleteCommand;
import com.gmail.filoghost.holographicdisplays.commands.main.subs.EditCommand; import com.gmail.filoghost.holographicdisplays.commands.main.subs.EditCommand;
import com.gmail.filoghost.holographicdisplays.commands.main.subs.FixCommand; import com.gmail.filoghost.holographicdisplays.commands.main.subs.FixCommand;
import com.gmail.filoghost.holographicdisplays.commands.main.subs.HelpCommand; import com.gmail.filoghost.holographicdisplays.commands.main.subs.HelpCommand;
import com.gmail.filoghost.holographicdisplays.commands.main.subs.InfoCommand;
import com.gmail.filoghost.holographicdisplays.commands.main.subs.InsertlineCommand; import com.gmail.filoghost.holographicdisplays.commands.main.subs.InsertlineCommand;
import com.gmail.filoghost.holographicdisplays.commands.main.subs.ListCommand; import com.gmail.filoghost.holographicdisplays.commands.main.subs.ListCommand;
import com.gmail.filoghost.holographicdisplays.commands.main.subs.MovehereCommand; import com.gmail.filoghost.holographicdisplays.commands.main.subs.MovehereCommand;
@ -57,6 +58,7 @@ public class HologramsCommandHandler implements CommandExecutor {
registerSubCommand(new InsertlineCommand()); registerSubCommand(new InsertlineCommand());
registerSubCommand(new ReadtextCommand()); registerSubCommand(new ReadtextCommand());
registerSubCommand(new ReadimageCommand()); registerSubCommand(new ReadimageCommand());
registerSubCommand(new InfoCommand());
registerSubCommand(new HelpCommand(this)); registerSubCommand(new HelpCommand(this));
} }

View File

@ -0,0 +1,61 @@
package com.gmail.filoghost.holographicdisplays.commands.main.subs;
import java.util.Arrays;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.gmail.filoghost.holographicdisplays.commands.Colors;
import com.gmail.filoghost.holographicdisplays.commands.CommandValidator;
import com.gmail.filoghost.holographicdisplays.commands.Strings;
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.object.line.CraftTextLine;
public class InfoCommand extends HologramSubCommand {
public InfoCommand() {
super("info", "details");
setPermission(Strings.BASE_PERM + "info");
}
@Override
public String getPossibleArguments() {
return "<hologramName>";
}
@Override
public int getMinimumArguments() {
return 1;
}
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
String name = args[0].toLowerCase();
NamedHologram hologram = NamedHologramManager.getHologram(name);
CommandValidator.notNull(hologram, Strings.noSuchHologram(name));
sender.sendMessage("");
sender.sendMessage(Strings.formatTitle("Lines of the hologram '" + name + "'"));
int index = 0;
for (CraftHologramLine line : hologram.getLinesUnsafe()) {
sender.sendMessage(Colors.SECONDARY + Colors.BOLD + (++index) + Colors.SECONDARY_SHADOW + ". " + Colors.SECONDARY + (line instanceof CraftTextLine ? ((CraftTextLine) line).getText() : HologramDatabase.saveLineToString(line)));
}
}
@Override
public List<String> getTutorial() {
return Arrays.asList("Shows the lines of a hologram.");
}
@Override
public SubCommandType getType() {
return SubCommandType.EDIT_LINES;
}
}