Search in sources :

Example 66 with Command

use of net.citizensnpcs.api.command.Command 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

Command (net.citizensnpcs.api.command.Command)66 Requirements (net.citizensnpcs.api.command.Requirements)45 CommandException (net.citizensnpcs.api.command.exception.CommandException)40 ServerCommandException (net.citizensnpcs.api.command.exception.ServerCommandException)27 Location (org.bukkit.Location)13 Player (org.bukkit.entity.Player)13 NPC (net.citizensnpcs.api.npc.NPC)10 CurrentLocation (net.citizensnpcs.trait.CurrentLocation)9 DyeColor (org.bukkit.DyeColor)8 BarColor (org.bukkit.boss.BarColor)5 NoPermissionsException (net.citizensnpcs.api.command.exception.NoPermissionsException)4 Owner (net.citizensnpcs.api.trait.trait.Owner)4 Anchors (net.citizensnpcs.trait.Anchors)4 CommandUsageException (net.citizensnpcs.api.command.exception.CommandUsageException)3 MobType (net.citizensnpcs.api.trait.trait.MobType)3 Paginator (net.citizensnpcs.api.util.Paginator)3 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)3 ScriptTrait (net.citizensnpcs.trait.ScriptTrait)3 SheepTrait (net.citizensnpcs.trait.SheepTrait)3 LocationTag (com.denizenscript.denizen.objects.LocationTag)2