Add Expansions command and placeholders.

This commit is contained in:
Olof Larsson 2014-11-12 11:34:43 +01:00
parent 40a666c7c3
commit aa0edb28b7
6 changed files with 144 additions and 0 deletions

View File

@ -19,6 +19,7 @@ public enum Perm
DEMOTE("demote"),
DESCRIPTION("description"),
DISBAND("disband"),
EXPANSIONS("expansions"),
FACTION("faction"),
FLAG("flag"),
HOME("home"),

View File

@ -36,6 +36,7 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsOfficer cmdFactionsOfficer = new CmdFactionsOfficer();
public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader();
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax");
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess();
@ -46,6 +47,8 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm();
public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag();
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions();
public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap");
public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin();
public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
public VersionCommand cmdFactionsVersion = new VersionCommand(Factions.get(), Perm.VERSION.node, "v", "version");
@ -80,6 +83,7 @@ public class CmdFactions extends FactionsCommand
this.addSubCommand(this.cmdFactionsOfficer);
this.addSubCommand(this.cmdFactionsLeader);
this.addSubCommand(this.cmdFactionsMoney);
this.addSubCommand(this.cmdFactionsTax);
this.addSubCommand(this.cmdFactionsSeeChunk);
this.addSubCommand(this.cmdFactionsSeeChunkOld);
this.addSubCommand(this.cmdFactionsAccess);
@ -90,6 +94,8 @@ public class CmdFactions extends FactionsCommand
this.addSubCommand(this.cmdFactionsPerm);
this.addSubCommand(this.cmdFactionsFlag);
this.addSubCommand(this.cmdFactionsDisband);
this.addSubCommand(this.cmdFactionsExpansions);
this.addSubCommand(this.cmdFactionsDynmap);
this.addSubCommand(this.cmdFactionsAdmin);
this.addSubCommand(this.cmdFactionsPowerBoost);
this.addSubCommand(this.cmdFactionsVersion);

View File

@ -0,0 +1,53 @@
package com.massivecraft.factions.cmd;
import java.util.Map.Entry;
import com.massivecraft.factions.event.EventFactionsExpansions;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsExpansions extends FactionsCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsExpansions()
{
// Aliases
this.addAliases("e", "expansions");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.EXPANSIONS.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Event
EventFactionsExpansions event = new EventFactionsExpansions(sender);
event.run();
// Title
msg(Txt.titleize("Factions Expansions"));
// Lines
for (Entry<String, Boolean> entry : event.getExpansions().entrySet())
{
String name = entry.getKey();
Boolean installed = entry.getValue();
String format = (installed ? "<g>[X] <h>%s" : "<b>[ ] <h>%s");
msg(format, name);
}
// URL Suggestion
msg("<i>Learn all about expansions in the online documentation:");
msg("<aqua>http://www.massivecraft.com/factions");
}
}

View File

@ -0,0 +1,42 @@
package com.massivecraft.factions.cmd;
public class CmdFactionsXPlaceholder extends FactionsCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public String extensionName;
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsXPlaceholder(String extensionName, String... aliases)
{
// Fields
this.extensionName = extensionName;
// Aliases
this.addAliases(aliases);
// Desc
this.setDesc("Use " + extensionName);
// Args
this.setErrorOnToManyArgs(false);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
msg("<b>The extension <h>%s <b>isn't installed.", this.extensionName);
msg("<g>Learn more and download the extension here:");
msg("<aqua>http://www.massivecraft.com/%s", this.extensionName.toLowerCase());
}
}

View File

@ -0,0 +1,39 @@
package com.massivecraft.factions.event;
import java.util.Map;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import com.massivecraft.massivecore.CaseInsensitiveComparator;
import com.massivecraft.massivecore.collections.MassiveTreeMap;
public class EventFactionsExpansions extends EventFactionsAbstractSender
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final MassiveTreeMap<String, Boolean, CaseInsensitiveComparator> expansions = new MassiveTreeMap<String, Boolean, CaseInsensitiveComparator>(CaseInsensitiveComparator.get());
public Map<String, Boolean> getExpansions() { return this.expansions; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public EventFactionsExpansions(CommandSender sender)
{
super(sender);
this.getExpansions().put("FactionsTax", false);
this.getExpansions().put("FactionsDynmap", false);
}
}

View File

@ -19,6 +19,7 @@ permissions:
factions.demote: {description: demote lesser members in your faction, default: false}
factions.description: {description: change faction description, default: false}
factions.disband: {description: disband faction, default: false}
factions.expansions: {description: list expansions, default: false}
factions.faction: {description: show faction information, default: false}
factions.flag: {description: manage faction flags, default: false}
factions.home: {description: teleport to faction home, default: false}
@ -78,6 +79,7 @@ permissions:
factions.demote: true
factions.description: true
factions.disband: true
factions.expansions: true
factions.faction: true
factions.flag: true
factions.home: true
@ -160,6 +162,7 @@ permissions:
factions.demote: true
factions.description: true
factions.disband: true
factions.expansions: true
factions.faction: true
factions.flag: true
factions.home: true