示例#1
0
  @CommandNode(
      name = "unclaim",
      permission = "mytown.cmd.assistant.unclaim",
      parentName = "mytown.cmd")
  public static void unclaimCommand(ICommandSender sender, List<String> args) {
    EntityPlayer pl = (EntityPlayer) sender;
    Resident res = getDatasource().getOrMakeResident(pl);
    Block block = getBlockAtResident(res);
    Town town = block.getTown();

    if (!block.isPointIn(
        town.getSpawn().getDim(), town.getSpawn().getX(), town.getSpawn().getZ())) {
      getDatasource().deleteBlock(block);
      res.sendMessage(
          getLocal()
              .getLocalization(
                  "mytown.notification.block.removed",
                  block.getX() << 4,
                  block.getZ() << 4,
                  block.getX() << 4 + 15,
                  block.getZ() << 4 + 15,
                  town.getName()));
    } else {
      throw new CommandException("§cYou cannot delete the Block containing the spawn point!");
    }
  }
示例#2
0
  @Command(
      name = "unclaim",
      permission = "mytown.cmd.assistant.unclaim",
      parentName = "mytown.cmd",
      syntax = "/town unclaim")
  public static CommandResponse unclaimCommand(ICommandSender sender, List<String> args) {
    EntityPlayer player = (EntityPlayer) sender;
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    TownBlock block = getBlockAtResident(res);
    Town town = getTownFromResident(res);

    if (town != block.getTown())
      throw new MyTownCommandException("mytown.cmd.err.unclaim.notInTown");
    if (block.isPointIn(town.getSpawn().getDim(), town.getSpawn().getX(), town.getSpawn().getZ()))
      throw new MyTownCommandException("mytown.cmd.err.unclaim.spawnPoint");
    if (!checkNearby(block.getDim(), block.getX(), block.getZ(), town)
        && town.townBlocksContainer.size() <= 1) {
      throw new MyTownCommandException("mytown.cmd.err.unclaim.lastClaim");
    }

    getDatasource().deleteBlock(block);
    res.sendMessage(
        getLocal()
            .getLocalization(
                "mytown.notification.block.removed",
                block.getX() << 4,
                block.getZ() << 4,
                block.getX() << 4 + 15,
                block.getZ() << 4 + 15,
                town.getName()));
    makeBankRefund(player, town, block.getPricePaid());
    return CommandResponse.DONE;
  }
示例#3
0
  @CommandNode(
      name = "setspawn",
      permission = "mytown.cmd.assistant.setspawn",
      parentName = "mytown.cmd")
  public static void setSpawnCommand(ICommandSender sender, List<String> args) {
    EntityPlayer player = (EntityPlayer) sender;
    Resident res = getDatasource().getOrMakeResident(player);
    Town town = getTownFromResident(res);

    town.getSpawn()
        .setDim(player.dimension)
        .setPosition((float) player.posX, (float) player.posY, (float) player.posZ)
        .setRotation(player.cameraYaw, player.cameraPitch);

    getDatasource().saveTown(town);

    res.sendMessage(getLocal().getLocalization("mytown.notification.town.setspawn"));
  }
示例#4
0
  @Command(
      name = "setspawn",
      permission = "mytown.cmd.assistant.setspawn",
      parentName = "mytown.cmd",
      syntax = "/town setspawn")
  public static CommandResponse setSpawnCommand(ICommandSender sender, List<String> args) {
    EntityPlayer player = (EntityPlayer) sender;
    Resident res = MyTownUniverse.instance.getOrMakeResident(player);
    Town town = getTownFromResident(res);

    if (!town.isPointInTown(player.dimension, (int) player.posX, (int) player.posZ))
      throw new MyTownCommandException(
          getLocal().getLocalization("mytown.cmd.err.setspawn.notintown", town.getName()));

    makePayment(player, Config.instance.costAmountSetSpawn.get());

    town.getSpawn()
        .setDim(player.dimension)
        .setPosition((float) player.posX, (float) player.posY, (float) player.posZ)
        .setRotation(player.cameraYaw, player.cameraPitch);
    getDatasource().saveTown(town);
    res.sendMessage(getLocal().getLocalization("mytown.notification.town.setspawn"));
    return CommandResponse.DONE;
  }