Java Code Examples for com.wasteofplastic.askyblock.Island#isSpawn()
The following examples show how to use
com.wasteofplastic.askyblock.Island#isSpawn() .
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 |
/** * Stop redstone if team members are offline and disableOfflineRedstone is TRUE. * @param e - event */ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockRedstone(final BlockRedstoneEvent e){ if(Settings.disableOfflineRedstone) { // Check world if (!inWorld(e.getBlock())) { return; } // Check if this is on an island Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation()); if (island == null || island.isSpawn()) { return; } for(UUID member : island.getMembers()){ if(plugin.getServer().getPlayer(member) != null) return; } e.setNewCurrent(0); } }
Example 2
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Prevents trees from growing outside of the protected area. * * @param e - event */ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTreeGrow(final StructureGrowEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } // Check world if (!IslandGuard.inWorld(e.getLocation())) { return; } // Check if this is on an island Island island = plugin.getGrid().getIslandAt(e.getLocation()); if (island == null || island.isSpawn()) { return; } Iterator<BlockState> it = e.getBlocks().iterator(); while (it.hasNext()) { BlockState b = it.next(); if (b.getType() == Material.LOG || b.getType() == Material.LOG_2 || b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) { if (!island.onIsland(b.getLocation())) { it.remove(); } } } }
Example 3
Source File: AdminCmd.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Assigns player to an island * * @param sender * - the player requesting the assignment * @param l * - the location of sender * @param newOwner * - the assignee * @return - true if successful, false if not */ public boolean adminSetPlayerIsland(final CommandSender sender, final Location l, final UUID newOwner) { // Location island = getClosestIsland(l); // Check what the grid thinks Island island = plugin.getGrid().getIslandAt(l); if (island == null) { // Try to find it and create it if it isn't known Location closestIsland = plugin.getGrid().getClosestIsland(l); // Double check this is not taken already island = plugin.getGrid().getIslandAt(closestIsland); if (island == null) { // Still not known - make an island island = plugin.getGrid().addIsland(closestIsland.getBlockX(), closestIsland.getBlockZ()); } } if (island.isSpawn()) { Util.sendMessage(sender, ChatColor.RED + plugin.myLocale().adminRegisterNotSpawn); return false; } UUID oldOwner = island.getOwner(); if (oldOwner != null) { if (plugin.getPlayers().inTeam(oldOwner)) { Util.sendMessage(sender, ChatColor.RED + plugin.myLocale().adminRegisterLeadsTeam.replace("[name]", plugin.getPlayers().getName(oldOwner))); return false; } Util.sendMessage(sender, ChatColor.RED + plugin.myLocale().adminRegisterTaking.replace("[name]", plugin.getPlayers().getName(oldOwner))); plugin.getPlayers().setIslandLevel(newOwner, plugin.getPlayers().getIslandLevel(oldOwner)); plugin.getPlayers().setTeamIslandLocation(oldOwner, null); plugin.getPlayers().setHasIsland(oldOwner, false); plugin.getPlayers().setIslandLocation(oldOwner, null); plugin.getPlayers().setIslandLevel(oldOwner, 0); plugin.getPlayers().setTeamIslandLocation(oldOwner, null); // plugin.topTenChangeOwner(oldOwner, newOwner); } // Check if the assigned player already has an island Island playersIsland = plugin.getGrid().getIsland(newOwner); if (playersIsland != null) { Util.sendMessage(sender, ChatColor.RED + (plugin.myLocale().adminRegisterHadIsland.replace("[name]", plugin.getPlayers().getName(playersIsland.getOwner())).replace("[location]", playersIsland.getCenter().getBlockX() + "," + playersIsland.getCenter().getBlockZ()))); plugin.getGrid().setIslandOwner(playersIsland, null); } if (sender instanceof Player && Settings.createNether && Settings.newNether && ((Player)sender).getWorld().equals(ASkyBlock.getNetherWorld())) { // Island in new nether plugin.getPlayers().setHomeLocation(newOwner, island.getCenter().toVector().toLocation(ASkyBlock.getNetherWorld())); plugin.getPlayers().setIslandLocation(newOwner, island.getCenter().toVector().toLocation(ASkyBlock.getNetherWorld())); } else { // Island in overworld plugin.getPlayers().setHomeLocation(newOwner, island.getCenter()); plugin.getPlayers().setIslandLocation(newOwner, island.getCenter()); } plugin.getPlayers().setHasIsland(newOwner, true); // Change the grid plugin.getGrid().setIslandOwner(island, newOwner); return true; }
Example 4
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Trap TNT being primed by flaming arrows * @param e - event */ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTNTPrimed(final EntityChangeBlockEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); plugin.getLogger().info("DEBUG: block = " + e.getBlock().getType()); plugin.getLogger().info("DEBUG: entity = " + e.getEntityType()); plugin.getLogger().info("DEBUG: material changing to " + e.getTo()); } if (actionAllowed(e.getEntity().getLocation(), SettingsFlag.FIRE)) { return; } if (e.getBlock() == null) { return; } // Check for TNT if (!e.getBlock().getType().equals(Material.TNT)) { //plugin.getLogger().info("DEBUG: not tnt"); return; } // Check world if (!inWorld(e.getBlock())) { return; } // Check if this is on an island Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation()); if (island == null || island.isSpawn()) { return; } // Stop TNT from being damaged if it is being caused by a visitor with a flaming arrow if (e.getEntity() instanceof Projectile) { //plugin.getLogger().info("DEBUG: projectile"); Projectile projectile = (Projectile) e.getEntity(); // Find out who fired it if (projectile.getShooter() instanceof Player) { //plugin.getLogger().info("DEBUG: player shot arrow. Fire ticks = " + projectile.getFireTicks()); if (projectile.getFireTicks() > 0) { //plugin.getLogger().info("DEBUG: arrow on fire"); Player shooter = (Player)projectile.getShooter(); if (!plugin.getGrid().locationIsAtHome(shooter, true, e.getBlock().getLocation())) { //plugin.getLogger().info("DEBUG: shooter is not at home"); // Only say it once a second // Debounce event (it can be called twice for the same action) if (!tntBlocks.contains(e.getBlock().getLocation())) { Util.sendMessage(shooter, ChatColor.RED + plugin.myLocale(shooter.getUniqueId()).islandProtected); tntBlocks.add(e.getBlock().getLocation()); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { tntBlocks.remove(e.getBlock().getLocation()); }}, 20L); } // Remove the arrow projectile.remove(); e.setCancelled(true); } } } } }
Example 5
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onVillagerSpawn(final CreatureSpawnEvent e) { // If not an villager if (!(e.getEntity() instanceof Villager)) { return; } if (DEBUG3) { plugin.getLogger().info("Villager spawn event! " + e.getEventName()); plugin.getLogger().info("Reason:" + e.getSpawnReason().toString()); plugin.getLogger().info("Entity:" + e.getEntityType().toString()); } // Only cover overworld if (!e.getEntity().getWorld().equals(ASkyBlock.getIslandWorld())) { return; } // If there's no limit - leave it if (Settings.villagerLimit <= 0) { return; } // We only care about villagers breeding, being cured or coming from a spawn egg, etc. if (e.getSpawnReason() != SpawnReason.SPAWNER && e.getSpawnReason() != SpawnReason.BREEDING && e.getSpawnReason() != SpawnReason.DISPENSE_EGG && e.getSpawnReason() != SpawnReason.SPAWNER_EGG && e.getSpawnReason() != SpawnReason.CURED) { return; } Island island = plugin.getGrid().getProtectedIslandAt(e.getLocation()); if (island == null || island.getOwner() == null || island.isSpawn()) { // No island, no limit return; } int limit = Settings.villagerLimit * Math.max(1,plugin.getPlayers().getMembers(island.getOwner()).size()); //plugin.getLogger().info("DEBUG: villager limit = " + limit); //long time = System.nanoTime(); int pop = island.getPopulation(); //plugin.getLogger().info("DEBUG: time = " + ((System.nanoTime() - time)*0.000000001)); if (pop >= limit) { plugin.getLogger().warning( "Island at " + island.getCenter().getBlockX() + "," + island.getCenter().getBlockZ() + " hit the island villager limit of " + limit); //plugin.getLogger().info("Stopped villager spawning on island " + island.getCenter()); // Get all players in the area List<Entity> players = e.getEntity().getNearbyEntities(10,10,10); for (Entity player: players) { if (player instanceof Player) { Player p = (Player) player; Util.sendMessage(p, ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit))); } } plugin.getMessages().tellTeam(island.getOwner(), ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit))); if (e.getSpawnReason().equals(SpawnReason.CURED)) { // Easter Egg. Or should I say Easter Apple? ItemStack goldenApple = new ItemStack(Material.GOLDEN_APPLE); // Nerfed //goldenApple.setDurability((short)1); e.getLocation().getWorld().dropItemNaturally(e.getLocation(), goldenApple); } e.setCancelled(true); } }
Example 6
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Handles minecart placing * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onMinecart(VehicleCreateEvent e) { if (DEBUG) { plugin.getLogger().info("DEBUG: " + e.getEventName()); plugin.getLogger().info("DEBUG: Vehicle type = " + e.getVehicle().getType()); } if (!IslandGuard.inWorld(e.getVehicle())) { if (DEBUG) plugin.getLogger().info("DEBUG: Not in world"); return; } if (DEBUG) plugin.getLogger().info("DEBUG: Checking entity types"); if (Settings.entityLimits.containsKey(e.getVehicle().getType())) { // If someone in that area has the bypass permission, allow the spawning for (Entity entity : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) { if (entity instanceof Player) { Player player = (Player)entity; Boolean bypass = false; if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypass")) { if (DEBUG) plugin.getLogger().info("DEBUG: op or bypass"); bypass = true; } // Check island Island island = plugin.getGrid().getProtectedIslandAt(e.getVehicle().getLocation()); if (island == null) { // Only count island entities if (DEBUG) plugin.getLogger().info("DEBUG: island is null"); return; } // Ignore spawn if (island.isSpawn()) { if (DEBUG) plugin.getLogger().info("DEBUG: ignore spawn"); return; } if (DEBUG) plugin.getLogger().info("DEBUG: Checking entity limits"); // Check if the player is at the limit if (atLimit(island, bypass, e.getVehicle())) { e.setCancelled(true); for (Entity ent : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) { if (ent instanceof Player) { Util.sendMessage((Player)ent, ChatColor.RED + (plugin.myLocale(player.getUniqueId()).entityLimitReached.replace("[entity]", Util.prettifyText(e.getVehicle().getType().toString())) .replace("[number]", String.valueOf(Settings.entityLimits.get(e.getVehicle().getType()))))); } } } } } } }