示例#1
0
  @Override
  public boolean cmd(
      BukkitCommand bkcmd, CommandSender sender, Command cmd, String label, String[] args) {
    if (!isPlayer(sender)) {
      sk(sender, "playeronly");
      return true;
    }

    Resident r = Resident.getResident(getPlayer(sender));
    Village v = Village.getPlayersVillage(r);
    if (v == null) {
      sk(sender, "notinvillage");
      return true;
    }

    if (v.isMayor(r)) {
      sk(sender, "leavevillagemayor");
      return true;
    }

    ResidentRemovedEvent event = new ResidentRemovedEvent(r, v);
    event.fireEvent();
    if (event.isCancelled()) return true;

    v.broadcast(gk("leftvillage", r));
    v.removeResident(r);
    return true;
  }
  @Override
  public boolean cmd(
      BukkitCommand bkcmd, CommandSender sender, Command cmd, String label, String[] args) {
    debug("THIS COMMAND IS IN DEVELOPMENT!!!");
    if (!isPlayer(sender)) {
      sk(sender, "playeronly");
      return true;
    }

    Player player = getPlayer(sender);
    // TODO: Figure out Wilderness Map
    Village v = Village.getPlayersVillage(Resident.getResident(player));
    if (v == null) {
      sk(sender, "notinvillage");
      return true;
    }

    VillageMap map;
    try {
      map = v.getVillageMap();
    } catch (IllegalArgumentException e) {
      // Village Map is not Available in this world
      sk(sender, "notinthisworld");
      return true;
    }

    DomsItem mapItem = map.getMapAsItem();
    try {
      mapItem.giveToPlayer(player);
    } catch (InvalidItemException e) {
      sendMessage(sender, ChatError + "An error occured...");
      return true;
    }

    sendMessage(sender, "Giving Village Map.");
    return true;
  }
  @Override
  public boolean cmd(
      BukkitCommand bkcmd, CommandSender sender, Command cmd, String label, String[] args) {
    if (args.length < 1) {
      sk(sender, "needvillagename");
      return false;
    }

    if (args.length < 2) {
      sk(sender, "enterplayer");
      return false;
    }

    Village v = Village.getVillage(args[0]);
    if (v == null) {
      sk(sender, "villagedoesntexist");
      return true;
    }

    Resident player = Resident.guessResident(args[1]);
    if (player == null) {
      sk(sender, "playernotfound");
      return true;
    }

    Village residentVillage = Village.getPlayersVillage(player);
    if (residentVillage == null) {
      sk(sender, "playernotinvillage");
      return true;
    }

    if (residentVillage.isMayor(player)) {
      sk(sender, "playeralreadymayor");
      return true;
    }

    if (!v.equals(residentVillage)) {
      sk(sender, "playerdifferentvillage");
      return true;
    }

    v.setMayor(player);
    sk(sender, "playersetmayor", player, v);
    return true;
  }
  @Override
  public boolean cmd(
      BukkitCommand bkcmd, CommandSender sender, Command cmd, String label, String[] args) {
    if (!getConfig().getBoolean("features.plots", true)) {
      sk(sender, "plotsnotenabled");
      return true;
    }
    if (!isPlayer(sender)) {
      sk(sender, "playeronly");
      return true;
    }

    Resident r = Resident.getResident(getPlayer(sender));
    Village v = Village.getPlayersVillage(r);
    if (v == null) {
      sk(sender, "notinvillage");
      return true;
    }
    if (!v.isMayor(r)) {
      sk(sender, "onlymayorplot");
      return true;
    }

    if (!Base.useEconomy) {
      sk(sender, "economydisabled");
      return true;
    }

    Region standing = Region.getRegion(getPlayer(sender));
    if (standing == null) return true;

    if (!v.isRegionOverlappingVillage(standing)) {
      sk(sender, "plotnotinvillage");
      return true;
    }

    if (args.length < 1) {
      sk(sender, "enteramt");
      return true;
    }

    if (!isDouble(args[0])) {
      sk(sender, "mustbenumber");
      return true;
    }

    double amt = getDouble(args[0]);
    if (amt <= 0) {
      sk(sender, "mustbeone");
      return true;
    }

    Plot plot = v.getPlot(standing);
    if (plot == null) {
      plot = new Plot(v, standing);
      v.addPlot(plot);
    }

    plot.setPrice(amt);
    sk(sender, "setplotprice", PluginHook.VAULT_HOOK.formatEconomy(amt));
    return true;
  }