Fixed a few issues with CmdAdmin now being Async
This commit is contained in:
parent
a20c2ec2eb
commit
f7619f0685
@ -70,7 +70,7 @@ public class CmdAdmin extends FCommand {
|
|||||||
|
|
||||||
// if target player is currently admin, demote and replace him
|
// if target player is currently admin, demote and replace him
|
||||||
if (fyou == admin) {
|
if (fyou == admin) {
|
||||||
targetFaction.promoteNewLeader();
|
promoteNewLeader(targetFaction);
|
||||||
context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
|
context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
|
||||||
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
|
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
|
||||||
return;
|
return;
|
||||||
@ -78,9 +78,9 @@ public class CmdAdmin extends FCommand {
|
|||||||
|
|
||||||
// promote target player, and demote existing admin if one exists
|
// promote target player, and demote existing admin if one exists
|
||||||
if (admin != null) {
|
if (admin != null) {
|
||||||
admin.setRole(Role.COLEADER);
|
setRole(admin, Role.COLEADER);
|
||||||
}
|
}
|
||||||
fyou.setRole(Role.LEADER);
|
setRole(fyou, Role.LEADER);
|
||||||
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
|
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
|
||||||
|
|
||||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
||||||
@ -94,6 +94,18 @@ public class CmdAdmin extends FCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setRole(FPlayer fp, Role r) {
|
||||||
|
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||||
|
fp.setRole(r);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void promoteNewLeader(Faction f) {
|
||||||
|
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||||
|
f.promoteNewLeader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
return TL.COMMAND_ADMIN_DESCRIPTION;
|
return TL.COMMAND_ADMIN_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class FPlayerRoleChangeEvent extends FactionPlayerEvent implements Cancel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user