Showing Dropping Anvil Something (Ignore)
This commit is contained in:
@@ -11,78 +11,78 @@ import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class FPromoteCommand extends FCommand {
|
||||
|
||||
public int relative = 0;
|
||||
public int relative = 0;
|
||||
|
||||
public FPromoteCommand() {
|
||||
super();
|
||||
this.requiredArgs.add("player");
|
||||
public FPromoteCommand() {
|
||||
super();
|
||||
this.requiredArgs.add("player");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.PROMOTE)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.PROMOTE)
|
||||
.build();
|
||||
}
|
||||
this.requirements = new CommandRequirements.Builder(Permission.PROMOTE)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.PROMOTE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
FPlayer target = context.argAsBestFPlayerMatch(0);
|
||||
if (target == null) {
|
||||
context.msg(TL.GENERIC_NOPLAYERFOUND, context.argAsString(0));
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
FPlayer target = context.argAsBestFPlayerMatch(0);
|
||||
if (target == null) {
|
||||
context.msg(TL.GENERIC_NOPLAYERFOUND, context.argAsString(0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.getFaction().equals(context.faction)) {
|
||||
context.msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName());
|
||||
return;
|
||||
}
|
||||
if (!target.getFaction().equals(context.faction)) {
|
||||
context.msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
Role current = target.getRole();
|
||||
Role promotion = Role.getRelative(current, +relative);
|
||||
Role current = target.getRole();
|
||||
Role promotion = Role.getRelative(current, +relative);
|
||||
|
||||
// Now it ain't that messy
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (target == context.fPlayer) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOTSELF);
|
||||
return;
|
||||
}
|
||||
// Don't allow people to manage role of their same rank
|
||||
if (context.fPlayer.getRole() == current) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOT_SAME);
|
||||
return;
|
||||
}
|
||||
// Don't allow people to promote people to their same or higher rank.
|
||||
if (context.fPlayer.getRole().value <= promotion.value) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Now it ain't that messy
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (target == context.fPlayer) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOTSELF);
|
||||
return;
|
||||
}
|
||||
// Don't allow people to manage role of their same rank
|
||||
if (context.fPlayer.getRole() == current) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOT_SAME);
|
||||
return;
|
||||
}
|
||||
// Don't allow people to promote people to their same or higher rank.
|
||||
if (context.fPlayer.getRole().value <= promotion.value) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (promotion == null) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
|
||||
return;
|
||||
}
|
||||
if (promotion == null) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't allow people to promote people to their same or higher rnak.
|
||||
if (context.fPlayer.getRole().value <= promotion.value) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
|
||||
return;
|
||||
}
|
||||
// Don't allow people to promote people to their same or higher rnak.
|
||||
if (context.fPlayer.getRole().value <= promotion.value) {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
|
||||
return;
|
||||
}
|
||||
|
||||
String action = relative > 0 ? TL.COMMAND_PROMOTE_PROMOTED.toString() : TL.COMMAND_PROMOTE_DEMOTED.toString();
|
||||
String action = relative > 0 ? TL.COMMAND_PROMOTE_PROMOTED.toString() : TL.COMMAND_PROMOTE_DEMOTED.toString();
|
||||
|
||||
// Success!
|
||||
target.setRole(promotion);
|
||||
if (target.isOnline()) {
|
||||
target.msg(TL.COMMAND_PROMOTE_TARGET, action, promotion.nicename);
|
||||
}
|
||||
// Success!
|
||||
target.setRole(promotion);
|
||||
if (target.isOnline()) {
|
||||
target.msg(TL.COMMAND_PROMOTE_TARGET, action, promotion.nicename);
|
||||
}
|
||||
|
||||
context.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename);
|
||||
}
|
||||
context.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_PROMOTE_DESCRIPTION;
|
||||
}
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_PROMOTE_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user