Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.cryptonicdev.cryptonic.commands.impl;
- import java.util.Iterator;
- import de.cryptonicdev.cryptonic.commands.Command;
- import de.cryptonicdev.cryptonic.main.Cryptonic;
- import de.cryptonicdev.cryptonic.utils.CryptoUtils;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.ChatStyle;
- import net.minecraft.util.EnumChatFormatting;
- public class HelpCmd extends Command {
- private static String[] syntax = { "[<Seite>]", "[<Befehl>]" };
- public HelpCmd() {
- super("Help", "Zeigt die Befehlsliste oder die Hilfe für einen Befehl an.", syntax);
- }
- @Override
- public void onCommand(String input, String[] args) throws Exception {
- if (args.length == 0) {
- onCommand("#help 1", new String[] { "1" });
- return;
- }
- int countCommands = getCommandManager().getCommands().size();
- int pages = (int) Math.ceil(countCommands / 8D);
- if (CryptoUtils.isInteger(args[0])) {
- int page = Integer.valueOf(args[0]);
- if (page > pages || page < 1)
- getChat().syntaxError("§cUngültige Seite: " + page);
- getChat().sendMessage("§2Verfügbare Befehle: " + countCommands);
- Iterator<Command> itr = getCommandManager().getCommands().iterator();
- for (int i = 0; itr.hasNext(); i++) {
- Command cmd = itr.next();
- if (i >= (page - 1) * 8 && i < (page - 1) * 8 + 8)
- getChat().sendMessage("§b#" + cmd.getCommand());
- }
- getChat().sendMessage("§2Befehlsliste (Seite " + page + "/" + pages + "):");
- } else {
- Command cmd = getCommandManager().getCommandByName(args[0]);
- if (cmd != null) {
- getChat().sendMessage("§3Verfügbare Hilfe für #" + args[0] + ":");
- getChat().component(new ChatComponentText(cmd.getDescription())
- .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)));
- for (String syntax : cmd.getSyntax()) {
- getChat().component(new ChatComponentText("§bSyntax: ").appendSibling(new ChatComponentText(syntax)
- .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE))));
- }
- } else
- getChat().sendMessage("§cDer Befehl \"" + args[0] + "\" konnte nicht gefunden werden.");
- }
- }
- }
Add Comment
Please, Sign In to add comment