mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 10:45:22 +01:00
Merge pull request #2323 from BentoBoxWorld/team_fixes
Fix promote and demote #2322
This commit is contained in:
commit
b45c842c2f
@ -15,6 +15,9 @@ import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
* Handle promotion and demotion
|
||||
*/
|
||||
public class IslandTeamPromoteCommand extends CompositeCommand {
|
||||
|
||||
private User target;
|
||||
@ -45,7 +48,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the user has a team
|
||||
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||
user.sendMessage("general.errors.no-team");
|
||||
return false;
|
||||
@ -65,6 +68,11 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
}
|
||||
// Check that target is a member of this island
|
||||
if (!island.getMemberSet().contains(target.getUniqueId())) {
|
||||
user.sendMessage("commands.island.team.promote.errors.must-be-member");
|
||||
return false;
|
||||
}
|
||||
// Check if the user is not trying to promote/ demote himself
|
||||
if (target.equals(user)) {
|
||||
if (this.getLabel().equals("promote")) {
|
||||
@ -100,7 +108,8 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
||||
if (this.getLabel().equals("promote")) {
|
||||
int nextRank = RanksManager.getInstance().getRankUpValue(currentRank);
|
||||
// Stop short of owner
|
||||
if (nextRank != RanksManager.OWNER_RANK && nextRank > currentRank) {
|
||||
if (nextRank < RanksManager.OWNER_RANK && currentRank >= RanksManager.MEMBER_RANK
|
||||
&& nextRank > currentRank) {
|
||||
island.setRank(target, nextRank);
|
||||
String rankName = user.getTranslation(RanksManager.getInstance().getRank(nextRank));
|
||||
user.sendMessage("commands.island.team.promote.success", TextVariables.NAME, target.getName(), TextVariables.RANK, rankName, TextVariables.DISPLAY_NAME, target.getDisplayName());
|
||||
|
@ -786,6 +786,7 @@ commands:
|
||||
errors:
|
||||
cant-demote-yourself: '&c You can''t demote yourself!'
|
||||
cant-demote: '&c You can''t demote higher ranks!'
|
||||
must-be-member: '&c Player must be an island member!'
|
||||
failure: '&c Player cannot be demoted any further!'
|
||||
success: '&a Demoted [name] to [rank]'
|
||||
promote:
|
||||
@ -794,6 +795,7 @@ commands:
|
||||
errors:
|
||||
cant-promote-yourself: '&c You can''t promote yourself!'
|
||||
cant-promote: '&c You can''t promote above your rank!'
|
||||
must-be-member: '&c Player must be an island member!'
|
||||
failure: '&c Player cannot be promoted any further!'
|
||||
success: '&a Promoted [name] to [rank]'
|
||||
setowner:
|
||||
|
Loading…
Reference in New Issue
Block a user