Search in sources :

Example 6 with Paginator

use of net.citizensnpcs.api.util.Paginator in project Denizen-For-Bukkit by DenizenScript.

the class TriggerTrait method describe.

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()) + "<e> " + (getRadius(entry.getKey()) == -1 ? "" : getRadius(entry.getKey()));
        paginator.addLine(line);
    }
    if (!paginator.sendPage(sender, page)) {
        throw new CommandException(Messages.COMMAND_PAGE_MISSING, page);
    }
}
Also used : CommandException(net.citizensnpcs.api.command.exception.CommandException) Paginator(net.citizensnpcs.api.util.Paginator)

Example 7 with Paginator

use of net.citizensnpcs.api.util.Paginator in project Denizen-For-Bukkit by DenizenScript.

the class AssignmentTrait method describe.

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")) {
            String[] split = scriptEntry.split(" ", 2);
            if (split.length == 2 && aH.matchesInteger(split[0])) {
                paginator.addLine("<a>" + split[0] + "<b> " + split[1]);
            } else {
                paginator.addLine("<b>" + scriptEntry);
            }
        }
    }
    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 (StringHolder action : assignmentScript.getConfigurationSection("ACTIONS").getKeys(false)) {
            paginator.addLine("<a>" + action.str + " <b>" + assignmentScript.getStringList("ACTIONS." + action.str).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);
    }
}
Also used : StringHolder(net.aufdemrand.denizencore.utilities.text.StringHolder) AssignmentScriptContainer(net.aufdemrand.denizen.scripts.containers.core.AssignmentScriptContainer) CommandException(net.citizensnpcs.api.command.exception.CommandException) Paginator(net.citizensnpcs.api.util.Paginator)

Example 8 with Paginator

use of net.citizensnpcs.api.util.Paginator in project Sentinel by mcmonkey4eva.

the class SentinelInfoCommands method info.

@Command(aliases = { "sentinel" }, usage = "info", desc = "Shows info on the current NPC.", modifiers = { "info" }, permission = "sentinel.info", min = 1, max = 2)
@Requirements(livingEntity = true, ownership = true, traits = { SentinelTrait.class })
public void info(CommandContext args, CommandSender sender, SentinelTrait sentinel) {
    String guardName = null;
    LivingEntity guarded = sentinel.getGuardingEntity();
    if (guarded != null) {
        guardName = guarded.getName();
    } else if (sentinel.guardedNPC >= 0 && CitizensAPI.getNPCRegistry().getById(sentinel.guardedNPC) != null) {
        guardName = "NPC " + sentinel.guardedNPC + ": " + CitizensAPI.getNPCRegistry().getById(sentinel.guardedNPC).getFullName();
    } else if (sentinel.getGuarding() != null) {
        OfflinePlayer player = Bukkit.getOfflinePlayer(sentinel.getGuarding());
        if (player != null && player.getName() != null) {
            guardName = player.getName();
        }
    }
    Paginator paginator = new Paginator().header(SentinelCommand.prefixGood + sentinel.getNPC().getFullName());
    addLineIfNeeded(paginator, "Owned by", SentinelPlugin.instance.getOwner(sentinel.getNPC(), ""));
    addLineIfNeeded(paginator, "Guarding", (guardName == null ? "" : guardName));
    addLineIfNeeded(paginator, "Damage", sentinel.damage + SentinelCommand.colorBasic + " Calculated: " + SentinelCommand.colorEmphasis + sentinel.getDamage(true));
    addLineIfNeeded(paginator, "Armor", sentinel.armor + (sentinel.getNPC().isSpawned() ? SentinelCommand.colorBasic + " Calculated: " + SentinelCommand.colorEmphasis + sentinel.getArmor(sentinel.getLivingEntity()) : ""));
    addLineIfNeeded(paginator, "Health", (sentinel.getNPC().isSpawned() ? sentinel.getLivingEntity().getHealth() + "/" : "") + sentinel.health);
    addLineIfNeeded(paginator, "Range", sentinel.range);
    addLineIfNeeded(paginator, "Avoidance Range", sentinel.avoidRange);
    addLineIfNeeded(paginator, "Attack Rate", (sentinel.attackRate / 20.0));
    addLineIfNeeded(paginator, "Ranged Attack Rate", (sentinel.attackRateRanged / 20.0));
    addLineIfNeeded(paginator, "Heal Rate", (sentinel.healRate / 20.0));
    addLineIfNeeded(paginator, "Respawn Time", (sentinel.respawnTime / 20.0));
    addLineIfNeeded(paginator, "Accuracy", sentinel.accuracy);
    addLineIfNeeded(paginator, "Reach", sentinel.reach);
    addLineIfNeeded(paginator, "Projectile Range", sentinel.projectileRange);
    addLineIfNeeded(paginator, "Greeting", (sentinel.greetingText == null ? "" : sentinel.greetingText));
    addLineIfNeeded(paginator, "Warning", (sentinel.warningText == null ? "" : sentinel.warningText));
    addLineIfNeeded(paginator, "Greeting Range", sentinel.greetRange);
    addLineIfNeeded(paginator, "Greeting Rate", sentinel.greetRate);
    addLineIfNeeded(paginator, "Guard Distance Minimum", sentinel.guardDistanceMinimum);
    addLineIfNeeded(paginator, "Guard Selection Range", sentinel.guardSelectionRange);
    addLineIfNeeded(paginator, "Invincibility Enabled", sentinel.invincible);
    addLineIfNeeded(paginator, "Protected Enabled", sentinel.protectFromIgnores);
    addLineIfNeeded(paginator, "Fightback Enabled", sentinel.fightback);
    addLineIfNeeded(paginator, "Ranged Chasing Enabled", sentinel.rangedChase);
    addLineIfNeeded(paginator, "Close-Quarters Chasing Enabled", sentinel.closeChase);
    addLineIfNeeded(paginator, "Maximum chase range", sentinel.chaseRange);
    addLineIfNeeded(paginator, "Safe-Shot Enabled", sentinel.safeShot);
    addLineIfNeeded(paginator, "Enemy-Drops Enabled", sentinel.enemyDrops);
    addLineIfNeeded(paginator, "Autoswitch Enabled", sentinel.autoswitch);
    addLineIfNeeded(paginator, "Realistic Targeting Enabled", sentinel.realistic);
    addLineIfNeeded(paginator, "Knockback allowed", sentinel.allowKnockback);
    addLineIfNeeded(paginator, "Run-Away Enabled", sentinel.runaway);
    addLineIfNeeded(paginator, "Squad", (sentinel.squad == null ? "" : sentinel.squad));
    addLineIfNeeded(paginator, "Spawnpoint", (sentinel.spawnPoint == null ? "" : sentinel.spawnPoint.toVector().toBlockVector().toString()));
    addLineIfNeeded(paginator, "Per-weapon damage values", sentinel.weaponDamage.toString());
    addLineIfNeeded(paginator, "Weapon redirections", sentinel.weaponRedirects.toString());
    addLineIfNeeded(paginator, "Drops", sentinel.drops == null ? "" : sentinel.drops.size());
    addLineIfNeeded(paginator, "Death XP", sentinel.deathXP);
    if (SentinelPlugin.instance.hasWorldGuard) {
        addLineIfNeeded(paginator, "WorldGuard region limit", sentinel.worldguardRegion);
    }
    int page = 1;
    if (args.argsLength() == 2) {
        try {
            page = args.getInteger(1);
        } catch (NumberFormatException ex) {
            sender.sendMessage(SentinelCommand.prefixBad + "First argument must be a valid page number.");
        }
    }
    paginator.sendPage(sender, page);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) OfflinePlayer(org.bukkit.OfflinePlayer) Paginator(net.citizensnpcs.api.util.Paginator) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Aggregations

Paginator (net.citizensnpcs.api.util.Paginator)8 CommandException (net.citizensnpcs.api.command.exception.CommandException)7 Command (net.citizensnpcs.api.command.Command)3 Requirements (net.citizensnpcs.api.command.Requirements)2 ServerCommandException (net.citizensnpcs.api.command.exception.ServerCommandException)2 ArrayList (java.util.ArrayList)1 AssignmentScriptContainer (net.aufdemrand.denizen.scripts.containers.core.AssignmentScriptContainer)1 StringHolder (net.aufdemrand.denizencore.utilities.text.StringHolder)1 NPC (net.citizensnpcs.api.npc.NPC)1 NPCRegistry (net.citizensnpcs.api.npc.NPCRegistry)1 Owner (net.citizensnpcs.api.trait.trait.Owner)1 Anchors (net.citizensnpcs.trait.Anchors)1 Anchor (net.citizensnpcs.util.Anchor)1 Pose (net.citizensnpcs.util.Pose)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)1 EntityType (org.bukkit.entity.EntityType)1 LivingEntity (org.bukkit.entity.LivingEntity)1 Player (org.bukkit.entity.Player)1