mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-12-26 18:48:13 +01:00
Server admins can now promote or demote any member of any faction to/from faction admin or moderator using the existing /f admin and /f mod commands, which can now also be used from the server console. Two new permissions are 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 admin promotion routine if faction was permanent with no current admin. New permissions: factions.admin.any - allows use of /f admin on any player in any faction factions mod.any - allows use of /f mod 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
a44336ff04
commit
edcb681210
@ -30,6 +30,9 @@ permissions:
|
||||
factions.setpeaceful: true
|
||||
factions.sethome.any: true
|
||||
factions.money.*: true
|
||||
factions.join.any: true
|
||||
factions.admin.any: true
|
||||
factions.mod.any: true
|
||||
factions.kit.halfmod:
|
||||
description: Zones, bypassing, kicking, and chatspy
|
||||
children:
|
||||
@ -82,6 +85,8 @@ permissions:
|
||||
factions.unclaimall: true
|
||||
factions.admin:
|
||||
description: hand over your admin rights
|
||||
factions.admin.any:
|
||||
description: give or revoke admin status for any player in any faction
|
||||
factions.autoclaim:
|
||||
description: auto-claim land as you walk around
|
||||
factions.bypass:
|
||||
@ -112,6 +117,8 @@ 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.kick.any:
|
||||
@ -130,6 +137,8 @@ permissions:
|
||||
description: show the territory map, and set optional auto update
|
||||
factions.mod:
|
||||
description: give or revoke moderator rights
|
||||
factions.mod.any:
|
||||
description: give or revoke moderator rights for any player in any faction
|
||||
factions.money.balance:
|
||||
description: show your factions current money balance
|
||||
factions.money.balance.any:
|
||||
|
@ -461,6 +461,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
{ // faction admin is the only member; one-man faction
|
||||
if (this.isPermanent())
|
||||
{
|
||||
if (oldLeader != null)
|
||||
oldLeader.setRole(Role.NORMAL);
|
||||
return;
|
||||
}
|
||||
@ -478,9 +479,10 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
else
|
||||
{ // promote new faction admin
|
||||
if (oldLeader != null)
|
||||
oldLeader.setRole(Role.NORMAL);
|
||||
replacements.get(0).setRole(Role.ADMIN);
|
||||
this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> has been promoted as the new faction admin.", oldLeader.getName(), replacements.get(0).getName());
|
||||
this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
||||
P.p.log("Faction "+this.getTag()+" ("+this.getId()+") admin was removed. Replacement admin: "+replacements.get(0).getName());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
@ -18,10 +19,10 @@ public class CmdAdmin extends FCommand
|
||||
this.permission = Permission.ADMIN.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,25 +31,48 @@ public class CmdAdmin extends FCommand
|
||||
FPlayer fyou = this.argAsBestFPlayerMatch(0);
|
||||
if (fyou == null) return;
|
||||
|
||||
if (fyou.getFaction() != myFaction)
|
||||
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
|
||||
Faction targetFaction = fyou.getFaction();
|
||||
|
||||
if (targetFaction != myFaction && !permAny)
|
||||
{
|
||||
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (fyou == fme)
|
||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny)
|
||||
{
|
||||
msg("<b>You are not the faction admin.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fyou == fme && !permAny)
|
||||
{
|
||||
msg("<b>The target player musn't be yourself.");
|
||||
return;
|
||||
}
|
||||
|
||||
fme.setRole(Role.MODERATOR);
|
||||
FPlayer admin = targetFaction.getFPlayerAdmin();
|
||||
|
||||
// if target player is currently admin, demote and replace him
|
||||
if (fyou == admin)
|
||||
{
|
||||
targetFaction.promoteNewLeader();
|
||||
msg("<i>You have demoted %s<i> from the position of faction admin.", fyou.describeTo(fme, true));
|
||||
fyou.msg("<i>You have been demoted from the position of faction admin by %s<i>.", senderIsConsole ? "a server admin" : fme.describeTo(fyou, true));
|
||||
return;
|
||||
}
|
||||
|
||||
// promote target player, and demote existing admin if one exists
|
||||
if (admin != null)
|
||||
admin.setRole(Role.MODERATOR);
|
||||
fyou.setRole(Role.ADMIN);
|
||||
msg("<i>You have promoted %s<i> to the position of faction admin.", fyou.describeTo(fme, true));
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||
{
|
||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s", fme.describeTo(fplayer, true), fyou.describeTo(fplayer), myFaction.describeTo(fplayer));
|
||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : fme.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.isAdminBypassing()))
|
||||
if( ! (faction.getOpen() || faction.isInvited(fme) || fme.isAdminBypassing() || 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));
|
||||
|
@ -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.Role;
|
||||
@ -18,10 +19,10 @@ public class CmdMod extends FCommand
|
||||
this.permission = Permission.MOD.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,29 +31,46 @@ public class CmdMod extends FCommand
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) return;
|
||||
|
||||
if (you.getFaction() != myFaction)
|
||||
boolean permAny = Permission.MOD_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() != Role.ADMIN && !permAny)
|
||||
{
|
||||
msg("<b>You are not the faction admin.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you == fme && !permAny)
|
||||
{
|
||||
msg("<b>The target player musn't be yourself.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.ADMIN)
|
||||
{
|
||||
msg("<b>The target player is a faction admin. Demote them first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.MODERATOR)
|
||||
{
|
||||
// Revoke
|
||||
you.setRole(Role.NORMAL);
|
||||
myFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(myFaction, true));
|
||||
targetFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(targetFaction, true));
|
||||
msg("<i>You have removed moderator status from %s<i>.", you.describeTo(fme, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Give
|
||||
you.setRole(Role.MODERATOR);
|
||||
myFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(myFaction, true));
|
||||
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));
|
||||
msg("<i>You have promoted %s<i> to moderator.", you.describeTo(fme, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
|
||||
@ -43,6 +44,8 @@ public class CmdPermanent extends FCommand
|
||||
faction.setPermanent(true);
|
||||
}
|
||||
|
||||
P.p.log((fme == null ? "A server admin" : fme.getName())+"<i> has "+change+" the faction \"" + faction.getTag() + "\".");
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ public enum Permission
|
||||
MANAGE_WAR_ZONE("managewarzone"),
|
||||
OWNERSHIP_BYPASS("ownershipbypass"),
|
||||
ADMIN("admin"),
|
||||
ADMIN_ANY("admin.any"),
|
||||
AUTOCLAIM("autoclaim"),
|
||||
BYPASS("bypass"),
|
||||
CHAT("chat"),
|
||||
@ -25,6 +26,7 @@ public enum Permission
|
||||
HOME("home"),
|
||||
INVITE("invite"),
|
||||
JOIN("join"),
|
||||
JOIN_ANY("join.any"),
|
||||
KICK("kick"),
|
||||
KICK_ANY("kick.any"),
|
||||
LEAVE("leave"),
|
||||
@ -32,6 +34,7 @@ public enum Permission
|
||||
LOCK("lock"),
|
||||
MAP("map"),
|
||||
MOD("mod"),
|
||||
MOD_ANY("mod.any"),
|
||||
MONEY_BALANCE("money.balance"),
|
||||
MONEY_BALANCE_ANY("money.balance.any"),
|
||||
MONEY_DEPOSIT("money.deposit"),
|
||||
|
@ -19,7 +19,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 that.describeTo(null); // no relation, but can show basic name or tag
|
||||
|
||||
if (that instanceof Faction)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user