-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 1.16.5_lts
- Loading branch information
1 parent
4683f7f
commit 260635e
Showing
63 changed files
with
2,995 additions
and
1,671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteHomesCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package world.bentobox.bentobox.api.commands.admin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.commands.ConfirmableCommand; | ||
import world.bentobox.bentobox.api.localization.TextVariables; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.bentobox.database.objects.Island; | ||
import world.bentobox.bentobox.util.Util; | ||
|
||
/** | ||
* Deletes all named homes from an island | ||
* @author tastybento | ||
* | ||
*/ | ||
public class AdminDeleteHomesCommand extends ConfirmableCommand { | ||
|
||
public AdminDeleteHomesCommand(CompositeCommand parent) { | ||
super(parent, "deletehomes"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
setPermission("mod.deletehomes"); | ||
setOnlyPlayer(false); | ||
setParametersHelp("commands.admin.deletehomes.parameters"); | ||
setDescription("commands.admin.deletehomes.description"); | ||
} | ||
|
||
@Override | ||
public boolean canExecute(User user, String label, List<String> args) { | ||
if (args.size() != 1) { | ||
showHelp(this, user); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
// Get target player | ||
UUID targetUUID = Util.getUUID(args.get(0)); | ||
if (targetUUID == null) { | ||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0)); | ||
return false; | ||
} | ||
// Get island | ||
Island island = getIslands().getIsland(getWorld(), targetUUID); | ||
if (island == null) { | ||
user.sendMessage("general.errors.player-has-no-island"); | ||
return false; | ||
} | ||
// Confirm | ||
askConfirmation(user, user.getTranslation("commands.admin.deletehomes.warning"), () -> deleteHomes(user, targetUUID, island)); | ||
return true; | ||
} | ||
|
||
private boolean deleteHomes(User user, UUID targetUUID, Island island) { | ||
island.removeHomes(); | ||
user.sendMessage("general.success"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) { | ||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : ""; | ||
if (args.isEmpty()) { | ||
// Don't show every player on the server. Require at least the first letter | ||
return Optional.empty(); | ||
} | ||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user)); | ||
return Optional.of(Util.tabLimit(options, lastArg)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.