Beispiel #1
0
 private static void delete(String akronim) {
   WioskiFile wioskiFile = plugin.getWioskiFile();
   Wioska w = getWioska(akronim);
   if (w != null) {
     w.delete();
     if (Config.getBroadcast()) {
       Bukkit.getServer()
           .broadcastMessage(Config.getMessage("rozwiazanoWioske", w.getAkronim(), w.getNazwa()));
     }
     plugin
         .getLogger()
         .log(Level.INFO, Config.getMessage("rozwiazanoWioske", w.getAkronim(), w.getNazwa()));
   }
 }
Beispiel #2
0
  public static void lista(CommandSender sender) {
    WioskiFile wioskiFile = plugin.getWioskiFile();
    ConfigurationSection cs = wioskiFile.getConfig().getConfigurationSection("wioski");

    sender.sendMessage(Config.getMessage("listaWiosek"));
    Set<String> wioski = cs.getKeys(false);
    if (wioski.size() < 1) {
      sender.sendMessage(Config.getMessage("brakWiosek"));
      return;
    }
    for (String s : wioski) {
      String n = wioskiFile.getConfig().getString("wioski." + s + ".nazwa");
      sender.sendMessage(Config.getMessage("listaWiosekPkt", s, n));
    }
  }
Beispiel #3
0
  public static void stworzWioske(Player player, String nazwa, String akronim) {
    WioskiFile wioskiFile = plugin.getWioskiFile();
    ConfigurationSection cs = wioskiFile.getConfig().getConfigurationSection("wioski");
    Set<String> wioski = cs.getKeys(false);
    for (String s : wioski) {
      if (s.toLowerCase().equals(akronim.toLowerCase())) {
        player.sendMessage(Config.getMessage("nieStworzonoWioski", nazwa, akronim));
        player.sendMessage(Config.getMessage("wioskaIstnieje", s));
        return;
      }
    }
    Wioska wioska = new Wioska(nazwa, akronim);
    wioska.setLeader(player.getName());
    wioska.setMembers(new ArrayList<String>());
    wioska.setWorld(player.getLocation().getWorld().getName());

    Location pLocation = player.getLocation();

    wioska.setPos1(pLocation.getBlockX(), pLocation.getBlockY() - 1, pLocation.getBlockZ());
    wioska.setPos2(
        pLocation.getBlockX() + Config.getWidth() - 1,
        pLocation.getBlockY() - 1 + Config.getHeight() - 1,
        pLocation.getBlockZ() + Config.getLength() - 1);

    wioska.setExpired(
        new Date(
            System.currentTimeMillis()
                + (plugin.getConfig().getInt("settings.extend_time") * 3600000 * 24)));
    wioska.setEstimated(new Date(System.currentTimeMillis()));
    try {
      wioska.createCuboid();
      wioskiFile.addWioska(wioska);
      wioskiFile.saveConfig();
      if (Config.getBroadcast()) {
        Bukkit.getServer()
            .broadcastMessage(
                Config.getMessage("stworzonoWioske", player.getName(), nazwa, akronim));
      } else {
        player.sendMessage(Config.getMessage("stworzonoWioske", player.getName(), nazwa, akronim));
      }
      return;
    } catch (Exception ex) {
      Logger.getLogger(Wioska.class.getName()).log(Level.SEVERE, null, ex);
    }

    // Message that something really bad has happened and village hasn't been created
  }
Beispiel #4
0
 public static void delete(Player player) {
   WioskiFile wioskiFile = plugin.getWioskiFile();
   Wioska w = getWioska(player);
   if (w != null) {
     if (w.getLeader().equals(player.getName())) {
       w.delete();
       if (Config.getBroadcast()) {
         Bukkit.getServer()
             .broadcastMessage(
                 Config.getMessage("rozwiazanoWioske", w.getAkronim(), w.getNazwa()));
       } else {
         player.sendMessage(Config.getMessage("rozwiazanoWioske", w.getAkronim(), w.getNazwa()));
       }
     }
   } else {
     player.sendMessage(Config.getMessage("nieJestesWiosce"));
   }
 }
Beispiel #5
0
  public static Boolean addPlayer(String member, Player sender) {
    Wioska w = Wioska.getWioska(sender);
    if (w == null) {
      return false;
    }

    if (!w.addPlayer(member)) {
      return false;
    }

    if (Config.getBroadcast()) {
      Bukkit.getServer()
          .broadcastMessage(Config.getMessage("usunietoUsera", member, w.getAkronim()));
    } else {
      sender.sendMessage(Config.getMessage("usunietoUsera", member, w.getAkronim()));
    }
    return true;
  }
Beispiel #6
0
  public static void removePlayer(Player sender) {
    Wioska w = Wioska.getWioska(sender);
    if (w == null) {
      sender.sendMessage(Config.getMessage("nieJestesWiosce"));
      return;
    }

    if (sender.getName().equals(w.getLeader())) {
      return;
    }

    if (!w.removePlayer(sender.getName())) {
      return;
    }

    if (Config.getBroadcast()) {
      Bukkit.getServer()
          .broadcastMessage(Config.getMessage("usunietoUsera", sender.getName(), w.getAkronim()));
    } else {
      sender.sendMessage(Config.getMessage("usunietoUsera", sender.getName(), w.getAkronim()));
    }
  }
Beispiel #7
0
 public void showInfo(CommandSender sender) {
   StringBuilder sb = new StringBuilder();
   Iterator<String> ite = members.iterator();
   while (ite.hasNext()) {
     sb.append(ite.next());
     if (ite.hasNext()) {
       sb.append(", ");
     }
   }
   String pos =
       "("
           + pos1.getBlockX()
           + ", "
           + pos1.getBlockY()
           + ", "
           + pos1.getBlockZ()
           + ") => "
           + "("
           + pos2.getBlockX()
           + ", "
           + pos2.getBlockY()
           + ", "
           + pos2.getBlockZ()
           + ")";
   sender.sendMessage(
       Config.getMessage(
           "infoWioska",
           akronim,
           nazwa,
           leader,
           sb.toString(),
           world,
           pos,
           getEstimated(),
           getExpired()));
 }