Add command to set default rank. Only used by admins.
/f defaultrole <role>
This commit is contained in:
parent
4db185e3ee
commit
f6bd156f89
@ -219,6 +219,10 @@ public interface Faction extends EconomyParticipator {
|
|||||||
// promotes new leader, or disbands faction if no other members left
|
// promotes new leader, or disbands faction if no other members left
|
||||||
public void promoteNewLeader();
|
public void promoteNewLeader();
|
||||||
|
|
||||||
|
public Role getDefaultRole();
|
||||||
|
|
||||||
|
public void setDefaultRole(Role role);
|
||||||
|
|
||||||
// ----------------------------------------------//
|
// ----------------------------------------------//
|
||||||
// Messages
|
// Messages
|
||||||
// ----------------------------------------------//
|
// ----------------------------------------------//
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
|
public class CmdSetDefaultRole extends FCommand {
|
||||||
|
|
||||||
|
public CmdSetDefaultRole() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.aliases.add("defaultrole");
|
||||||
|
this.aliases.add("defaultrank");
|
||||||
|
this.aliases.add("default");
|
||||||
|
this.aliases.add("def");
|
||||||
|
this.requiredArgs.add("role");
|
||||||
|
|
||||||
|
this.senderMustBeMember = true;
|
||||||
|
this.senderMustBeAdmin = true;
|
||||||
|
this.senderMustBePlayer = true;
|
||||||
|
|
||||||
|
this.permission = Permission.DEFAULTRANK.node;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform() {
|
||||||
|
Role target = Role.fromString(argAsString(0).toUpperCase());
|
||||||
|
if (target == null) {
|
||||||
|
msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, argAsString(0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myFaction.setDefaultRole(target);
|
||||||
|
msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_SETDEFAULTROLE_DESCRIPTION;
|
||||||
|
}
|
||||||
|
}
|
@ -73,6 +73,7 @@ public class FCmdRoot extends FCommand {
|
|||||||
public CmdPerm cmdPerm = new CmdPerm();
|
public CmdPerm cmdPerm = new CmdPerm();
|
||||||
public CmdPromote cmdPromote = new CmdPromote();
|
public CmdPromote cmdPromote = new CmdPromote();
|
||||||
public CmdDemote cmdDemote = new CmdDemote();
|
public CmdDemote cmdDemote = new CmdDemote();
|
||||||
|
public CmdSetDefaultRole cmdSetDefaultRole = new CmdSetDefaultRole();
|
||||||
|
|
||||||
public FCmdRoot() {
|
public FCmdRoot() {
|
||||||
super();
|
super();
|
||||||
@ -160,6 +161,7 @@ public class FCmdRoot extends FCommand {
|
|||||||
this.addSubCommand(this.cmdPerm);
|
this.addSubCommand(this.cmdPerm);
|
||||||
this.addSubCommand(this.cmdPromote);
|
this.addSubCommand(this.cmdPromote);
|
||||||
this.addSubCommand(this.cmdDemote);
|
this.addSubCommand(this.cmdDemote);
|
||||||
|
this.addSubCommand(this.cmdSetDefaultRole);
|
||||||
if (P.p.isHookedPlayervaults()) {
|
if (P.p.isHookedPlayervaults()) {
|
||||||
P.p.log("Found playervaults hook, adding /f vault and /f setmaxvault commands.");
|
P.p.log("Found playervaults hook, adding /f vault and /f setmaxvault commands.");
|
||||||
this.addSubCommand(new CmdSetMaxVaults());
|
this.addSubCommand(new CmdSetMaxVaults());
|
||||||
|
@ -21,6 +21,7 @@ public enum Permission {
|
|||||||
CLAIM_RADIUS("claim.radius"),
|
CLAIM_RADIUS("claim.radius"),
|
||||||
CONFIG("config"),
|
CONFIG("config"),
|
||||||
CREATE("create"),
|
CREATE("create"),
|
||||||
|
DEFAULTRANK("defaultrank"),
|
||||||
DEINVITE("deinvite"),
|
DEINVITE("deinvite"),
|
||||||
DESCRIPTION("description"),
|
DESCRIPTION("description"),
|
||||||
DISBAND("disband"),
|
DISBAND("disband"),
|
||||||
|
@ -45,6 +45,24 @@ public enum Role {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Role fromString(String check) {
|
||||||
|
switch (check.toLowerCase()) {
|
||||||
|
case "admin":
|
||||||
|
return ADMIN;
|
||||||
|
case "mod":
|
||||||
|
case "moderator":
|
||||||
|
return MODERATOR;
|
||||||
|
case "normal":
|
||||||
|
case "member":
|
||||||
|
return NORMAL;
|
||||||
|
case "recruit":
|
||||||
|
case "rec":
|
||||||
|
return RECRUIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.nicename;
|
return this.nicename;
|
||||||
|
@ -48,6 +48,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
private long lastDeath;
|
private long lastDeath;
|
||||||
protected int maxVaults;
|
protected int maxVaults;
|
||||||
protected Map<Relation, Map<Action, Access>> permissions = new HashMap<>();
|
protected Map<Relation, Map<Action, Access>> permissions = new HashMap<>();
|
||||||
|
protected Role defaultRole;
|
||||||
|
|
||||||
public HashMap<String, List<String>> getAnnouncements() {
|
public HashMap<String, List<String>> getAnnouncements() {
|
||||||
return this.announcements;
|
return this.announcements;
|
||||||
@ -357,6 +358,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Role getDefaultRole() {
|
||||||
|
return this.defaultRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultRole(Role role) {
|
||||||
|
this.defaultRole = role;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Construct
|
// Construct
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -376,6 +385,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
this.powerBoost = 0.0;
|
this.powerBoost = 0.0;
|
||||||
this.foundedDate = System.currentTimeMillis();
|
this.foundedDate = System.currentTimeMillis();
|
||||||
this.maxVaults = Conf.defaultMaxVaults;
|
this.maxVaults = Conf.defaultMaxVaults;
|
||||||
|
this.defaultRole = Role.NORMAL;
|
||||||
|
|
||||||
resetPerms(); // Reset on new Faction so it has default values.
|
resetPerms(); // Reset on new Faction so it has default values.
|
||||||
}
|
}
|
||||||
@ -399,6 +409,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
fplayers = new HashSet<>();
|
fplayers = new HashSet<>();
|
||||||
invites = old.invites;
|
invites = old.invites;
|
||||||
announcements = old.announcements;
|
announcements = old.announcements;
|
||||||
|
this.defaultRole = Role.NORMAL;
|
||||||
|
|
||||||
resetPerms(); // Reset on new Faction so it has default values.
|
resetPerms(); // Reset on new Faction so it has default values.
|
||||||
}
|
}
|
||||||
@ -568,7 +579,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean addFPlayer(FPlayer fplayer) {
|
public boolean addFPlayer(FPlayer fplayer) {
|
||||||
return !this.isPlayerFreeType() && fplayers.add(fplayer);
|
if (!this.isPlayerFreeType() && fplayers.add(fplayer)) {
|
||||||
|
fplayer.setRole(defaultRole); // set default role on join.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeFPlayer(FPlayer fplayer) {
|
public boolean removeFPlayer(FPlayer fplayer) {
|
||||||
|
@ -434,6 +434,11 @@ public enum TL {
|
|||||||
|
|
||||||
COMMAND_SCOREBOARD_DESCRIPTION("Scoreboardy things"),
|
COMMAND_SCOREBOARD_DESCRIPTION("Scoreboardy things"),
|
||||||
|
|
||||||
|
COMMAND_SETDEFAULTROLE_DESCRIPTION("/f defaultrole <role> - set your Faction's default role."),
|
||||||
|
COMMAND_SETDEFAULTROLE_NOTTHATROLE("You cannot set the default to admin."),
|
||||||
|
COMMAND_SETDEFAULTROLE_SUCCESS("Set default role of your faction to %1$s"),
|
||||||
|
COMMAND_SETDEFAULTROLE_INVALIDROLE("Couldn't find matching role for %1$s"),
|
||||||
|
|
||||||
COMMAND_SETFWARP_NOTCLAIMED("<i>You can only set warps in your faction territory."),
|
COMMAND_SETFWARP_NOTCLAIMED("<i>You can only set warps in your faction territory."),
|
||||||
COMMAND_SETFWARP_LIMIT("<i>Your Faction already has the max amount of warps set <a>(%1$d)."),
|
COMMAND_SETFWARP_LIMIT("<i>Your Faction already has the max amount of warps set <a>(%1$d)."),
|
||||||
COMMAND_SETFWARP_SET("<i>Set warp <a>%1$s and password <c>'%2$s' <i>to your location."),
|
COMMAND_SETFWARP_SET("<i>Set warp <a>%1$s and password <c>'%2$s' <i>to your location."),
|
||||||
|
Loading…
Reference in New Issue
Block a user