Package net.citizensnpcs.api.util

Examples of net.citizensnpcs.api.util.Paginator


        rebuildAssignmentConstants();
    }


    public void describe(CommandSender sender, int page) throws CommandException {
        Paginator paginator = new Paginator().header("Constants for " + npc.getName());
        paginator.addLine("<e>NPC-specific constants: " + (hasNPCConstants() ? "" : "None.") + "");
        if (hasNPCConstants()) paginator.addLine("<e>Key: <a>Name  <b>Value");
        for (Entry<String, String> constant : constants.entrySet()) {
            paginator.addLine("<a> " + String.valueOf(constant.getKey().charAt(0)).toUpperCase() + constant.getKey().substring(1) + "<b>  " + constant.getValue());
        }
        paginator.addLine("");

        if (npc.hasTrait(AssignmentTrait.class) && npc.getTrait(AssignmentTrait.class).hasAssignment()) {
            getAssignmentConstants();
            // List constants inherited from an Assignment.
            paginator.addLine("<e>Constants for assignment '" + assignment.toUpperCase() + "':");
            paginator.addLine("<e>Key: <a>Name  <b>Value");
            for (Entry<String, String> constant : getAssignmentConstants().entrySet()) {
                // If a constant from the Assignment has been overridden by a NPC constant,
                // change formatting to indicate so.
                if (constants.containsKey(constant.getKey()))
                    paginator.addLine("<m>" + String.valueOf(constant.getKey().charAt(0)).toUpperCase() + constant.getKey().substring(1) + "<r>  <m>" + constant.getValue());
                else paginator.addLine("<a>" + String.valueOf(constant.getKey().charAt(0)).toUpperCase() + constant.getKey().substring(1) + "<b>  " + constant.getValue());
            }
            paginator.addLine("");
        }

        if (!paginator.sendPage(sender, page))
            throw new CommandException(Messages.COMMAND_PAGE_MISSING, page);
    }
View Full Code Here


    public void describe(CommandSender sender, int page) throws CommandException {

        AssignmentScriptContainer assignmentScript = ScriptRegistry.getScriptContainer(assignment);

        Paginator paginator = new Paginator().header("Assignment");
        paginator.addLine("<e>Current assignment: " + (hasAssignment() ? this.assignment : "None.") + "");
        paginator.addLine("");

        if (!hasAssignment()) {
            paginator.sendPage(sender, page);
            return;
        }

        // Interact Scripts
        boolean entriesPresent = false;
        paginator.addLine(ChatColor.GRAY + "Interact Scripts:");
        paginator.addLine("<e>Key: <a>Priority  <b>Name");
        if (assignmentScript.contains("INTERACT SCRIPTS")) {
            entriesPresent = true;
            for (String scriptEntry : assignmentScript.getStringList("INTERACT SCRIPTS"))
                paginator.addLine("<a>" + scriptEntry.split(" ")[0] + "<b> " + scriptEntry.split(" ", 2)[1]);
        } if (!entriesPresent) paginator.addLine("<c>No Interact Scripts assigned.");
        paginator.addLine("");

        if (!entriesPresent) {
            if (!paginator.sendPage(sender, page))
                throw new CommandException(Messages.COMMAND_PAGE_MISSING);
            return;
        }

        // Scheduled Activities
        entriesPresent = false;
        paginator.addLine(ChatColor.GRAY + "Scheduled Scripts:");
        paginator.addLine("<e>Key: <a>Time  <b>Name");
        if (assignmentScript.contains("SCHEDULED ACTIVITIES")) {
            entriesPresent = true;
            for (String scriptEntry : assignmentScript.getStringList("SCHEDULED ACTIVITIES"))
                paginator.addLine("<a>" + scriptEntry.split(" ")[0] + "<b> " + scriptEntry.split(" ", 2)[1]);
        } if (!entriesPresent) paginator.addLine("<c>No scheduled scripts activities.");
        paginator.addLine("");

        // Actions
        entriesPresent = false;
        paginator.addLine(ChatColor.GRAY + "Actions:");
        paginator.addLine("<e>Key: <a>Action name  <b>Script Size");
        if (assignmentScript.contains("ACTIONS")) entriesPresent = true;
        if (entriesPresent)
            for (String action : assignmentScript.getConfigurationSection("ACTIONS").getKeys(false))
                paginator.addLine("<a>" + action + " <b>" + assignmentScript.getStringList("ACTIONS." + action).size());
        else paginator.addLine("<c>No actions defined in the assignment.");
        paginator.addLine("");

        if (!paginator.sendPage(sender, page))
            throw new CommandException(Messages.COMMAND_PAGE_MISSING, page);
    }
View Full Code Here

        else return Settings.triggerDefaultRange(triggerName);
    }


    public void describe(CommandSender sender, int page) throws CommandException {
        Paginator paginator = new Paginator().header("Triggers");
        paginator.addLine("<e>Key: <a>Name  <b>Status  <c>Cooldown  <d>Cooldown Type  <e>(Radius)");
        for (Entry<String, Boolean> entry : enabled.entrySet()) {
            String line = "<a> " + entry.getKey()
                    + "<b> " + (entry.getValue() ? "Enabled" : "Disabled")
                    + "<c> " + getCooldownDuration(entry.getKey())
                    + "<d> " + getCooldownType(entry.getKey()).name()
                    + "<e> " + (getRadius(entry.getKey()) == -1 ? "" : getRadius(entry.getKey()));
            paginator.addLine(line);
        }
        if (!paginator.sendPage(sender, page))
            throw new CommandException(Messages.COMMAND_PAGE_MISSING, page);
    }
View Full Code Here

TOP

Related Classes of net.citizensnpcs.api.util.Paginator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.