Skip to content

Commit

Permalink
Enable to use command line to set spawn island settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Mar 10, 2021
1 parent 9f9dc40 commit 031d789
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*/
public class AdminSettingsCommand extends CompositeCommand {

private static final String SPAWN_ISLAND = "spawn-island";
private final List<String> PROTECTION_FLAG_NAMES;
private Island island;
private final List<String> SETTING_FLAG_NAMES;
Expand Down Expand Up @@ -84,6 +85,12 @@ public boolean canExecute(User user, String label, List<String> args) {
}

private boolean getIsland(User user, List<String> args) {
if (args.get(0).equalsIgnoreCase(SPAWN_ISLAND)) {
if (getIslands().getSpawn(getWorld()).isPresent()) {
island = getIslands().getSpawn(getWorld()).get();
return true;
}
}
// Get target player
@Nullable UUID targetUUID = Util.getUUID(args.get(0));
if (targetUUID == null) {
Expand Down Expand Up @@ -200,8 +207,8 @@ public boolean execute(User user, String label, List<String> args) {
}
// GUI requires in-game
if (!user.isPlayer()) {
user.sendMessage("general.errors.use-in-game");
return false;
user.sendMessage("general.errors.use-in-game");
return false;
}
getPlayers().setFlagsDisplayMode(user.getUniqueId(), Mode.EXPERT);
if (args.isEmpty()) {
Expand Down Expand Up @@ -234,9 +241,12 @@ public Optional<List<String>> tabComplete(User user, String alias, List<String>
List<String> options = new ArrayList<>();
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
if (args.size() == 2) {
// Player names or world settings
// Player names or world settings
options = Util.tabLimit(Util.getOnlinePlayerList(user), lastArg);
options.addAll(WORLD_SETTING_FLAG_NAMES);
if (getIslands().getSpawn(getWorld()).isPresent()) {
options.add(SPAWN_ISLAND);
}
} else if (args.size() == 3) {
// If world settings, then active/disabled, otherwise player flags
if (WORLD_SETTING_FLAG_NAMES.contains(args.get(1).toUpperCase(Locale.ENGLISH))) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ commands:
success: "&a Successfully set this location as the spawn point for this island."
island-spawnpoint-changed: "&a [user] changed this island spawn point."
settings:
parameters: "[player]/[world flag] [flag/active/disable] [rank/active/disable]"
parameters: "[player]/[world flag]/spawn-island [flag/active/disable] [rank/active/disable]"
description: "open settings GUI or set settings"
unknown-setting: "&c Unknown setting"
blueprint:
Expand Down

0 comments on commit 031d789

Please sign in to comment.