mirror of
https://github.com/MassiveCraft/Factions.git
synced 2025-01-08 17:08:22 +01:00
Finish off coleader perms
This commit is contained in:
parent
104e7916f8
commit
db8bece127
@ -42,6 +42,8 @@ public class Conf {
|
||||
public static String prefixNormal = "+";
|
||||
public static String prefixRecruit = "-";
|
||||
|
||||
public static boolean allowMultipleColeaders = false;
|
||||
|
||||
public static int factionTagLengthMin = 3;
|
||||
public static int factionTagLengthMax = 10;
|
||||
public static boolean factionTagForceUpperCase = false;
|
||||
|
97
src/main/java/com/massivecraft/factions/cmd/CmdColeader.java
Normal file
97
src/main/java/com/massivecraft/factions/cmd/CmdColeader.java
Normal file
@ -0,0 +1,97 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CmdColeader extends FCommand {
|
||||
|
||||
public CmdColeader() {
|
||||
super();
|
||||
this.aliases.add("coleader");
|
||||
this.aliases.add("setcoleader");
|
||||
this.aliases.add("cl");
|
||||
this.aliases.add("setcl");
|
||||
|
||||
this.optionalArgs.put("player name", "name");
|
||||
|
||||
this.permission = Permission.COLEADER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0);
|
||||
if (target == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
|
||||
String s = player.getName();
|
||||
|
||||
msg.then(s + " ").color(ChatColor.WHITE)
|
||||
.tooltip(TL.COMMAND_COLEADER_CLICKTOPROMOTE.toString() + s)
|
||||
.command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
|
||||
}
|
||||
|
||||
sendFancyMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean permAny = Permission.COLEADER_ANY.has(sender, false);
|
||||
Faction targetFaction = target.getFaction();
|
||||
|
||||
if (targetFaction != myFaction && !permAny) {
|
||||
msg(TL.COMMAND_COLEADER_NOTMEMBER, target.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||
msg(TL.COMMAND_COLEADER_NOTADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target == fme && !permAny) {
|
||||
msg(TL.COMMAND_COLEADER_SELF);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getRole() == Role.ADMIN) {
|
||||
msg(TL.COMMAND_COLEADER_TARGETISADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getRole() == Role.COLEADER) {
|
||||
// Revoke
|
||||
target.setRole(Role.MODERATOR);
|
||||
targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, target.describeTo(targetFaction, true));
|
||||
msg(TL.COMMAND_COLEADER_REVOKES, target.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check to see if we should allow multiple coleaders or not.
|
||||
if (!Conf.allowMultipleColeaders && !targetFaction.getFPlayersWhereRole(Role.COLEADER).isEmpty()) {
|
||||
msg(TL.COMMAND_COLEADER_ALREADY_COLEADER);
|
||||
return;
|
||||
}
|
||||
|
||||
// Give
|
||||
target.setRole(Role.COLEADER);
|
||||
targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, target.describeTo(targetFaction, true));
|
||||
msg(TL.COMMAND_COLEADER_PROMOTES, target.describeTo(fme, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_COLEADER_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
@ -82,6 +82,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdBan cmdban = new CmdBan();
|
||||
public CmdUnban cmdUnban = new CmdUnban();
|
||||
public CmdBanlist cmdbanlist = new CmdBanlist();
|
||||
public CmdColeader cmdColeader = new CmdColeader();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@ -174,6 +175,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdban);
|
||||
this.addSubCommand(this.cmdUnban);
|
||||
this.addSubCommand(this.cmdbanlist);
|
||||
this.addSubCommand(this.cmdColeader);
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("FactionsTop")) {
|
||||
P.p.log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command.");
|
||||
} else {
|
||||
|
@ -98,8 +98,9 @@ public abstract class FCommand extends MCommand<P> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.ADMIN)) {
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||
// FactionsUUID - allow coleaders to execute things.
|
||||
if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.COLEADER)) {
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction coleaders and admins can %s.", this.getHelpShort()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ public enum Permission {
|
||||
CLAIMAT("claimat"),
|
||||
CLAIM_LINE("claim.line"),
|
||||
CLAIM_RADIUS("claim.radius"),
|
||||
COLEADER("coleader"),
|
||||
COLEADER_ANY("coleader.any"),
|
||||
CONFIG("config"),
|
||||
CREATE("create"),
|
||||
DEFAULTRANK("defaultrank"),
|
||||
|
@ -956,7 +956,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
|
||||
// Admins can always fly in their territory.
|
||||
// admin bypass (ops) can fly as well.
|
||||
if (isAdminBypassing || (faction == getFaction() && getRole() == Role.ADMIN)) {
|
||||
if (isAdminBypassing || (faction == getFaction() && getRole().isAtLeast(Role.COLEADER))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,19 @@ public enum TL {
|
||||
COMMAND_CLAIMLINE_ABOVEMAX("&cThe maximum limit for claim line is &c%s&c."),
|
||||
COMMAND_CLAIMLINE_NOTVALID("%s&c is not a cardinal direction. You may use &dnorth&c, &deast&c, &dsouth &cor &dwest&c."),
|
||||
|
||||
COMMAND_COLEADER_CANDIDATES("Players you can promote: "),
|
||||
COMMAND_COLEADER_CLICKTOPROMOTE("Click to promote "),
|
||||
COMMAND_COLEADER_NOTMEMBER("%1$s&c is not a member in your faction."),
|
||||
COMMAND_COLEADER_NOTADMIN("&cYou are not the faction admin."),
|
||||
COMMAND_COLEADER_SELF("&cThe target player musn't be yourself."),
|
||||
COMMAND_COLEADER_TARGETISADMIN("&cThe target player is a faction admin. Demote them first."),
|
||||
COMMAND_COLEADER_REVOKES("&eYou have removed coleader status from %1$s&e."),
|
||||
COMMAND_COLEADER_REVOKED("%1$s&e is no longer coleader in your faction."),
|
||||
COMMAND_COLEADER_PROMOTES("%1$s&e was promoted to coleader in your faction."),
|
||||
COMMAND_COLEADER_PROMOTED("&eYou have promoted %1$s&e to coleader."),
|
||||
COMMAND_COLEADER_DESCRIPTION("Give or revoke coleader rights"),
|
||||
COMMAND_COLEADER_ALREADY_COLEADER("The faction already has a coleader. There can only be 1."),
|
||||
|
||||
COMMAND_CONFIG_NOEXIST("&cNo configuration setting \"&d%1$s&c\" exists."),
|
||||
COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."),
|
||||
COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."),
|
||||
@ -417,7 +430,6 @@ public enum TL {
|
||||
COMMAND_NOACCESS("You don't have access to that."),
|
||||
COMMAND_PROMOTE_NOTTHATPLAYER("That player cannot be promoted."),
|
||||
|
||||
|
||||
COMMAND_POWER_TOSHOW("to show player power info"),
|
||||
COMMAND_POWER_FORSHOW("for showing player power info"),
|
||||
COMMAND_POWER_POWER("%1$s&6 - Power / Maxpower: &e%2$d / %3$d %4$s"),
|
||||
|
@ -103,6 +103,7 @@ permissions:
|
||||
factions.mapheight: true
|
||||
factions.ban: true
|
||||
factions.fly: true
|
||||
factions.coleader: true
|
||||
factions.admin:
|
||||
description: hand over your admin rights
|
||||
factions.admin.any:
|
||||
@ -286,3 +287,5 @@ permissions:
|
||||
description: Ban players from Factions
|
||||
factions.fly:
|
||||
description: Allow use of /f fly
|
||||
factions.coleader:
|
||||
description: Allow use of /f coleader <target>
|
||||
|
Loading…
Reference in New Issue
Block a user