Search in sources :

Example 1 with SoliniaZoneCreationException

use of com.solinia.solinia.Exceptions.SoliniaZoneCreationException in project solinia3-core by mixxit.

the class SoliniaZoneFactory method Create.

public static SoliniaZone Create(String zonename, int x, int y, int z, boolean operatorCreated) throws CoreStateInitException, SoliniaZoneCreationException {
    if (StateManager.getInstance().getConfigurationManager().getZone(zonename.toUpperCase()) != null)
        throw new SoliniaZoneCreationException("Zone already exists");
    SoliniaZone zone = new SoliniaZone();
    zone.setId(StateManager.getInstance().getConfigurationManager().getNextZoneId());
    zone.setName(zonename.toUpperCase());
    zone.setX(x);
    zone.setY(y);
    zone.setZ(z);
    zone.setOperatorCreated(operatorCreated);
    StateManager.getInstance().getConfigurationManager().addZone(zone);
    return zone;
}
Also used : SoliniaZone(com.solinia.solinia.Models.SoliniaZone) SoliniaZoneCreationException(com.solinia.solinia.Exceptions.SoliniaZoneCreationException)

Example 2 with SoliniaZoneCreationException

use of com.solinia.solinia.Exceptions.SoliniaZoneCreationException in project solinia3-core by mixxit.

the class CommandCreateZone method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp() && !player.hasPermission("solinia.createzone")) {
            player.sendMessage("You do not have permission to access this command");
            return false;
        }
    }
    if (args.length < 4) {
        sender.sendMessage("Insufficient arguments: namenospaces x y z");
        return false;
    }
    String zonename = args[0].toUpperCase();
    int x = Integer.parseInt(args[1]);
    int y = Integer.parseInt(args[2]);
    int z = Integer.parseInt(args[3]);
    if (zonename.equals("")) {
        sender.sendMessage("Name of Zone cannot be null");
        return false;
    }
    try {
        SoliniaZone zone = SoliniaZoneFactory.Create(zonename, x, y, z, sender.isOp());
        sender.sendMessage("Created Zone: " + zone.getId());
    } catch (CoreStateInitException | SoliniaZoneCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) SoliniaZone(com.solinia.solinia.Models.SoliniaZone) SoliniaZoneCreationException(com.solinia.solinia.Exceptions.SoliniaZoneCreationException)

Aggregations

SoliniaZoneCreationException (com.solinia.solinia.Exceptions.SoliniaZoneCreationException)2 SoliniaZone (com.solinia.solinia.Models.SoliniaZone)2 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)1 CommandSender (org.bukkit.command.CommandSender)1 Player (org.bukkit.entity.Player)1