Add some feedback in the method for island deletion.

This commit is contained in:
tastybento 2025-01-24 16:50:33 -08:00
parent c712e7e95f
commit 821fd77354
3 changed files with 13 additions and 5 deletions

View File

@ -105,13 +105,18 @@ public class AdminDeleteCommand extends ConfirmableCommand {
return true;
}
private void deleteIsland(User user, Island oldIsland) {
private boolean deleteIsland(User user, Island oldIsland) {
// Fire island preclear event
IslandEvent.builder().involvedPlayer(user.getUniqueId()).reason(Reason.PRECLEAR).island(oldIsland)
.oldIsland(oldIsland).location(oldIsland.getCenter()).build();
user.sendMessage("commands.admin.delete.deleted-island", TextVariables.XYZ,
if (getIslands().deleteIsland(oldIsland, true, targetUUID)) {
user.sendMessage("commands.admin.delete.deleted-island", TextVariables.XYZ,
Util.xyz(oldIsland.getCenter().toVector()));
return true;
}
user.sendMessage("commands.admin.delete.canceled", TextVariables.XYZ,
Util.xyz(oldIsland.getCenter().toVector()));
getIslands().deleteIsland(oldIsland, true, targetUUID);
return false;
}

View File

@ -273,13 +273,14 @@ public class IslandsManager {
* @param island island to delete, not null
* @param removeBlocks whether the island blocks should be removed or not
* @param involvedPlayer - player related to the island deletion, if any
* @return true if island deleted, false if canceled
*/
public void deleteIsland(@NonNull Island island, boolean removeBlocks, @Nullable UUID involvedPlayer) {
public boolean deleteIsland(@NonNull Island island, boolean removeBlocks, @Nullable UUID involvedPlayer) {
// Fire event
IslandBaseEvent event = IslandEvent.builder().island(island).involvedPlayer(involvedPlayer)
.reason(Reason.DELETE).build();
if (event.getNewEvent().map(IslandBaseEvent::isCancelled).orElse(event.isCancelled())) {
return;
return false;
}
// Set the owner of the island to no one.
island.setOwner(null);
@ -303,6 +304,7 @@ public class IslandsManager {
// Delete the island from the database
handler.deleteObject(island);
}
return true;
}
private Gson getGson() {

View File

@ -459,6 +459,7 @@ commands:
cannot-delete-owner: '&c All island members have to be kicked from the island
before deleting it.'
deleted-island: '&a Island at &e [xyz] &a has been successfully deleted.'
canceled: '&c Island deletion was cancelled via API at [xyz].'
deletehomes:
parameters: <player>
description: deletes all named homes from an island