forked from MassiveCraft/Factions
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds recruit role below the normal role. * Adds /f promote and demote. Access to this command defaults to moderator if not set in /f perm * Default role is still set to recruite. Will have to /f demote to set players to that rank.
- Loading branch information
Showing
15 changed files
with
152 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.massivecraft.factions.cmd; | ||
|
||
public class CmdDemote extends FPromoteCommand { | ||
|
||
public CmdDemote() { | ||
aliases.add("demote"); | ||
this.relative = -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/massivecraft/factions/cmd/CmdPromote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.massivecraft.factions.cmd; | ||
|
||
public class CmdPromote extends FPromoteCommand { | ||
|
||
public CmdPromote() { | ||
aliases.add("promote"); | ||
aliases.add("promo"); | ||
this.relative = 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.massivecraft.factions.cmd; | ||
|
||
import com.massivecraft.factions.FPlayer; | ||
import com.massivecraft.factions.struct.Permission; | ||
import com.massivecraft.factions.struct.Role; | ||
import com.massivecraft.factions.zcore.fperms.Access; | ||
import com.massivecraft.factions.zcore.fperms.Action; | ||
import com.massivecraft.factions.zcore.util.TL; | ||
|
||
public class FPromoteCommand extends FCommand { | ||
|
||
public int relative = 0; | ||
|
||
public FPromoteCommand() { | ||
super(); | ||
|
||
this.optionalArgs.put("player name", "name"); | ||
//this.optionalArgs.put("", ""); | ||
|
||
this.permission = Permission.MOD.node; | ||
this.disableOnLock = true; | ||
|
||
senderMustBePlayer = true; | ||
senderMustBeMember = true; | ||
senderMustBeModerator = false; | ||
senderMustBeAdmin = false; | ||
} | ||
|
||
@Override | ||
public void perform() { | ||
FPlayer target = this.argAsBestFPlayerMatch(0); | ||
if (target == null) { | ||
msg(TL.GENERIC_NOPLAYERFOUND, this.argAsString(0)); | ||
return; | ||
} | ||
|
||
if (!target.getFaction().equals(myFaction)) { | ||
msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName()); | ||
return; | ||
} | ||
|
||
Access access = myFaction.getAccess(fme, Action.PROMOTE); | ||
|
||
// Well this is messy. | ||
if (access == null || access == Access.UNDEFINED) { | ||
if (!assertMinRole(Role.MODERATOR)) { | ||
msg(TL.COMMAND_NOACCESS); | ||
return; | ||
} | ||
} else if (access == Access.DENY) { | ||
msg(TL.COMMAND_NOACCESS); | ||
return; | ||
} | ||
|
||
Role current = target.getRole(); | ||
Role promotion = Role.getRelative(current, +relative); | ||
if (promotion == null) { | ||
fme.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER); | ||
return; | ||
} | ||
|
||
// Success! | ||
target.setRole(promotion); | ||
if (target.isOnline()) { | ||
target.msg(TL.COMMAND_PROMOTE_TARGET, promotion.nicename); | ||
} | ||
|
||
target.msg(TL.COMMAND_PROMOTE_SUCCESS, target.getName(), promotion.nicename); | ||
} | ||
|
||
@Override | ||
public TL getUsageTranslation() { | ||
return TL.COMMAND_PROMOTE_DESCRIPTION; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters