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())); } }
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)); } }
public Boolean addPlayer(String name) { Player p = Bukkit.getServer().getPlayer(name); if (p == null) { return false; } if (p.getName().equals(leader)) { return false; } members.add(name); /* Dodanie gracza do cuboidu i configu */ RegionManager regionManager = getRegionManager(world); String prefix = Config.getPrefix(); DefaultDomain dd = regionManager.getRegion(prefix + akronim).getMembers(); dd.addPlayer(name); regionManager.getRegion(prefix + akronim).setMembers(dd); try { regionManager.save(); } catch (ProtectionDatabaseException ex) { Logger.getLogger(Wioska.class.getName()).log(Level.SEVERE, null, ex); } saveWioska(); return true; }
public void deleteCuboid() { WioskiFile wioskiFile = plugin.getWioskiFile(); WorldGuardPlugin wgp = WorldGuard.getWorldGuard(plugin); World w = Bukkit.getServer().getWorld(world); RegionManager regionManager = wgp.getRegionManager(w); String prefix = Config.getPrefix(); regionManager.removeRegion(prefix + getAkronim()); }
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")); } }
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; }
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())); } }
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 }
private void createCuboid() throws Exception { RegionManager regionManager = getRegionManager(world); String prefix = Config.getPrefix(); ProtectedCuboidRegion pr = new ProtectedCuboidRegion(prefix + akronim, getPos1(), getPos2()); DefaultDomain dd = new DefaultDomain(); dd.addPlayer(leader); for (String s : members) { dd.addPlayer(s); } pr.setMembers(dd); pr.setFlag(DefaultFlag.USE, State.DENY); regionManager.addRegion(pr); }
public Boolean removePlayer(String name) { if (!members.contains(name)) { return false; } members.remove(name); /* Usunięcie gracza z cuboidu i configu */ RegionManager regionManager = getRegionManager(world); String prefix = Config.getPrefix(); DefaultDomain dd = regionManager.getRegion(prefix + akronim).getMembers(); dd.removePlayer(name); regionManager.getRegion(prefix + akronim).setMembers(dd); try { regionManager.save(); } catch (ProtectionDatabaseException ex) { Logger.getLogger(Wioska.class.getName()).log(Level.SEVERE, null, ex); } saveWioska(); return true; }
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())); }