New cape system and refactored spout appearances.

This commit is contained in:
Olof Larsson
2012-05-09 03:24:07 +02:00
parent 1f51ee9699
commit ca6b185bd1
25 changed files with 446 additions and 309 deletions

View File

@ -0,0 +1,52 @@
package com.massivecraft.factions.cmd;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.FPerm;
public abstract class CapeCommand extends FCommand
{
public Faction capeFaction;
public String currentCape;
public CapeCommand()
{
this.optionalArgs.put("faction", "your");
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}
@Override
public boolean validCall(CommandSender sender, List<String> args)
{
if ( ! super.validCall(sender, args)) return false;
this.capeFaction = null;
this.currentCape = null;
if (this.myFaction == null && ! this.argIsSet(this.requiredArgs.size()))
{
msg("<b>You must specify a faction from console.");
return false;
}
this.capeFaction = this.argAsFaction(this.requiredArgs.size(), this.myFaction);
if (this.capeFaction == null) return false;
// Do we have permission to manage the cape of that faction?
if (fme != null && ! FPerm.CAPE.has(fme, capeFaction)) return false;
this.currentCape = this.capeFaction.getCape();
return true;
}
}

View File

@ -0,0 +1,36 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class CmdCape extends FCommand
{
public CmdCapeGet cmdCapeGet = new CmdCapeGet();
public CmdCapeSet cmdCapeSet = new CmdCapeSet();
public CmdCapeRemove cmdCapeRemove = new CmdCapeRemove();
public CmdCape()
{
super();
this.aliases.add("cape");
this.permission = Permission.CAPE.node;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
this.addSubCommand(this.cmdCapeGet);
this.addSubCommand(this.cmdCapeSet);
this.addSubCommand(this.cmdCapeRemove);
}
@Override
public void perform()
{
this.commandChain.add(this);
P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
}
}

View File

@ -0,0 +1,25 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.struct.Permission;
public class CmdCapeGet extends CapeCommand
{
public CmdCapeGet()
{
this.aliases.add("get");
this.permission = Permission.CAPE_GET.node;
}
@Override
public void perform()
{
if (currentCape == null)
{
msg("<h>%s <i>has no cape set.", capeFaction.describeTo(fme, true));
}
else
{
msg("<i>The cape of <h>%s <i>is \"<h>%s<i>\".", capeFaction.describeTo(fme, true), currentCape);
}
}
}

View File

@ -0,0 +1,35 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.RelationUtil;
public class CmdCapeRemove extends CapeCommand
{
public CmdCapeRemove()
{
this.aliases.add("rm");
this.aliases.add("rem");
this.aliases.add("remove");
this.aliases.add("del");
this.aliases.add("delete");
this.permission = Permission.CAPE_REMOVE.node;
}
@Override
public void perform()
{
if (currentCape == null)
{
msg("<h>%s <i>has no cape set.", capeFaction.describeTo(fme, true));
}
else
{
capeFaction.setCape(null);
SpoutFeatures.updateCape(capeFaction, null);
msg("<h>%s <i>removed the cape from <h>%s<i>.", RelationUtil.describeThatToMe(fme, fme, true), capeFaction.describeTo(fme));
capeFaction.msg("<h>%s <i>removed the cape from <h>%s<i>.", RelationUtil.describeThatToMe(fme, capeFaction, true), capeFaction.describeTo(capeFaction));
}
}
}

View File

@ -0,0 +1,49 @@
package com.massivecraft.factions.cmd;
import java.net.URL;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.RelationUtil;
public class CmdCapeSet extends CapeCommand
{
public CmdCapeSet()
{
this.aliases.add("set");
this.requiredArgs.add("url");
this.permission = Permission.CAPE_SET.node;
}
@Override
public void perform()
{
String newCape = this.argAsString(0);
if (isUrlValid(newCape))
{
capeFaction.setCape(newCape);
SpoutFeatures.updateCape(capeFaction, null);
msg("<h>%s <i>set the cape of <h>%s<i> to \"<h>%s<i>\".", RelationUtil.describeThatToMe(fme, fme, true), capeFaction.describeTo(fme), newCape);
capeFaction.msg("<h>%s <i>set the cape of <h>%s<i> to \"<h>%s<i>\".", RelationUtil.describeThatToMe(fme, capeFaction, true), capeFaction.describeTo(capeFaction), newCape);
}
else
{
msg("<i>\"<h>%s<i>\" is not a valid URL.", newCape);
}
}
public static boolean isUrlValid(String urlString)
{
try
{
new URL(urlString);
return true;
}
catch (Exception e)
{
return false;
}
}
}

View File

@ -393,7 +393,8 @@ public class CmdConfig extends FCommand
Conf.save();
// in case some Spout related setting was changed
SpoutFeatures.updateAppearances();
SpoutFeatures.updateTitle(null, null);
//SpoutFeatures.updateCape(null);
}
}

View File

@ -91,6 +91,7 @@ public class CmdDisband extends FCommand
faction.detach();
SpoutFeatures.updateAppearances();
SpoutFeatures.updateTitle(null, null);
SpoutFeatures.updateCape(null, null);
}
}

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.FPerm;
import com.massivecraft.factions.struct.Permission;
public class CmdInvite extends FCommand
@ -37,6 +38,8 @@ public class CmdInvite extends FCommand
return;
}
if (fme != null && ! FPerm.INVITE.has(fme, myFaction)) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) return;

View File

@ -27,7 +27,7 @@ public class CmdKick extends FCommand
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeOfficer = true;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}

View File

@ -78,7 +78,7 @@ public class CmdTag extends FCommand
if (Conf.spoutFactionTagsOverNames)
{
SpoutFeatures.updateAppearances(myFaction);
SpoutFeatures.updateTitle(myFaction, null);
}
}

View File

@ -45,7 +45,7 @@ public class CmdTitle extends FCommand
if (Conf.spoutFactionTitlesOverNames)
{
SpoutFeatures.updateAppearances(me);
SpoutFeatures.updateTitle(me, null);
}
}

View File

@ -9,6 +9,7 @@ public class FCmdRoot extends FCommand
public CmdLeader cmdLeader = new CmdLeader();
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
public CmdAdmin cmdBypass = new CmdAdmin();
public CmdCape cmdCape = new CmdCape();
public CmdClaim cmdClaim = new CmdClaim();
public CmdConfig cmdConfig = new CmdConfig();
public CmdCreate cmdCreate = new CmdCreate();
@ -71,6 +72,7 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdLeader);
this.addSubCommand(this.cmdAutoClaim);
this.addSubCommand(this.cmdBypass);
this.addSubCommand(this.cmdCape);
this.addSubCommand(this.cmdClaim);
this.addSubCommand(this.cmdConfig);
this.addSubCommand(this.cmdCreate);

View File

@ -93,7 +93,7 @@ public abstract class FRelationCommand extends FCommand
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
}
SpoutFeatures.updateAppearances(myFaction, them);
SpoutFeatures.updateTitle(myFaction, them);
SpoutFeatures.updateTerritoryDisplayLoc(null);
}
}