mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-27 10:31:21 +01:00
Added IslandRankChangeEvent (#1260)
Implements #1135 changed name of the event to append Event to it Call the event in proper places
This commit is contained in:
parent
74007a7a9f
commit
3bd0ff4a69
@ -14,6 +14,7 @@ import world.bentobox.bentobox.api.events.island.IslandEvent;
|
|||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
public class AdminRegisterCommand extends ConfirmableCommand {
|
public class AdminRegisterCommand extends ConfirmableCommand {
|
||||||
@ -87,6 +88,13 @@ public class AdminRegisterCommand extends ConfirmableCommand {
|
|||||||
.involvedPlayer(targetUUID)
|
.involvedPlayer(targetUUID)
|
||||||
.admin(true)
|
.admin(true)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(i)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(true)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(RanksManager.VISITOR_RANK, RanksManager.OWNER_RANK)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
}).orElse(false)) {
|
}).orElse(false)) {
|
||||||
// Island does not exist - this is a reservation
|
// Island does not exist - this is a reservation
|
||||||
|
@ -9,6 +9,7 @@ import java.util.stream.Collectors;
|
|||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
@ -98,6 +99,13 @@ public class AdminSetrankCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
int currentRank = island.getRank(target);
|
int currentRank = island.getRank(target);
|
||||||
island.setRank(target, rankValue);
|
island.setRank(target, rankValue);
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(true)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(currentRank, rankValue)
|
||||||
|
.build();
|
||||||
|
|
||||||
String ownerName;
|
String ownerName;
|
||||||
if (ownerUUID != null) {
|
if (ownerUUID != null) {
|
||||||
|
@ -11,6 +11,7 @@ import world.bentobox.bentobox.api.events.island.IslandEvent;
|
|||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
public class AdminUnregisterCommand extends ConfirmableCommand {
|
public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||||
@ -62,6 +63,13 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
|||||||
.involvedPlayer(targetUUID)
|
.involvedPlayer(targetUUID)
|
||||||
.admin(true)
|
.admin(true)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(oldIsland)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(true)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(RanksManager.OWNER_RANK, RanksManager.VISITOR_RANK)
|
||||||
|
.build();
|
||||||
// Remove all island members
|
// Remove all island members
|
||||||
oldIsland.getMemberSet().forEach(m -> {
|
oldIsland.getMemberSet().forEach(m -> {
|
||||||
getIslands().removePlayer(getWorld(), m);
|
getIslands().removePlayer(getWorld(), m);
|
||||||
|
@ -4,10 +4,13 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
|
||||||
public class AdminTeamAddCommand extends CompositeCommand {
|
public class AdminTeamAddCommand extends CompositeCommand {
|
||||||
|
|
||||||
@ -68,6 +71,13 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
|||||||
.involvedPlayer(targetUUID)
|
.involvedPlayer(targetUUID)
|
||||||
.admin(true)
|
.admin(true)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(teamIsland)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(true)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(teamIsland.getRank(target), RanksManager.MEMBER_RANK)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage("general.errors.player-has-no-island");
|
user.sendMessage("general.errors.player-has-no-island");
|
||||||
|
@ -4,10 +4,12 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
|
||||||
public class AdminTeamDisbandCommand extends CompositeCommand {
|
public class AdminTeamDisbandCommand extends CompositeCommand {
|
||||||
|
|
||||||
@ -46,7 +48,8 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
|||||||
// Disband team
|
// Disband team
|
||||||
Island island = getIslands().getIsland(getWorld(), targetUUID);
|
Island island = getIslands().getIsland(getWorld(), targetUUID);
|
||||||
getIslands().getMembers(getWorld(), targetUUID).forEach(m -> {
|
getIslands().getMembers(getWorld(), targetUUID).forEach(m -> {
|
||||||
User.getInstance(m).sendMessage("commands.admin.team.disband.disbanded");
|
User mUser = User.getInstance(m);
|
||||||
|
mUser.sendMessage("commands.admin.team.disband.disbanded");
|
||||||
// The owner gets to keep the island
|
// The owner gets to keep the island
|
||||||
if (!m.equals(targetUUID)) {
|
if (!m.equals(targetUUID)) {
|
||||||
getIslands().setLeaveTeam(getWorld(), m);
|
getIslands().setLeaveTeam(getWorld(), m);
|
||||||
@ -56,6 +59,13 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
|||||||
.involvedPlayer(m)
|
.involvedPlayer(m)
|
||||||
.admin(true)
|
.admin(true)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(true)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(island.getRank(mUser), RanksManager.VISITOR_RANK)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
user.sendMessage("commands.admin.team.disband.success", TextVariables.NAME, args.get(0));
|
user.sendMessage("commands.admin.team.disband.success", TextVariables.NAME, args.get(0));
|
||||||
|
@ -6,10 +6,12 @@ import java.util.UUID;
|
|||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kicks the specified player from the island team.
|
* Kicks the specified player from the island team.
|
||||||
@ -71,6 +73,13 @@ public class AdminTeamKickCommand extends CompositeCommand {
|
|||||||
.involvedPlayer(targetUUID)
|
.involvedPlayer(targetUUID)
|
||||||
.admin(true)
|
.admin(true)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(true)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(island.getRank(target), RanksManager.VISITOR_RANK)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,12 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the owner of an island.
|
* Sets the owner of an island.
|
||||||
@ -44,6 +46,7 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Make new owner
|
// Make new owner
|
||||||
|
User target = User.getInstance(targetUUID);
|
||||||
getIslands().setOwner(getWorld(), user, targetUUID);
|
getIslands().setOwner(getWorld(), user, targetUUID);
|
||||||
user.sendMessage("commands.admin.team.setowner.success", TextVariables.NAME, args.get(0));
|
user.sendMessage("commands.admin.team.setowner.success", TextVariables.NAME, args.get(0));
|
||||||
// Fire event so add-ons know
|
// Fire event so add-ons know
|
||||||
@ -54,6 +57,13 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
|
|||||||
.involvedPlayer(targetUUID)
|
.involvedPlayer(targetUUID)
|
||||||
.admin(true)
|
.admin(true)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(true)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(island.getRank(target), RanksManager.OWNER_RANK)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||||
import world.bentobox.bentobox.api.commands.island.team.Invite.Type;
|
import world.bentobox.bentobox.api.commands.island.team.Invite.Type;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
@ -86,6 +87,13 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
|||||||
Island island = getIslands().getIsland(getWorld(), inviter);
|
Island island = getIslands().getIsland(getWorld(), inviter);
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
island.setRank(user, RanksManager.TRUSTED_RANK);
|
island.setRank(user, RanksManager.TRUSTED_RANK);
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(user.getUniqueId())
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(island.getRank(user), RanksManager.TRUSTED_RANK)
|
||||||
|
.build();
|
||||||
inviter.sendMessage("commands.island.team.trust.success", TextVariables.NAME, user.getName());
|
inviter.sendMessage("commands.island.team.trust.success", TextVariables.NAME, user.getName());
|
||||||
user.sendMessage("commands.island.team.trust.you-are-trusted", TextVariables.NAME, inviter.getName());
|
user.sendMessage("commands.island.team.trust.you-are-trusted", TextVariables.NAME, inviter.getName());
|
||||||
}
|
}
|
||||||
@ -100,6 +108,13 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
|||||||
Island island = getIslands().getIsland(getWorld(), inviter);
|
Island island = getIslands().getIsland(getWorld(), inviter);
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
island.setRank(user, RanksManager.COOP_RANK);
|
island.setRank(user, RanksManager.COOP_RANK);
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(user.getUniqueId())
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(island.getRank(user), RanksManager.COOP_RANK)
|
||||||
|
.build();
|
||||||
inviter.sendMessage("commands.island.team.coop.success", TextVariables.NAME, user.getName());
|
inviter.sendMessage("commands.island.team.coop.success", TextVariables.NAME, user.getName());
|
||||||
user.sendMessage("commands.island.team.coop.you-are-a-coop-member", TextVariables.NAME, inviter.getName());
|
user.sendMessage("commands.island.team.coop.you-are-a-coop-member", TextVariables.NAME, inviter.getName());
|
||||||
}
|
}
|
||||||
@ -145,6 +160,13 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
|||||||
.reason(TeamEvent.Reason.JOINED)
|
.reason(TeamEvent.Reason.JOINED)
|
||||||
.involvedPlayer(playerUUID)
|
.involvedPlayer(playerUUID)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(teamIsland)
|
||||||
|
.involvedPlayer(user.getUniqueId())
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(teamIsland.getRank(user), RanksManager.MEMBER_RANK)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanPlayer(User user) {
|
private void cleanPlayer(User user) {
|
||||||
|
@ -7,10 +7,12 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
|
||||||
|
|
||||||
public class IslandTeamKickCommand extends ConfirmableCommand {
|
public class IslandTeamKickCommand extends ConfirmableCommand {
|
||||||
@ -126,6 +128,13 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
|||||||
.reason(TeamEvent.Reason.KICK)
|
.reason(TeamEvent.Reason.KICK)
|
||||||
.involvedPlayer(targetUUID)
|
.involvedPlayer(targetUUID)
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(oldIsland)
|
||||||
|
.involvedPlayer(user.getUniqueId())
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(oldIsland.getRank(user), RanksManager.VISITOR_RANK)
|
||||||
|
.build();
|
||||||
|
|
||||||
// Add cooldown for this player and target
|
// Add cooldown for this player and target
|
||||||
if (getSettings().getInviteCooldown() > 0 && getParent() != null) {
|
if (getSettings().getInviteCooldown() > 0 && getParent() != null) {
|
||||||
|
@ -7,10 +7,12 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
|
||||||
public class IslandTeamLeaveCommand extends ConfirmableCommand {
|
public class IslandTeamLeaveCommand extends ConfirmableCommand {
|
||||||
|
|
||||||
@ -121,5 +123,12 @@ public class IslandTeamLeaveCommand extends ConfirmableCommand {
|
|||||||
.reason(TeamEvent.Reason.LEAVE)
|
.reason(TeamEvent.Reason.LEAVE)
|
||||||
.involvedPlayer(user.getUniqueId())
|
.involvedPlayer(user.getUniqueId())
|
||||||
.build();
|
.build();
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(user.getUniqueId())
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(island.getRank(user), RanksManager.VISITOR_RANK)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package world.bentobox.bentobox.api.commands.island.team;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
@ -62,7 +63,8 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean change(User user, User target) {
|
private boolean change(User user, User target) {
|
||||||
int currentRank = getIslands().getIsland(getWorld(), user.getUniqueId()).getRank(target);
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
int currentRank = island.getRank(target);
|
||||||
if (this.getLabel().equals("promote")) {
|
if (this.getLabel().equals("promote")) {
|
||||||
int nextRank = getPlugin().getRanksManager().getRankUpValue(currentRank);
|
int nextRank = getPlugin().getRanksManager().getRankUpValue(currentRank);
|
||||||
// Stop short of owner
|
// Stop short of owner
|
||||||
@ -70,6 +72,13 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, nextRank);
|
getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, nextRank);
|
||||||
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(nextRank));
|
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(nextRank));
|
||||||
user.sendMessage("commands.island.team.promote.success", TextVariables.NAME, target.getName(), TextVariables.RANK, rankName);
|
user.sendMessage("commands.island.team.promote.success", TextVariables.NAME, target.getName(), TextVariables.RANK, rankName);
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(user.getUniqueId())
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(currentRank, nextRank)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage("commands.island.team.promote.failure");
|
user.sendMessage("commands.island.team.promote.failure");
|
||||||
@ -83,6 +92,13 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, prevRank);
|
getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, prevRank);
|
||||||
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(prevRank));
|
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(prevRank));
|
||||||
user.sendMessage("commands.island.team.demote.success", TextVariables.NAME, target.getName(), TextVariables.RANK, rankName);
|
user.sendMessage("commands.island.team.demote.success", TextVariables.NAME, target.getName(), TextVariables.RANK, rankName);
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(user.getUniqueId())
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(currentRank, prevRank)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage("commands.island.team.demote.failure");
|
user.sendMessage("commands.island.team.demote.failure");
|
||||||
|
@ -8,10 +8,12 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
public class IslandTeamSetownerCommand extends CompositeCommand {
|
public class IslandTeamSetownerCommand extends CompositeCommand {
|
||||||
@ -67,6 +69,13 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
getIslands().setOwner(getWorld(), user, targetUUID);
|
getIslands().setOwner(getWorld(), user, targetUUID);
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(island.getRank(User.getInstance(targetUUID)), RanksManager.OWNER_RANK)
|
||||||
|
.build();
|
||||||
getIslands().save(island);
|
getIslands().save(island);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
@ -85,6 +86,13 @@ public class IslandTeamUncoopCommand extends CompositeCommand {
|
|||||||
getParent().getSubCommand("coop").ifPresent(subCommand ->
|
getParent().getSubCommand("coop").ifPresent(subCommand ->
|
||||||
subCommand.setCooldown(island.getUniqueId(), targetUUID.toString(), getSettings().getCoopCooldown() * 60));
|
subCommand.setCooldown(island.getUniqueId(), targetUUID.toString(), getSettings().getCoopCooldown() * 60));
|
||||||
}
|
}
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(RanksManager.COOP_RANK, RanksManager.VISITOR_RANK)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Should not happen
|
// Should not happen
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
@ -85,6 +86,13 @@ public class IslandTeamUntrustCommand extends CompositeCommand {
|
|||||||
getParent().getSubCommand("trust").ifPresent(subCommand ->
|
getParent().getSubCommand("trust").ifPresent(subCommand ->
|
||||||
subCommand.setCooldown(island.getUniqueId(), targetUUID.toString(), getSettings().getTrustCooldown() * 60));
|
subCommand.setCooldown(island.getUniqueId(), targetUUID.toString(), getSettings().getTrustCooldown() * 60));
|
||||||
}
|
}
|
||||||
|
IslandEvent.builder()
|
||||||
|
.island(island)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.admin(false)
|
||||||
|
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||||
|
.rankChange(RanksManager.TRUSTED_RANK, RanksManager.VISITOR_RANK)
|
||||||
|
.build();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Should not happen
|
// Should not happen
|
||||||
|
@ -141,13 +141,43 @@ public class IslandEvent extends IslandBaseEvent {
|
|||||||
* The island protection range was changed.
|
* The island protection range was changed.
|
||||||
* @since 1.11.0
|
* @since 1.11.0
|
||||||
*/
|
*/
|
||||||
RANGE_CHANGE
|
RANGE_CHANGE,
|
||||||
|
/**
|
||||||
|
* Event that will fire any time a player's rank changes on an island.
|
||||||
|
* @since 1.13.0
|
||||||
|
*/
|
||||||
|
RANK_CHANGE
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IslandEventBuilder builder() {
|
public static IslandEventBuilder builder() {
|
||||||
return new IslandEventBuilder();
|
return new IslandEventBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired when a player's rank has changed on an island.
|
||||||
|
* Cancellation has no effect.
|
||||||
|
* @since 1.13.0
|
||||||
|
*/
|
||||||
|
public static class IslandRankChangeEvent extends IslandBaseEvent {
|
||||||
|
|
||||||
|
private final int oldRank;
|
||||||
|
private final int newRank;
|
||||||
|
|
||||||
|
public IslandRankChangeEvent(Island island, UUID playerUUID, boolean admin, Location location, int oldRank, int newRank) {
|
||||||
|
super(island, playerUUID, admin, location);
|
||||||
|
this.oldRank = oldRank;
|
||||||
|
this.newRank = newRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOldRank() {
|
||||||
|
return oldRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNewRank(){
|
||||||
|
return newRank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player will be expelled from an island.
|
* Fired when a player will be expelled from an island.
|
||||||
* May be cancelled.
|
* May be cancelled.
|
||||||
@ -542,6 +572,16 @@ public class IslandEvent extends IslandBaseEvent {
|
|||||||
*/
|
*/
|
||||||
private Island oldIsland;
|
private Island oldIsland;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.13.0
|
||||||
|
*/
|
||||||
|
private int oldRank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.13.0
|
||||||
|
*/
|
||||||
|
private int newRank;
|
||||||
|
|
||||||
public IslandEventBuilder island(Island island) {
|
public IslandEventBuilder island(Island island) {
|
||||||
this.island = island;
|
this.island = island;
|
||||||
return this;
|
return this;
|
||||||
@ -618,6 +658,15 @@ public class IslandEvent extends IslandBaseEvent {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.13.0
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public IslandEventBuilder rankChange(int oldRank, int newRank){
|
||||||
|
this.oldRank = oldRank;
|
||||||
|
this.newRank = newRank;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public IslandBaseEvent build() {
|
public IslandBaseEvent build() {
|
||||||
// Call the generic event for developers who just want one event and use the Reason enum
|
// Call the generic event for developers who just want one event and use the Reason enum
|
||||||
@ -701,6 +750,10 @@ public class IslandEvent extends IslandBaseEvent {
|
|||||||
IslandReservedEvent res = new IslandReservedEvent(island, player, admin, location);
|
IslandReservedEvent res = new IslandReservedEvent(island, player, admin, location);
|
||||||
Bukkit.getPluginManager().callEvent(res);
|
Bukkit.getPluginManager().callEvent(res);
|
||||||
return res;
|
return res;
|
||||||
|
case RANK_CHANGE:
|
||||||
|
IslandRankChangeEvent rankChange = new IslandRankChangeEvent(island, player, admin, location, oldRank, newRank);
|
||||||
|
Bukkit.getPluginManager().callEvent(rankChange);
|
||||||
|
return rankChange;
|
||||||
default:
|
default:
|
||||||
IslandGeneralEvent general = new IslandGeneralEvent(island, player, admin, location);
|
IslandGeneralEvent general = new IslandGeneralEvent(island, player, admin, location);
|
||||||
Bukkit.getPluginManager().callEvent(general);
|
Bukkit.getPluginManager().callEvent(general);
|
||||||
|
@ -30,6 +30,8 @@ import com.google.gson.annotations.Expose;
|
|||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||||
|
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||||
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.api.flags.Flag;
|
import world.bentobox.bentobox.api.flags.Flag;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.logs.LogEntry;
|
import world.bentobox.bentobox.api.logs.LogEntry;
|
||||||
@ -850,7 +852,8 @@ public class Island implements DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets player's rank to an arbitrary rank value
|
* Sets player's rank to an arbitrary rank value.
|
||||||
|
* Calling this method won't call the {@link IslandEvent.IslandRankChangeEvent}.
|
||||||
* @param uuid UUID of the player
|
* @param uuid UUID of the player
|
||||||
* @param rank rank value
|
* @param rank rank value
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
@ -859,7 +862,6 @@ public class Island implements DataObject {
|
|||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return; // Defensive code
|
return; // Defensive code
|
||||||
}
|
}
|
||||||
|
|
||||||
members.put(uuid, rank);
|
members.put(uuid, rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user