Server admins can now promote or demote any member of any faction to/from faction leader or officer using the existing /f leader and /f officer commands, with two new permissions added to allow that. A third permission is also added to allow server admins or moderators to join any faction without the need of /f bypass mode.
Also, a couple more minor bugfixes are included for /f home payment giving the wrong message, player/faction descriptions being wrong for console messages, and potential NPE in new faction leader promotion routine if faction was permanent with no current leader. New permissions: factions.leader.any - allows use of /f leader on any player in any faction factions officer.any - allows use of /f officer on any player in any faction factions.join.any - allows player to join any faction, bypassing invitation process for closed factions (the same as players with /f bypass enabled can do)
This commit is contained in:
parent
46d7e9f4c5
commit
bc40f3b751
@ -25,6 +25,9 @@ permissions:
|
||||
children:
|
||||
factions.kit.halfmod: true
|
||||
factions.flag.set: true
|
||||
factions.join.any: true
|
||||
factions.leader.any: true
|
||||
factions.officer.any: true
|
||||
factions.kit.halfmod:
|
||||
description: Can use adminmode and chat spy
|
||||
children:
|
||||
@ -102,10 +105,14 @@ permissions:
|
||||
description: invite a player to your faction
|
||||
factions.join:
|
||||
description: join a faction
|
||||
factions.join.any:
|
||||
description: join any faction, bypassing invitation process for closed factions
|
||||
factions.kick:
|
||||
description: kick a player from the faction
|
||||
factions.leader:
|
||||
description: hand over leader rights
|
||||
factions.leader.any:
|
||||
description: give or revoke leader status for any player in any faction
|
||||
factions.leave:
|
||||
description: leave your faction
|
||||
factions.list:
|
||||
@ -139,6 +146,8 @@ permissions:
|
||||
factions.money.withdraw: true
|
||||
factions.officer:
|
||||
description: give or revoke officer rights
|
||||
factions.officer.any:
|
||||
description: give or revoke officer rights for any player in any faction
|
||||
factions.open:
|
||||
description: switch if invitation is required to join
|
||||
factions.perm:
|
||||
|
@ -443,7 +443,8 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
{ // faction leader is the only member; one-man faction
|
||||
if (this.getFlag(FFlag.PERMANENT))
|
||||
{
|
||||
oldLeader.setRole(Rel.MEMBER);
|
||||
if (oldLeader != null)
|
||||
oldLeader.setRole(Rel.MEMBER);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -460,9 +461,10 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
else
|
||||
{ // promote new faction leader
|
||||
oldLeader.setRole(Rel.MEMBER);
|
||||
if (oldLeader != null)
|
||||
oldLeader.setRole(Rel.MEMBER);
|
||||
replacements.get(0).setRole(Rel.LEADER);
|
||||
this.msg("<i>Faction leader <h>%s<i> has been removed. %s<i> has been promoted as the new faction leader.", oldLeader.getName(), replacements.get(0).getName());
|
||||
this.msg("<i>Faction leader <h>%s<i> has been removed. %s<i> has been promoted as the new faction leader.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
||||
P.p.log("Faction "+this.getTag()+" ("+this.getId()+") leader was removed. Replacement leader: "+replacements.get(0).getName());
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class CmdHome extends FCommand
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if ( ! payForCommand(Conf.econCostHome, "to change faction home", "for changing faction home")) return;
|
||||
if ( ! payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) return;
|
||||
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled)
|
||||
|
@ -54,7 +54,7 @@ public class CmdJoin extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! (faction.getOpen() || faction.isInvited(fme) || fme.hasAdminMode()))
|
||||
if( ! (faction.getOpen() || faction.isInvited(fme) || fme.hasAdminMode() || Permission.JOIN_ANY.has(sender, false)))
|
||||
{
|
||||
msg("<i>This faction requires invitation.");
|
||||
faction.msg("%s<i> tried to join your faction.", fme.describeTo(faction, true));
|
||||
|
@ -38,7 +38,7 @@ public class CmdLeader extends FCommand
|
||||
FPlayer targetFactionCurrentLeader = targetFaction.getFPlayerLeader();
|
||||
|
||||
// We now have fplayer and the target faction
|
||||
if (this.senderIsConsole || fme.hasAdminMode())
|
||||
if (this.senderIsConsole || fme.hasAdminMode() || Permission.LEADER_ANY.has(sender, false))
|
||||
{
|
||||
// Do whatever you wish
|
||||
}
|
||||
@ -47,7 +47,7 @@ public class CmdLeader extends FCommand
|
||||
// Follow the standard rules
|
||||
if (fme.getRole() != Rel.LEADER)
|
||||
{
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction leaders can %s.", this.getHelpShort()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,6 +64,15 @@ public class CmdLeader extends FCommand
|
||||
}
|
||||
}
|
||||
|
||||
// if target player is currently leader, demote and replace him
|
||||
if (targetFactionCurrentLeader == newLeader)
|
||||
{
|
||||
targetFaction.promoteNewLeader();
|
||||
msg("<i>You have demoted %s<i> from the position of faction leader.", newLeader.describeTo(fme, true));
|
||||
newLeader.msg("<i>You have been demoted from the position of faction leader by %s<i>.", senderIsConsole ? "a server admin" : fme.describeTo(newLeader, true));
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform the switching
|
||||
if (targetFactionCurrentLeader != null)
|
||||
{
|
||||
@ -71,11 +80,12 @@ public class CmdLeader extends FCommand
|
||||
}
|
||||
newLeader.setFaction(targetFaction);
|
||||
newLeader.setRole(Rel.LEADER);
|
||||
msg("<i>You have promoted %s<i> to the position of faction leader.", newLeader.describeTo(fme, true));
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||
{
|
||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s", RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
@ -18,10 +19,10 @@ public class CmdOfficer extends FCommand
|
||||
this.permission = Permission.OFFICER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = true;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -29,30 +30,47 @@ public class CmdOfficer extends FCommand
|
||||
{
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) return;
|
||||
|
||||
if (you.getFaction() != myFaction)
|
||||
|
||||
boolean permAny = Permission.OFFICER_ANY.has(sender, false);
|
||||
Faction targetFaction = you.getFaction();
|
||||
|
||||
if (targetFaction != myFaction && !permAny)
|
||||
{
|
||||
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (you == fme)
|
||||
if (fme != null && fme.getRole() != Rel.LEADER && !permAny)
|
||||
{
|
||||
msg("<b>You are not the faction leader.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you == fme && !permAny)
|
||||
{
|
||||
msg("<b>The target player musn't be yourself.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Rel.LEADER)
|
||||
{
|
||||
msg("<b>The target player is a faction leader. Demote them first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Rel.OFFICER)
|
||||
{
|
||||
// Revoke
|
||||
you.setRole(Rel.MEMBER);
|
||||
myFaction.msg("%s<i> is no longer officer in your faction.", you.describeTo(myFaction, true));
|
||||
targetFaction.msg("%s<i> is no longer officer in your faction.", you.describeTo(targetFaction, true));
|
||||
msg("<i>You have removed officer status from %s<i>.", you.describeTo(fme, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Give
|
||||
you.setRole(Rel.OFFICER);
|
||||
myFaction.msg("%s<i> was promoted to officer in your faction.", you.describeTo(myFaction, true));
|
||||
targetFaction.msg("%s<i> was promoted to officer in your faction.", you.describeTo(targetFaction, true));
|
||||
msg("<i>You have promoted %s<i> to officer.", you.describeTo(fme, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,10 @@ public enum Permission
|
||||
HOME("home"),
|
||||
INVITE("invite"),
|
||||
JOIN("join"),
|
||||
JOIN_ANY("join.any"),
|
||||
KICK("kick"),
|
||||
LEADER("leader"),
|
||||
LEADER_ANY("leader.any"),
|
||||
LEAVE("leave"),
|
||||
LIST("list"),
|
||||
LOCK("lock"),
|
||||
@ -35,6 +37,7 @@ public enum Permission
|
||||
MONEY_P2F("money.p2f"),
|
||||
MONEY_WITHDRAW("money.withdraw"),
|
||||
OFFICER("officer"),
|
||||
OFFICER_ANY("officer.any"),
|
||||
OPEN("open"),
|
||||
PERM("perm"),
|
||||
POWER("power"),
|
||||
|
@ -25,7 +25,7 @@ public class RelationUtil
|
||||
if (thatFaction == null) return "ERROR"; // ERROR
|
||||
|
||||
Faction myFaction = getFaction(me);
|
||||
if (myFaction == null) return thatFaction.getTag(); // no relation, but can show basic faction tag
|
||||
// if (myFaction == null) return thatFaction.getTag(); // no relation, but can show basic name or tag
|
||||
|
||||
if (that instanceof Faction)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user