mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-06-24 13:54:51 +02:00
Fixed AdminDeleteCommand.
This commit is contained in:
parent
9847235df1
commit
f844b9bb40
|
@ -8,6 +8,7 @@ import java.util.UUID;
|
|||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
public class AdminDeleteCommand extends ConfirmableCommand {
|
||||
|
@ -53,8 +54,28 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
|||
private void deletePlayer(User user, UUID targetUUID) {
|
||||
// Delete player and island
|
||||
user.sendMessage("commands.admin.delete.deleted-island", "[xyz]", Util.xyz(getIslands().getIsland(getWorld(), targetUUID).getCenter().toVector()));
|
||||
getIslands().deleteIsland(getIslands().getIsland(getWorld(), targetUUID), true);
|
||||
getIslands().removePlayer(getWorld(), targetUUID);
|
||||
|
||||
// Get the target's island
|
||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||
if (oldIsland != null) {
|
||||
// Check if player is online and on the island
|
||||
User target = User.getInstance(targetUUID);
|
||||
// Remove them from this island (it still exists and will be deleted later)
|
||||
getIslands().removePlayer(getWorld(), targetUUID);
|
||||
if (target.isOnline()) {
|
||||
// Remove money inventory etc.
|
||||
if (getIWM().isOnLeaveResetEnderChest(getWorld())) {
|
||||
target.getPlayer().getEnderChest().clear();
|
||||
}
|
||||
if (getIWM().isOnLeaveResetInventory(getWorld())) {
|
||||
target.getPlayer().getInventory().clear();
|
||||
}
|
||||
if (getSettings().isUseEconomy() && getIWM().isOnLeaveResetMoney(getWorld())) {
|
||||
// TODO: needs Vault
|
||||
}
|
||||
}
|
||||
getIslands().deleteIsland(oldIsland, true);
|
||||
}
|
||||
getPlayers().clearHomeLocations(getWorld(), targetUUID);
|
||||
user.sendMessage("general.success");
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ import world.bentobox.bentobox.util.teleport.SafeTeleportBuilder;
|
|||
*/
|
||||
public class IslandsManager {
|
||||
|
||||
private static final String SPAWNCOMMAND = "spawn";
|
||||
|
||||
private BentoBox plugin;
|
||||
|
||||
/**
|
||||
|
@ -250,12 +248,12 @@ public class IslandsManager {
|
|||
island.setOwner(null);
|
||||
island.setFlag(Flags.LOCK, RanksManager.VISITOR_RANK);
|
||||
if (removeBlocks) {
|
||||
// Remove players from island
|
||||
removePlayersFromIsland(island);
|
||||
// Remove island from the cache
|
||||
islandCache.deleteIslandFromCache(island);
|
||||
// Remove the island from the database
|
||||
handler.deleteObject(island);
|
||||
// Remove players from island
|
||||
removePlayersFromIsland(island);
|
||||
// Remove blocks from world
|
||||
new DeleteIslandChunks(plugin, island);
|
||||
}
|
||||
|
@ -623,7 +621,7 @@ public class IslandsManager {
|
|||
|
||||
/**
|
||||
* Checks if an online player is in the protected area of their island, a team island or a
|
||||
* coop island in the specific world in the arguments. Note that the user
|
||||
* coop island in the specific world in the arguments.
|
||||
*
|
||||
* @param world - the world to check
|
||||
* @param user - the user
|
||||
|
@ -674,9 +672,9 @@ public class IslandsManager {
|
|||
// go to island spawn
|
||||
player.teleport(spawn.get(island.getWorld()).getSpawnPoint(island.getWorld().getEnvironment()));
|
||||
} else {
|
||||
if (!player.performCommand(SPAWNCOMMAND)) {
|
||||
plugin.logWarning("During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry.");
|
||||
}
|
||||
plugin.logWarning("During island deletion player " + player.getName() + " could not be sent home so was placed into spectator mode.");
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
player.getPlayer().setFlying(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user