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);
}
}
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);
}
}
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);
}
Aggregations