コード例 #1
0
  public void onCommand(
      CommandSender sender, ChunkyCommand chunkyCommand, String s, String[] strings) {
    if (!(sender instanceof Player)) {
      Language.IN_GAME_ONLY.bad(sender);
      return;
    }
    Player player = (Player) sender;
    ChunkyResident chunkyResident = new ChunkyResident(player.getName());
    ChunkyChunk chunkyChunk = chunkyResident.getChunkyPlayer().getCurrentChunk();
    ChunkyTown chunkyTown = chunkyResident.getTown();
    if (chunkyTown == null) {
      Language.sendBad(chunkyResident.getChunkyPlayer(), "You do not belong to a town.");
      return;
    }

    if (!chunkyTown.isOwnerOf(chunkyChunk)) {
      Language.sendBad(chunkyResident.getChunkyPlayer(), "This is not town land.");
      return;
    }

    if (!chunkyResident.owns(chunkyChunk) && !chunkyResident.isAssistantOrMayor()) {
      Language.sendBad(chunkyResident.getChunkyPlayer(), "You do not own this land.");
      return;
    }

    new TownChunk(chunkyChunk).setNotForSale();
    Language.sendGood(chunkyResident.getChunkyPlayer(), "This plot is no longer for sale");
  }
コード例 #2
0
  public void onCommand(
      CommandSender sender, ChunkyCommand chunkyCommand, String s, String[] strings) {
    if (!(sender instanceof Player)) {
      Language.IN_GAME_ONLY.bad(sender);
      return;
    }
    Player player = (Player) sender;
    ChunkyResident chunkyResident = new ChunkyResident(player);
    ChunkyChunk chunkyChunk = chunkyResident.getChunkyPlayer().getCurrentChunk();
    ChunkyTown chunkyTown = chunkyResident.getTown();
    if (chunkyTown == null) {
      Strings.NO_TOWN.bad(chunkyResident);
      return;
    }

    if (!chunkyTown.isOwnerOf(chunkyChunk)) {
      Strings.NOT_TOWN_LAND.bad(chunkyResident);
      return;
    }

    if (!chunkyResident.owns(chunkyChunk) && !chunkyResident.isAssistantOrMayor()) {
      Strings.NOT_OWNED.bad(chunkyResident);
      return;
    }

    double cost = 100;

    if (strings.length > 0) {
      cost = Tools.parseDouble(strings[0]);
      if (cost < 0) Strings.SPECIFY_NUMBER.bad(chunkyResident);
    }

    new TownChunk(chunkyChunk).setForSale(cost);
    Strings.FORSALE.good(chunkyResident, Chunky.getMethod().format(cost));
  }
コード例 #3
0
ファイル: NewTown.java プロジェクト: rymate1234/ChunkyVillage
 public void onCommand(
     CommandSender sender, ChunkyCommand chunkyCommand, String s, String[] strings) {
   if (!(sender instanceof Player)) {
     Language.IN_GAME_ONLY.bad(sender);
     return;
   }
   if (!Permissions.CREATE_TOWN.has(sender)) {
     Language.NO_COMMAND_PERMISSION.bad(sender);
     return;
   }
   Player player = (Player) sender;
   ChunkyResident chunkyResident = new ChunkyResident(player);
   if (chunkyResident.getTown() != null) {
     Language.sendBad(chunkyResident.getChunkyPlayer(), "You are already part of a town.");
     return;
   }
   if (strings.length < 1) {
     Language.sendBad(chunkyResident.getChunkyPlayer(), "Please specify the town name.");
     return;
   }
   ChunkyChunk chunkyChunk = chunkyResident.getChunkyPlayer().getCurrentChunk();
   if (chunkyChunk.isOwned()) {
     Language.sendBad(chunkyResident.getChunkyPlayer(), "This chunk is already owned.");
     return;
   }
   String id = strings[0];
   ChunkyTown chunkyTown = new ChunkyTown();
   chunkyTown.setId(ChunkyManager.getUniqueId());
   chunkyTown.setMayor(chunkyResident).setHome(chunkyChunk).setName(id);
   chunkyChunk.setOwner(chunkyTown, true, true);
   chunkyChunk.save();
   Language.sendGood(
       chunkyResident.getChunkyPlayer(),
       "You've just created a town called " + chunkyTown.getName());
 }