Java Code Examples for br.net.fabiozumbi12.RedProtect.Bukkit.Region#flagExists()
The following examples show how to use
br.net.fabiozumbi12.RedProtect.Bukkit.Region#flagExists() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoorManager.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public static void ChangeDoor(Block b, Region r) { try { if ((!r.flagExists("smart-door") && !RedProtect.get().config.configRoot().flags.get("smart-door")) || !r.getFlagBool("smart-door")) { return; } } catch (Exception ignored) { return; } if (!blocks.contains(b)) { blocks.add(b); Bukkit.getScheduler().runTaskLater(RedProtect.get(), () -> blocks.remove(b), 1); } else return; if (b.getType().name().contains("IRON")) { b.getWorld().playEffect(b.getLocation(), Effect.DOOR_TOGGLE, 0); toggleDoor(b); } if (b.getType().name().contains("TRAP")) { return; } //check side block if is door Block[] block = new Block[4]; block[0] = b.getRelative(BlockFace.EAST); block[1] = b.getRelative(BlockFace.WEST); block[2] = b.getRelative(BlockFace.NORTH); block[3] = b.getRelative(BlockFace.SOUTH); for (Block b2 : block) { if (b.getType().equals(b2.getType())) { toggleDoor(b2); break; } } }
Example 2
Source File: EntityListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) { RedProtect.get().logger.debug(LogLevel.ENTITY, "EntityListener - Is PotionSplashEvent"); ProjectileSource thrower = event.getPotion().getShooter(); for (PotionEffect e : event.getPotion().getEffects()) { PotionEffectType t = e.getType(); if (!t.equals(PotionEffectType.BLINDNESS) && !t.equals(PotionEffectType.CONFUSION) && !t.equals(PotionEffectType.HARM) && !t.equals(PotionEffectType.HUNGER) && !t.equals(PotionEffectType.POISON) && !t.equals(PotionEffectType.SLOW) && !t.equals(PotionEffectType.SLOW_DIGGING) && !t.equals(PotionEffectType.WEAKNESS) && !t.equals(PotionEffectType.WITHER)) { return; } } Player shooter; if (thrower instanceof Player) { shooter = (Player) thrower; } else { return; } for (Entity e2 : event.getAffectedEntities()) { Region r = RedProtect.get().rm.getTopRegion(e2.getLocation()); if (event.getEntity() instanceof Player) { if (r != null && r.flagExists("pvp") && !r.canPVP((Player) event.getEntity(), shooter)) { event.setCancelled(true); return; } } else { if (r != null && !r.canInteractPassives(shooter)) { event.setCancelled(true); return; } } } }
Example 3
Source File: CommandHandler.java From RedProtect with GNU General Public License v3.0 | 4 votes |
private static boolean handleWGRegions() { if (!RedProtect.get().hooks.worldguard) { return false; } WorldGuardHelper helper = RedProtect.get().hooks.worldGuardHelper; List<RegionManager> loaded = helper.getLoaded(); if (loaded.isEmpty()) return false; int i = 0; for (RegionManager rm : loaded) { if (rm.getRegions().isEmpty()) continue; String w = rm.getName(); for (Map.Entry<String, ProtectedRegion> pr : rm.getRegions().entrySet()) { if (!pr.getValue().getType().equals(RegionType.CUBOID)) continue; if (RedProtect.get().rm.getRegion(pr.getKey(), w) != null) continue; Set<PlayerRegion> leaders; Set<PlayerRegion> members; if (!pr.getValue().getOwners().getUniqueIds().isEmpty()) leaders = pr.getValue().getOwners().getUniqueIds().stream().filter(p -> Bukkit.getPlayer(p) != null).map(o -> new PlayerRegion(o.toString(), Bukkit.getPlayer(o).getName())).collect(Collectors.toSet()); else leaders = pr.getValue().getOwners().getPlayers().stream().map(o -> new PlayerRegion(o, o)).collect(Collectors.toSet()); if (!pr.getValue().getMembers().getUniqueIds().isEmpty()) members = pr.getValue().getMembers().getUniqueIds().stream().filter(p -> Bukkit.getPlayer(p) != null).map(o -> new PlayerRegion(o.toString(), Bukkit.getPlayer(o).getName())).collect(Collectors.toSet()); else members = pr.getValue().getMembers().getPlayers().stream().map(o -> new PlayerRegion(o, o)).collect(Collectors.toSet()); if (leaders.isEmpty()) { if (members.isEmpty()) leaders.add(new PlayerRegion(RedProtect.get().config.configRoot().region_settings.default_leader, RedProtect.get().config.configRoot().region_settings.default_leader)); else leaders.addAll(members); } Location min = helper.getMinimumPoint(pr.getValue(), Bukkit.getWorld(w)); Location max = helper.getMaximumPoint(pr.getValue(), Bukkit.getWorld(w)); Region r = new Region(pr.getKey(), new HashSet<>(), members, leaders, min, max, RedProtect.get().config.getDefFlagsValues(), "", pr.getValue().getPriority(), w, RedProtect.get().getUtil().dateNow(), 0, null, true, true); for (Map.Entry<Flag<?>, Object> flag : pr.getValue().getFlags().entrySet()) { if (r.flagExists(flag.getKey().getName()) && RedProtect.get().getUtil().parseObject(flag.getValue().toString()) != null) { r.setFlag(Bukkit.getConsoleSender(), flag.getKey().getName(), RedProtect.get().getUtil().parseObject(flag.getValue().toString())); } } RedProtect.get().rm.add(r, w); RedProtect.get().logger.warning("Region converted and named to " + r.getName()); i++; } RedProtect.get().logger.success(i + " WorldGuard regions imported for world " + w); } return i > 0; }
Example 4
Source File: PlayerListener.java From RedProtect with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e) { Player p = null; RedProtect.get().logger.debug(LogLevel.PLAYER, "RPLayerListener: Is EntityDamageByEntityEvent event"); if (e.getDamager() instanceof Player) { p = (Player) e.getDamager(); } else if (e.getDamager() instanceof Projectile) { Projectile proj = (Projectile) e.getDamager(); if (proj.getShooter() instanceof Player) { p = (Player) proj.getShooter(); } } if (p != null) { RedProtect.get().logger.debug(LogLevel.PLAYER, "Player: " + p.getName()); } else { RedProtect.get().logger.debug(LogLevel.PLAYER, "Player: is null"); return; } RedProtect.get().logger.debug(LogLevel.PLAYER, "Damager: " + e.getDamager().getType().name()); Location l = e.getEntity().getLocation(); Region r = RedProtect.get().rm.getTopRegion(l); if (r == null) { return; } if (RedProtect.get().tpWait.contains(p.getName())) { RedProtect.get().tpWait.remove(p.getName()); RedProtect.get().lang.sendMessage(p, "cmdmanager.region.tpcancelled"); } if (e.getEntity() instanceof Player && !p.equals(e.getEntity()) && r.flagExists("pvp") && !r.canPVP((Player) e.getEntity(), p)) { RedProtect.get().lang.sendMessage(p, "entitylistener.region.cantpvp"); e.setCancelled(true); } if ((e.getEntity() instanceof Hanging || e.getEntity() instanceof EnderCrystal) && !r.canBuild(p) && !r.canBreak(e.getEntityType())) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantremove"); e.setCancelled(true); } if ((e.getEntity() instanceof Boat || e.getEntity() instanceof Minecart) && !r.canMinecart(p)) { RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbreak"); e.setCancelled(true); } }