Added /bsb range reset <player>

This commit is contained in:
Florian CUNY 2018-07-19 13:31:47 +02:00
parent a5a1ccb7e5
commit e15ed63899
3 changed files with 53 additions and 0 deletions

View File

@ -21,6 +21,7 @@ public class AdminRangeCommand extends CompositeCommand {
new AdminRangeDisplayCommand(this);
new AdminRangeSetCommand(this);
new AdminRangeResetCommand(this);
}
@Override

View File

@ -0,0 +1,51 @@
package us.tastybento.bskyblock.commands.admin.range;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import java.util.List;
import java.util.UUID;
public class AdminRangeResetCommand extends CompositeCommand {
public AdminRangeResetCommand(CompositeCommand parent) {
super(parent, "reset");
}
@Override
public void setup() {
setPermission("admin.range.reset");
setParameters("commands.admin.range.reset.parameters");
setDescription("commands.admin.range.reset.description");
}
@Override
public boolean execute(User user, String label, List<String> args) {
if (args.size() != 1) {
// Show help
showHelp(this, user);
return false;
}
// Get target player
UUID targetUUID = getPlayers().getUUID(args.get(0));
if (targetUUID == null) {
user.sendMessage("general.errors.unknown-player");
return false;
}
if (!getPlugin().getIslands().hasIsland(getWorld(), targetUUID)) {
user.sendMessage("general.errors.player-has-no-island");
return false;
}
// Get island
Island island = getIslands().getIsland(getWorld(), targetUUID);
// Reset the protection range
island.setProtectionRange(getSettings().getIslandProtectionRange());
// TODO send message?
return true;
}
}

View File

@ -67,6 +67,7 @@ public class AdminRangeSetCommand extends CompositeCommand {
// Well, now it can be applied without taking any risks !
island.setProtectionRange(range);
// TODO send message?
return true;
}