Java Code Examples for com.wasteofplastic.askyblock.Island#getIgsFlag()
The following examples show how to use
com.wasteofplastic.askyblock.Island#getIgsFlag() .
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: IslandGuard.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Handle visitor chicken egg throwing * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEggThrow(PlayerEggThrowEvent e) { if (DEBUG) { plugin.getLogger().info("egg throwing = " + e.getEventName()); } if (!inWorld(e.getPlayer()) || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().playerIsOnIsland(e.getPlayer()) || plugin.getGrid().isAtSpawn(e.getPlayer().getLocation())) { return; } // Check island Island island = plugin.getGrid().getProtectedIslandAt(e.getPlayer().getLocation()); if (island == null) { return; } if (!island.getIgsFlag(SettingsFlag.EGGS)) { e.setHatching(false); Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); //e.getPlayer().updateInventory(); } return; }
Example 2
Source File: PlayerEvents2.java From askyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVisitorPickup(final PlayerPickupItemEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } if (!IslandGuard.inWorld(e.getPlayer())) { return; } Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation()); if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().locationIsOnIsland(e.getPlayer(), e.getItem().getLocation())) { return; } e.setCancelled(true); }
Example 3
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Checks if action is allowed for player in location for flag * @param uuid * @param location * @param flag * @return true if allowed */ private boolean actionAllowed(UUID uuid, Location location, SettingsFlag flag) { Player player = plugin.getServer().getPlayer(uuid); if (player == null) { return actionAllowed(location, flag); } // This permission bypasses protection if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { return true; } Island island = plugin.getGrid().getProtectedIslandAt(location); if (island != null && (island.getIgsFlag(flag) || island.getMembers().contains(player.getUniqueId()))){ return true; } if (island == null && Settings.defaultWorldSettings.get(flag)) { return true; } return false; }
Example 4
Source File: PlayerEvents.java From askyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVisitorDrop(final PlayerDropItemEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } if (!IslandGuard.inWorld(e.getPlayer())) { return; } Island island = plugin.getGrid().getIslandAt(e.getItemDrop().getLocation()); if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_DROP)) || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().locationIsOnIsland(e.getPlayer(), e.getItemDrop().getLocation())) { return; } Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); }
Example 5
Source File: PlayerEvents3.java From askyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVisitorPickup(final EntityPickupItemEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } if (e.getEntity() instanceof Player) { Player player = (Player)e.getEntity(); if (!IslandGuard.inWorld(player)) { return; } Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation()); if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().locationIsOnIsland(player, e.getItem().getLocation())) { return; } e.setCancelled(true); } }
Example 6
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Handles Frost Walking on visitor's islands * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onBlockForm(final EntityBlockFormEvent e) { if (e.getEntity() instanceof Player && e.getNewState().getType().equals(Material.FROSTED_ICE)) { Player player= (Player) e.getEntity(); if (!IslandGuard.inWorld(player)) { return; } if (player.isOp()) { return; } // This permission bypasses protection if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { return; } // Check island Island island = plugin.getGrid().getIslandAt(player.getLocation()); if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) { return; } if (island !=null) { if (island.getMembers().contains(player.getUniqueId()) || island.getIgsFlag(SettingsFlag.PLACE_BLOCKS)) { return; } } // Silently cancel the event e.setCancelled(true); } }
Example 7
Source File: IslandGuard1_8.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void ArmorStandDestroy(EntityDamageByEntityEvent e) { if (DEBUG) { plugin.getLogger().info("1.8 " + "IslandGuard New " + e.getEventName()); } if (!(e.getEntity() instanceof LivingEntity)) { return; } if (!IslandGuard.inWorld(e.getEntity())) { return; } final LivingEntity livingEntity = (LivingEntity) e.getEntity(); if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) { return; } if (e.getDamager() instanceof Player) { Player p = (Player) e.getDamager(); if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { return; } // Check if on island if (plugin.getGrid().playerIsOnIsland(p)) { return; } // Check island Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation()); if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) { return; } if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) { return; } Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected); e.setCancelled(true); } }
Example 8
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Checks if action is allowed for player in location for flag * @param player * @param location * @param flag * @return true if allowed */ private boolean actionAllowed(Player player, Location location, SettingsFlag flag) { if (player == null) { return actionAllowed(location, flag); } // This permission bypasses protection if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { return true; } Island island = plugin.getGrid().getProtectedIslandAt(location); if (island != null && (island.getIgsFlag(flag) || island.getMembers().contains(player.getUniqueId()))){ return true; } return island == null && Settings.defaultWorldSettings.get(flag); }
Example 9
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Action allowed in this location * @param location * @param flag * @return true if allowed */ private boolean actionAllowed(Location location, SettingsFlag flag) { Island island = plugin.getGrid().getProtectedIslandAt(location); if (island != null && island.getIgsFlag(flag)){ return true; } return island == null && Settings.defaultWorldSettings.get(flag); }
Example 10
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Action allowed in this location * @param location * @param flag * @return true if allowed */ private boolean actionAllowed(Location location, SettingsFlag flag) { Island island = plugin.getGrid().getProtectedIslandAt(location); if (island != null && island.getIgsFlag(flag)){ return true; } return island == null && Settings.defaultWorldSettings.get(flag); }
Example 11
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onRodDamage(final PlayerFishEvent e) { if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { return; } if (!IslandGuard.inWorld(e.getPlayer().getLocation())) { return; } Player p = e.getPlayer(); if (e.getCaught() != null && (e.getCaught().getType().equals(EntityType.ARMOR_STAND) || e.getCaught().getType().equals(EntityType.ENDER_CRYSTAL))) { if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { return; } // Check if on island if (plugin.getGrid().playerIsOnIsland(p)) { return; } // Check island Island island = plugin.getGrid().getIslandAt(e.getCaught().getLocation()); if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) { return; } if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) { return; } Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected); e.getHook().remove(); e.setCancelled(true); } }
Example 12
Source File: IslandGuard1_8.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Checks if action is allowed for player in location for flag * @param player * @param location * @param flag * @return true if allowed */ private boolean actionAllowed(Player player, Location location, SettingsFlag flag) { // This permission bypasses protection if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { return true; } Island island = plugin.getGrid().getProtectedIslandAt(location); if (island != null && (island.getIgsFlag(flag) || island.getMembers().contains(player.getUniqueId()))){ return true; } return island == null && Settings.defaultWorldSettings.get(flag); }
Example 13
Source File: WarpPanel.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Updates the meta text on the warp sign icon by looking at the warp sign * This MUST be run 1 TICK AFTER the sign has been created otherwise the sign is blank * @param playerSign * @param playerUUID - the player's UUID * @return updated skull item stack */ private ItemStack updateText(ItemStack playerSign, final UUID playerUUID) { if (DEBUG) plugin.getLogger().info("DEBUG: Updating text on item"); ItemMeta meta = playerSign.getItemMeta(); //get the sign info Location signLocation = plugin.getWarpSignsListener().getWarp(playerUUID); if (signLocation == null) { plugin.getWarpSignsListener().removeWarp(playerUUID); return playerSign; } //plugin.getLogger().info("DEBUG: block type = " + signLocation.getBlock().getType()); // Get the sign info if it exists if (signLocation.getBlock().getType().equals(Material.SIGN_POST) || signLocation.getBlock().getType().equals(Material.WALL_SIGN)) { Sign sign = (Sign)signLocation.getBlock().getState(); List<String> lines = new ArrayList<String>(Arrays.asList(sign.getLines())); // Check for PVP and add warning Island island = plugin.getGrid().getIsland(playerUUID); if (island != null) { if ((signLocation.getWorld().equals(ASkyBlock.getIslandWorld()) && island.getIgsFlag(SettingsFlag.PVP)) || (signLocation.getWorld().equals(ASkyBlock.getNetherWorld()) && island.getIgsFlag(SettingsFlag.NETHER_PVP))) { if (DEBUG) plugin.getLogger().info("DEBUG: pvp warning added"); lines.add(ChatColor.RED + plugin.myLocale().igs.get(SettingsFlag.PVP)); } } meta.setLore(lines); if (DEBUG) plugin.getLogger().info("DEBUG: lines = " + lines); } else { // No sign there - remove the warp plugin.getWarpSignsListener().removeWarp(playerUUID); } playerSign.setItemMeta(meta); return playerSign; }
Example 14
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onFishing(final PlayerFishEvent e) { if (DEBUG) { plugin.getLogger().info("Player fish event " + e.getEventName()); plugin.getLogger().info("Player fish event " + e.getCaught()); } if (e.getCaught() == null) return; Player p = e.getPlayer(); if (!inWorld(p)) { return; } if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { // You can do anything if you are Op of have the bypass return; } // Handle rods Island island = plugin.getGrid().getProtectedIslandAt(e.getCaught().getLocation()); // PVP check if (e.getCaught() instanceof Player) { // Check if this is the player who is holding the rod if (e.getCaught().equals(e.getPlayer())) { if (DEBUG) plugin.getLogger().info("DEBUG: player cught themselves!"); return; } if (island == null && (e.getCaught().getWorld().getEnvironment().equals(Environment.NORMAL) && !Settings.defaultWorldSettings.get(SettingsFlag.PVP)) || ((e.getCaught().getWorld().getEnvironment().equals(Environment.NETHER) && !Settings.defaultWorldSettings.get(SettingsFlag.NETHER_PVP)))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).targetInNoPVPArea); e.setCancelled(true); e.getHook().remove(); return; } if (island != null && ((e.getCaught().getWorld().getEnvironment().equals(Environment.NORMAL) && !island.getIgsFlag(SettingsFlag.PVP)) || (e.getCaught().getWorld().getEnvironment().equals(Environment.NETHER) && !island.getIgsFlag(SettingsFlag.NETHER_PVP)))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).targetInNoPVPArea); e.setCancelled(true); e.getHook().remove(); return; } } if (!plugin.getGrid().playerIsOnIsland(e.getPlayer())) { if (e.getCaught() instanceof Animals) { if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.HURT_MOBS)) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } if (island != null) { if ((!island.getIgsFlag(SettingsFlag.HURT_MOBS) && !island.getMembers().contains(p.getUniqueId()))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } } } // Monster protection if (e.getCaught() instanceof Monster || e.getCaught() instanceof Squid || e.getCaught() instanceof Slime) { if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.HURT_MONSTERS)) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } if (island != null) { if ((!island.getIgsFlag(SettingsFlag.HURT_MONSTERS) && !island.getMembers().contains(p.getUniqueId()))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); } } } } }
Example 15
Source File: AcidEffect.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Check if player can be burned by acid * @param player * @return true if player is not safe */ private boolean isSafeFromAcid(Player player) { if (DEBUG) plugin.getLogger().info("DEBUG: safe from acid"); if (!player.getWorld().equals(ASkyBlock.getIslandWorld())) { if (DEBUG) plugin.getLogger().info("DEBUG: wrong world"); return true; } // In liquid Material bodyMat = player.getLocation().getBlock().getType(); Material headMat = player.getLocation().getBlock().getRelative(BlockFace.UP).getType(); if (bodyMat.equals(Material.STATIONARY_WATER)) bodyMat = Material.WATER; if (headMat.equals(Material.STATIONARY_WATER)) headMat = Material.WATER; if (bodyMat != Material.WATER && headMat != Material.WATER) { if (DEBUG) plugin.getLogger().info("DEBUG: not in water " + player.getLocation().getBlock().isLiquid() + " " + player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()); return true; } // Check if player is in a boat Entity playersVehicle = player.getVehicle(); if (playersVehicle != null) { // They are in a Vehicle if (playersVehicle.getType().equals(EntityType.BOAT)) { // I'M ON A BOAT! I'M ON A BOAT! A %^&&* BOAT! if (DEBUG) plugin.getLogger().info("DEBUG: boat"); return true; } } // Check if full armor protects if (Settings.fullArmorProtection) { boolean fullArmor = true; for (ItemStack item : player.getInventory().getArmorContents()) { if (item == null || (item != null && item.getType().equals(Material.AIR))) { fullArmor = false; break; } } if (fullArmor) { if (DEBUG) plugin.getLogger().info("DEBUG: full armor"); return true; } } // Check if player has an active water potion or not Collection<PotionEffect> activePotions = player.getActivePotionEffects(); for (PotionEffect s : activePotions) { // plugin.getLogger().info("Potion is : " + // s.getType().toString()); if (s.getType().equals(PotionEffectType.WATER_BREATHING)) { // Safe! if (DEBUG) plugin.getLogger().info("DEBUG: Water breathing potion protection!"); return true; } } // Check if water above sea-level is not acid Island island = plugin.getGrid().getIslandAt(player.getLocation()); if (island != null && !island.getIgsFlag(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) { if (DEBUG) plugin.getLogger().info("DEBUG:no acid damage above sea level 1"); return true; } if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) { if (DEBUG) plugin.getLogger().info("DEBUG: no acid damage above sea level"); return true; } if (DEBUG) plugin.getLogger().info("DEBUG: burn in acid"); return false; }
Example 16
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onProjectileHit(EntityInteractEvent e) { if (e.getEntity() == null || !(e.getEntity() instanceof Projectile)) { return; } Projectile p = (Projectile)e.getEntity(); if (p.getShooter() != null && p.getShooter() instanceof Player && e.getBlock() != null) { Player player = (Player)p.getShooter(); if (!inWorld(player) || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().playerIsOnIsland(player)) { return; } Island island = plugin.getGrid().getProtectedIslandAt(e.getBlock().getLocation()); switch(e.getBlock().getType()) { case WOOD_BUTTON: case STONE_BUTTON: if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.LEVER_BUTTON))) { return; } if (island != null && island.getIgsFlag(SettingsFlag.LEVER_BUTTON)) { return; } Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandProtected); e.setCancelled(true); break; case WOOD_PLATE: case STONE_PLATE: case GOLD_PLATE: case IRON_PLATE: // Pressure plates if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.PRESSURE_PLATE))) { return; } if (island != null && island.getIgsFlag(SettingsFlag.PRESSURE_PLATE)) { return; } Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandProtected); e.setCancelled(true); break; default: break; } } }
Example 17
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) { if (!IslandGuard.inWorld(e.getEntity().getLocation())) { return; } if (e.getEntity() == null || e.getEntity().getUniqueId() == null) { return; } if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) { UUID attacker = thrownPotions.get(e.getDamager().getEntityId()); // Self damage if (attacker.equals(e.getEntity().getUniqueId())) { return; } Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation()); boolean inNether = false; if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) { inNether = true; } // Monsters being hurt if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) { // Normal island check if (island != null && island.getMembers().contains(attacker)) { // Members always allowed return; } if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) { return; } // Not allowed e.setCancelled(true); return; } // Mobs being hurt if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman || e.getEntity() instanceof Villager) { if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) { return; } e.setCancelled(true); return; } // Establish whether PVP is allowed or not. boolean pvp = false; if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) { pvp = true; } // Players being hurt PvP if (e.getEntity() instanceof Player) { if (pvp) { } else { e.setCancelled(true); } } } }
Example 18
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Checks for splash damage. If there is any to any affected entity and it's not allowed, it won't work on any of them. * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onSplashPotionSplash(final PotionSplashEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info("splash entity = " + e.getEntity()); plugin.getLogger().info("splash entity type = " + e.getEntityType()); plugin.getLogger().info("splash affected entities = " + e.getAffectedEntities()); //plugin.getLogger().info("splash hit entity = " + e.getHitEntity()); } if (!IslandGuard.inWorld(e.getEntity().getLocation())) { return; } // Try to get the shooter Projectile projectile = e.getEntity(); if (DEBUG) plugin.getLogger().info("splash shooter = " + projectile.getShooter()); if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) { Player attacker = (Player)projectile.getShooter(); // Run through all the affected entities for (LivingEntity entity: e.getAffectedEntities()) { if (DEBUG) plugin.getLogger().info("DEBUG: affected splash entity = " + entity); // Self damage if (attacker.equals(entity)) { if (DEBUG) plugin.getLogger().info("DEBUG: Self damage from splash potion!"); continue; } Island island = plugin.getGrid().getIslandAt(entity.getLocation()); boolean inNether = false; if (entity.getWorld().equals(ASkyBlock.getNetherWorld())) { inNether = true; } // Monsters being hurt if (entity instanceof Monster || entity instanceof Slime || entity instanceof Squid) { // Normal island check if (island != null && island.getMembers().contains(attacker.getUniqueId())) { // Members always allowed continue; } if (actionAllowed(attacker, entity.getLocation(), SettingsFlag.HURT_MONSTERS)) { continue; } // Not allowed Util.sendMessage(attacker, ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).islandProtected); e.setCancelled(true); return; } // Mobs being hurt if (entity instanceof Animals || entity instanceof IronGolem || entity instanceof Snowman || entity instanceof Villager) { if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker.getUniqueId()))) { continue; } if (DEBUG) plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking"); Util.sendMessage(attacker, ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).islandProtected); e.setCancelled(true); return; } // Establish whether PVP is allowed or not. boolean pvp = false; if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed"); pvp = true; } // Players being hurt PvP if (entity instanceof Player) { if (pvp) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed"); } else { if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed"); Util.sendMessage(attacker, ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).targetInNoPVPArea); e.setCancelled(true); return; } } } } }
Example 19
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true) void placeEndCrystalEvent(final PlayerInteractEvent e) { Player p = e.getPlayer(); if (!IslandGuard.inWorld(p)) { return; } if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { // You can do anything if you are Op return; } // Check if they are holding armor stand for (ItemStack inHand : Util.getPlayerInHandItems(e.getPlayer())) { if (inHand.getType().equals(Material.END_CRYSTAL)) { // Check island Island island = plugin.getGrid().getIslandAt(e.getPlayer().getLocation()); if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) { return; } if (island !=null && (island.getMembers().contains(p.getUniqueId()) || island.getIgsFlag(SettingsFlag.PLACE_BLOCKS))) { //plugin.getLogger().info("1.9 " +"DEBUG: armor stand place check"); if (Settings.limitedBlocks.containsKey("END_CRYSTAL") && Settings.limitedBlocks.get("END_CRYSTAL") > -1) { //plugin.getLogger().info("1.9 " +"DEBUG: count armor stands"); int count = island.getTileEntityCount(Material.END_CRYSTAL,e.getPlayer().getWorld()); //plugin.getLogger().info("1.9 " +"DEBUG: count is " + count + " limit is " + Settings.limitedBlocks.get("ARMOR_STAND")); if (Settings.limitedBlocks.get("END_CRYSTAL") <= count) { Util.sendMessage(e.getPlayer(), ChatColor.RED + (plugin.myLocale(e.getPlayer().getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(Material.END_CRYSTAL.toString()))).replace("[number]", String.valueOf(Settings.limitedBlocks.get("END_CRYSTAL")))); e.setCancelled(true); return; } } return; } // plugin.getLogger().info("1.9 " +"DEBUG: stand place cancelled"); e.setCancelled(true); Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.getPlayer().updateInventory(); } } }
Example 20
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerBlockPlace(final HangingPlaceEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info("DEBUG: block placed " + e.getBlock().getType()); plugin.getLogger().info("DEBUG: entity " + e.getEntity().getType()); } if (Settings.allowedFakePlayers.contains(e.getPlayer().getName())) return; // plugin.getLogger().info(e.getEventName()); if (IslandGuard.inWorld(e.getPlayer())) { // This permission bypasses protection if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { return; } Island island = plugin.getGrid().getProtectedIslandAt(e.getBlock().getLocation()); // Outside of island protection zone if (island == null) { if (!Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); } return; } if (island.getIgsFlag(SettingsFlag.PLACE_BLOCKS) || island.getMembers().contains(e.getPlayer().getUniqueId())) { // Check how many placed String type = e.getEntity().getType().toString(); if (e.getEntity().getType().equals(EntityType.ITEM_FRAME) || e.getEntity().getType().equals(EntityType.PAINTING)) { // tile entity placed if (Settings.limitedBlocks.containsKey(type) && Settings.limitedBlocks.get(type) > -1) { // Convert from EntityType to Material via string - ugh int count = island.getTileEntityCount(Material.valueOf(type),e.getEntity().getWorld()); if (Settings.limitedBlocks.get(type) <= count) { Util.sendMessage(e.getPlayer(), ChatColor.RED + (plugin.myLocale(e.getPlayer().getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(type))).replace("[number]", String.valueOf(Settings.limitedBlocks.get(type)))); e.setCancelled(true); } } } } else { // Visitor Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); } } }