Major messaround with the internal events and payForCommand logic. Not done just yet though.

This commit is contained in:
Olof Larsson
2013-04-19 12:27:39 +02:00
parent d3488311de
commit 61baf70ed1
46 changed files with 638 additions and 626 deletions

View File

@ -17,7 +17,6 @@ public class CmdFactions extends FCommand
public CmdFactionsCape cmdFactionsCape = new CmdFactionsCape();
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
public CmdFactionsDeinvite cmdFactionsDeinvite = new CmdFactionsDeinvite();
public CmdFactionsDemote cmdFactionsDemote = new CmdFactionsDemote();
public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
@ -77,7 +76,6 @@ public class CmdFactions extends FCommand
this.addSubCommand(this.cmdFactionsPerm);
this.addSubCommand(this.cmdFactionsFlag);
this.addSubCommand(this.cmdFactionsInvite);
this.addSubCommand(this.cmdFactionsDeinvite);
this.addSubCommand(this.cmdFactionsOpen);
this.addSubCommand(this.cmdFactionsMoney);
this.addSubCommand(this.cmdFactionsClaim);

View File

@ -12,8 +12,8 @@ import com.massivecraft.factions.FactionColl;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.event.FactionCreateEvent;
import com.massivecraft.factions.event.FactionsEventJoin;
import com.massivecraft.factions.event.FactionsEventCreate;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsCreate extends FCommand
@ -54,29 +54,19 @@ public class CmdFactionsCreate extends FCommand
// trigger the faction creation event (cancellable)
String factionId = FactionColl.get().getIdStrategy().generate(FactionColl.get());
FactionCreateEvent createEvent = new FactionCreateEvent(sender, tag, factionId);
FactionsEventCreate createEvent = new FactionsEventCreate(sender, tag, factionId);
Bukkit.getServer().getPluginManager().callEvent(createEvent);
if(createEvent.isCancelled()) return;
// then make 'em pay (if applicable)
if (!payForCommand(ConfServer.econCostCreate)) return;
if (createEvent.isCancelled()) return;
Faction faction = FactionColl.get().create(factionId);
// TODO: Why would this even happen??? Auto increment clash??
if (faction == null)
{
msg("<b>There was an internal error while trying to create your faction. Please try again.");
return;
}
// finish setting up the Faction
faction.setTag(tag);
// trigger the faction join event for the creator
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(sender),faction,FPlayerJoinEvent.PlayerJoinReason.CREATE);
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
// join event cannot be cancelled or you'll have an empty faction
FactionsEventJoin joinEvent = new FactionsEventJoin(sender, fme, faction, FactionsEventJoin.PlayerJoinReason.CREATE);
joinEvent.run();
// NOTE: join event cannot be cancelled or you'll have an empty faction
// finish setting up the FPlayer
fme.setRole(Rel.LEADER);

View File

@ -1,44 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsDeinvite extends FCommand
{
public CmdFactionsDeinvite()
{
this.addAliases("deinvite", "deinv");
this.addRequiredArg("player");
this.addRequirements(ReqHasPerm.get(Perm.DEINVITE.node));
}
@Override
public void perform()
{
if ( ! FPerm.INVITE.has(sender, myFaction, true)) return;
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
if (you.getFaction() == myFaction)
{
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
msg("<i>You might want to: %s", Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false));
return;
}
myFaction.deinvite(you);
you.msg("%s<i> revoked your invitation to <h>%s<i>.", fme.describeTo(you), myFaction.describeTo(you));
myFaction.msg("%s<i> revoked %s's<i> invitation.", fme.describeTo(myFaction), you.describeTo(myFaction));
}
}

View File

@ -1,9 +1,9 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionsEventDescriptionChange;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.mixin.Mixin;
@ -23,11 +23,19 @@ public class CmdFactionsDescription extends FCommand
@Override
public void perform()
{
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(ConfServer.econCostDesc)) return;
// Args
String newDescription = this.argConcatFrom(1);
// Event
FactionsEventDescriptionChange event = new FactionsEventDescriptionChange(sender, myFaction, newDescription);
event.run();
if (event.isCancelled()) return;
newDescription = event.getNewDescription();
// Apply
myFaction.setDescription(this.argConcatFrom(1));
// Inform
myFaction.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender), myFaction.getDescription());
}

View File

@ -4,8 +4,8 @@ import org.bukkit.Bukkit;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FactionDisbandEvent;
import com.massivecraft.factions.event.FactionsEventLeave;
import com.massivecraft.factions.event.FactionsEventDisband;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
@ -42,14 +42,15 @@ public class CmdFactionsDisband extends FCommand
return;
}
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
FactionsEventDisband disbandEvent = new FactionsEventDisband(me, faction);
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
if(disbandEvent.isCancelled()) return;
// Send FPlayerLeaveEvent for each player in the faction
for ( FPlayer fplayer : faction.getFPlayers() )
{
Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, faction, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND));
FactionsEventLeave leaveEvent = new FactionsEventLeave(sender, fplayer, faction, FactionsEventLeave.PlayerLeaveReason.DISBAND);
leaveEvent.run();
}
// Inform all players

View File

@ -1,11 +1,12 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.event.FactionsEventInvitedChange;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
@ -16,6 +17,7 @@ public class CmdFactionsInvite extends FCommand
this.addAliases("inv", "invite");
this.addRequiredArg("player");
this.addOptionalArg("yes/no", "toggle");
this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
this.addRequirements(ReqIsPlayer.get());
@ -24,27 +26,44 @@ public class CmdFactionsInvite extends FCommand
@Override
public void perform()
{
if ( ! FPerm.INVITE.has(sender, myFaction, true)) return;
// Args
FPlayer fplayer = this.arg(0, ARFPlayer.getStartAny());
if (fplayer == null) return;
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
Boolean newInvited = this.arg(1, ARBoolean.get(), !myFaction.isInvited(fplayer));
if (newInvited == null) return;
if (you.getFaction() == myFaction)
// Allready member?
if (fplayer.getFaction() == myFaction)
{
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
msg("%s<i> is already a member of %s", fplayer.getName(), myFaction.getTag());
msg("<i>You might want to: " + Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false));
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(ConfServer.econCostInvite)) return;
myFaction.invite(you);
// FPerm
if ( ! FPerm.INVITE.has(sender, myFaction, true)) return;
you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
myFaction.msg("%s<i> invited %s<i> to your faction.", fme.describeTo(myFaction, true), you.describeTo(myFaction));
// Event
FactionsEventInvitedChange event = new FactionsEventInvitedChange(sender, fplayer, myFaction, newInvited);
event.run();
if (event.isCancelled()) return;
newInvited = event.isNewInvited();
// Apply
myFaction.setInvited(fplayer, newInvited);
// Inform
if (newInvited)
{
fplayer.msg("%s<i> invited you to %s", fme.describeTo(fplayer, true), myFaction.describeTo(fplayer));
myFaction.msg("%s<i> invited %s<i> to your faction.", fme.describeTo(myFaction, true), fplayer.describeTo(myFaction));
}
else
{
fplayer.msg("%s<i> revoked your invitation to <h>%s<i>.", fme.describeTo(fplayer), myFaction.describeTo(fplayer));
myFaction.msg("%s<i> revoked %s's<i> invitation.", fme.describeTo(myFaction), fplayer.describeTo(myFaction));
}
}
}

View File

@ -10,7 +10,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.event.FactionsEventJoin;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsJoin extends FCommand
@ -75,7 +75,7 @@ public class CmdFactionsJoin extends FCommand
}
// trigger the join event (cancellable)
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND);
FactionsEventJoin joinEvent = new FactionsEventJoin(FPlayerColl.get().get(me),faction,FactionsEventJoin.PlayerJoinReason.JOIN);
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
if (joinEvent.isCancelled()) return;

View File

@ -10,7 +10,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FactionsEventLeave;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsKick extends FCommand
@ -55,7 +55,7 @@ public class CmdFactionsKick extends FCommand
if (fme != null && ! FPerm.KICK.has(fme, yourFaction)) return;
// trigger the leave event (cancellable) [reason:kicked]
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
FactionsEventLeave event = new FactionsEventLeave(you, you.getFaction(), FactionsEventLeave.PlayerLeaveReason.KICKED);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) return;

View File

@ -1,7 +1,5 @@
package com.massivecraft.factions.cmd;
import org.bukkit.Bukkit;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayerColl;
import com.massivecraft.factions.Faction;
@ -9,7 +7,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.event.FactionsEventJoin;
import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -67,8 +65,8 @@ public class CmdFactionsLeader extends FCommand
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
if (newLeader.getFaction() != targetFaction)
{
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayerColl.get().get(me),targetFaction,FPlayerJoinEvent.PlayerJoinReason.LEADER);
Bukkit.getServer().getPluginManager().callEvent(event);
FactionsEventJoin event = new FactionsEventJoin(sender, newLeader, targetFaction, FactionsEventJoin.PlayerJoinReason.LEADER);
event.run();
if (event.isCancelled()) return;
}

View File

@ -1,11 +1,11 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionColl;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionsEventOpenChange;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -24,17 +24,21 @@ public class CmdFactionsOpen extends FCommand
@Override
public void perform()
{
Boolean target = this.arg(0, ARBoolean.get(), !myFaction.isOpen());
if (target == null) return;
// Args
Boolean newOpen = this.arg(0, ARBoolean.get(), !myFaction.isOpen());
if (newOpen == null) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(ConfServer.econCostOpen)) return;
// Event
FactionsEventOpenChange event = new FactionsEventOpenChange(sender, myFaction, newOpen);
event.run();
if (event.isCancelled()) return;
newOpen = event.isNewOpen();
myFaction.setOpen(target);
String descTarget = myFaction.isOpen() ? "open" : "closed";
// Apply
myFaction.setOpen(newOpen);
// Inform
String descTarget = myFaction.isOpen() ? "open" : "closed";
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), descTarget);
for (Faction faction : FactionColl.get().getAll())
{

View File

@ -1,7 +1,5 @@
package com.massivecraft.factions.cmd;
import org.bukkit.Bukkit;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Faction;
@ -9,7 +7,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionRelationEvent;
import com.massivecraft.factions.event.FactionsEventRelationChange;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -28,8 +26,11 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
@Override
public void perform()
{
Faction them = this.arg(0, ARFaction.get());
if (them == null) return;
// Args
Faction otherFaction = this.arg(0, ARFaction.get());
if (otherFaction == null) return;
Rel newRelation = targetRelation;
/*if ( ! them.isNormal())
{
@ -37,60 +38,60 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
return;
}*/
if (them == myFaction)
// Verify
if (otherFaction == myFaction)
{
msg("<b>Nope! You can't declare a relation to yourself :)");
return;
}
if (myFaction.getRelationWish(them) == targetRelation)
if (myFaction.getRelationWish(otherFaction) == newRelation)
{
msg("<b>You already have that relation wish set with %s.", them.getTag());
msg("<b>You already have that relation wish set with %s.", otherFaction.getTag());
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(targetRelation.getRelationCost())) return;
// Event
FactionsEventRelationChange event = new FactionsEventRelationChange(sender, myFaction, otherFaction, newRelation);
event.run();
if (event.isCancelled()) return;
newRelation = event.getNewRelation();
// try to set the new relation
Rel oldRelation = myFaction.getRelationTo(them, true);
myFaction.setRelationWish(them, targetRelation);
Rel currentRelation = myFaction.getRelationTo(them, true);
myFaction.setRelationWish(otherFaction, newRelation);
Rel currentRelation = myFaction.getRelationTo(otherFaction, true);
// if the relation change was successful
if (targetRelation == currentRelation)
if (newRelation == currentRelation)
{
// trigger the faction relation event
FactionRelationEvent relationEvent = new FactionRelationEvent(myFaction, them, oldRelation, currentRelation);
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
them.msg("%s<i> is now %s.", myFaction.describeTo(them, true), targetRelation.getDescFactionOne());
myFaction.msg("%s<i> is now %s.", them.describeTo(myFaction, true), targetRelation.getDescFactionOne());
otherFaction.msg("%s<i> is now %s.", myFaction.describeTo(otherFaction, true), newRelation.getDescFactionOne());
myFaction.msg("%s<i> is now %s.", otherFaction.describeTo(myFaction, true), newRelation.getDescFactionOne());
}
// inform the other faction of your request
else
{
them.msg("%s<i> wishes to be %s.", myFaction.describeTo(them, true), targetRelation.getColor()+targetRelation.getDescFactionOne());
them.msg("<i>Type <c>/"+ConfServer.baseCommandAliases.get(0)+" "+targetRelation+" "+myFaction.getTag()+"<i> to accept.");
myFaction.msg("%s<i> were informed that you wish to be %s<i>.", them.describeTo(myFaction, true), targetRelation.getColor()+targetRelation.getDescFactionOne());
otherFaction.msg("%s<i> wishes to be %s.", myFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
otherFaction.msg("<i>Type <c>/"+ConfServer.baseCommandAliases.get(0)+" "+newRelation+" "+myFaction.getTag()+"<i> to accept.");
myFaction.msg("%s<i> were informed that you wish to be %s<i>.", otherFaction.describeTo(myFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
}
// TODO: The ally case should work!!
// * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only
if ( targetRelation != Rel.TRUCE && them.getFlag(FFlag.PEACEFUL))
if ( newRelation != Rel.TRUCE && otherFaction.getFlag(FFlag.PEACEFUL))
{
them.msg("<i>This will have no effect while your faction is peaceful.");
otherFaction.msg("<i>This will have no effect while your faction is peaceful.");
myFaction.msg("<i>This will have no effect while their faction is peaceful.");
}
if ( targetRelation != Rel.TRUCE && myFaction.getFlag(FFlag.PEACEFUL))
if ( newRelation != Rel.TRUCE && myFaction.getFlag(FFlag.PEACEFUL))
{
them.msg("<i>This will have no effect while their faction is peaceful.");
otherFaction.msg("<i>This will have no effect while their faction is peaceful.");
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
}
SpoutFeatures.updateTitle(myFaction, them);
SpoutFeatures.updateTitle(them, myFaction);
SpoutFeatures.updateTitle(myFaction, otherFaction);
SpoutFeatures.updateTitle(otherFaction, myFaction);
SpoutFeatures.updateTerritoryDisplayLoc(null);
}
}

View File

@ -6,7 +6,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FactionsHomeChangeEvent;
import com.massivecraft.factions.event.FactionsEventHomeChange;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
import com.massivecraft.mcore.ps.PS;
@ -48,14 +48,11 @@ public class CmdFactionsSethome extends FCommand
return;
}
FactionsHomeChangeEvent event = new FactionsHomeChangeEvent(sender, FactionsHomeChangeEvent.REASON_COMMAND_SETHOME, faction, newHome);
FactionsEventHomeChange event = new FactionsEventHomeChange(sender, faction, newHome);
event.run();
if (event.isCancelled()) return;
newHome = event.getNewHome();
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(ConfServer.econCostSethome)) return;
faction.setHome(newHome);
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));

View File

@ -10,7 +10,7 @@ import com.massivecraft.factions.FactionColl;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionRenameEvent;
import com.massivecraft.factions.event.FactionsEventTagChange;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -31,33 +31,33 @@ public class CmdFactionsTag extends FCommand
@Override
public void perform()
{
String tag = this.arg(0);
// Arg
String newTag = this.arg(0);
// TODO does not first test cover selfcase?
if (FactionColl.get().isTagTaken(tag) && ! MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag()))
if (FactionColl.get().isTagTaken(newTag) && ! MiscUtil.getComparisonString(newTag).equals(myFaction.getComparisonTag()))
{
msg("<b>That tag is already taken");
return;
}
ArrayList<String> errors = new ArrayList<String>();
errors.addAll(FactionColl.validateTag(tag));
errors.addAll(FactionColl.validateTag(newTag));
if (errors.size() > 0)
{
sendMessage(errors);
return;
}
// trigger the faction rename event (cancellable)
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
// Event
FactionsEventTagChange renameEvent = new FactionsEventTagChange(sender, myFaction, newTag);
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
if(renameEvent.isCancelled()) return;
// then make 'em pay (if applicable)
if (!payForCommand(ConfServer.econCostTag)) return;
if (renameEvent.isCancelled()) return;
newTag = renameEvent.getNewTag();
// Apply
String oldtag = myFaction.getTag();
myFaction.setTag(tag);
myFaction.setTag(newTag);
// Inform
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionsEventTitleChange;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.mcore.cmd.arg.ARString;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -26,18 +27,24 @@ public class CmdFactionsTitle extends FCommand
@Override
public void perform()
{
// Args
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
String title = this.argConcatFrom(1, ARString.get(), "");
if (title == null) return;
String newTitle = this.argConcatFrom(1, ARString.get(), "");
if (newTitle == null) return;
// Verify
if ( ! canIAdministerYou(fme, you)) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(ConfServer.econCostTitle)) return;
// Event
FactionsEventTitleChange event = new FactionsEventTitleChange(sender, you, newTitle);
event.run();
if (event.isCancelled()) return;
newTitle = event.getNewTitle();
you.setTitle(title);
// Apply
you.setTitle(newTitle);
// Inform
myFaction.msg("%s<i> changed a title: %s", fme.describeTo(myFaction, true), you.describeTo(myFaction, true));

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd;
import org.bukkit.Bukkit;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.event.LandUnclaimEvent;
import com.massivecraft.factions.event.FactionsEventLandUnclaim;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.BoardColl;
@ -33,7 +33,7 @@ public class CmdFactionsUnclaim extends FCommand
if ( ! FPerm.TERRITORY.has(sender, otherFaction, true)) return;
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(chunk, otherFaction, fme);
FactionsEventLandUnclaim unclaimEvent = new FactionsEventLandUnclaim(sender, otherFaction, chunk);
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
if(unclaimEvent.isCancelled()) return;

View File

@ -8,7 +8,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.LandUnclaimAllEvent;
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -39,7 +39,7 @@ public class CmdFactionsUnclaimall extends FCommand
}
}
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
FactionsEventLandUnclaimAll unclaimAllEvent = new FactionsEventLandUnclaimAll(sender, myFaction);
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
// this event cannot be cancelled

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayerColl;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.util.Txt;
@ -61,8 +60,8 @@ public abstract class FCommand extends MCommand
}
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost)
/*public boolean payForCommand(double cost)
{
return Econ.payForAction(cost, sender, this.getDesc());
}
}*/
}