org.bukkit.World.Environment Java Examples

The following examples show how to use org.bukkit.World.Environment. 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: ThermiteTeleportationHandler.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static void transferEntityToDimension(Entity ent, int dim, ServerConfigurationManager manager, Environment environ) {

		if (ent instanceof EntityPlayerMP) {
			transferPlayerToDimension((EntityPlayerMP) ent, dim, manager, environ);
			return;
		}
		WorldServer worldserver = manager.getServerInstance().worldServerForDimension(ent.dimension);
		ent.dimension = dim;
		WorldServer worldserver1 = manager.getServerInstance().worldServerForDimension(ent.dimension);
		worldserver.removePlayerEntityDangerously(ent);
		if (ent.riddenByEntity != null) {
			ent.riddenByEntity.mountEntity(null);
		}
		if (ent.ridingEntity != null) {
			ent.mountEntity(null);
		}
		ent.isDead = false;
		transferEntityToWorld(ent, worldserver, worldserver1);
	}
 
Example #2
Source File: ChunkGeneratorWorld.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public byte[][] generateBlockSections(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) {
    // Bukkit.getLogger().info("DEBUG: world environment = " +
    // world.getEnvironment().toString());
    if (world.getEnvironment().equals(World.Environment.NETHER)) {
        return generateNetherBlockSections(world, random, chunkX, chunkZ, biomeGrid);
    }
    byte[][] result = new byte[world.getMaxHeight() / 16][];
    if (Settings.seaHeight == 0) {
        return result;
    } else {
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                for (int y = 0; y < Settings.seaHeight; y++) {
                    setBlock(result, x, y, z, (byte) Material.STATIONARY_WATER.getId()); // Stationary
                    // Water
                    // Allows stuff to fall through into oblivion, thus
                    // keeping lag to a minimum
                }
            }
        }
        return result;
    }
}
 
Example #3
Source File: ArenaManager.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
private static World createArenaWorld(ConfigArena arena, String name) {
	World world;
	world = Bukkit.getServer().getWorld(name);
	if (world == null) {
		WorldCreator wc = new WorldCreator(name);
		wc.environment(Environment.NORMAL);
		wc.type(WorldType.FLAT);
		wc.generateStructures(false);
		
		world = Bukkit.getServer().createWorld(wc);
		world.setAutoSave(false);
		world.setSpawnFlags(false, false);
		world.setKeepSpawnInMemory(false);
		ChunkCoord.addWorld(world);
	}
	
	return world;
}
 
Example #4
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Prevents water from being dispensed in hell biomes
 *
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW)
public void onNetherDispenser(final BlockDispenseEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (e.getBlock().getWorld().getEnvironment().equals(Environment.NETHER) || !inWorld(e.getBlock().getLocation()) || !e.getBlock().getBiome().equals(Biome.HELL)) {
        return;
    }
    // plugin.getLogger().info("DEBUG: Item being dispensed is " +
    // e.getItem().getType().toString());
    if (e.getItem().getType().equals(Material.WATER_BUCKET)) {
        e.setCancelled(true);
        if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
        } else {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
        }
    }
}
 
Example #5
Source File: DimensionPacket.java    From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 6 votes vote down vote up
private static int toPocketDimension(Environment dimId) {
	switch (dimId) {
		case NETHER: {
			return 1;
		}
		case THE_END: {
			return 2;
		}
		case NORMAL: {
			return 0;
		}
		default: {
			throw new IllegalArgumentException(String.format("Unknown dim id %s", dimId));
		}
	}
}
 
Example #6
Source File: TestResourceRegistration.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testOilResource() {
    NamespacedKey key = new NamespacedKey(plugin, "oil");
    GEOResource resource = testResource(key, "Oil", SlimefunItems.OIL_BUCKET, false, 8);

    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));

    Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.BEACH));
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.DESERT) > 10);
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS) > 10);
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.ICE_SPIKES) > 10);
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.BADLANDS) > 10);
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.OCEAN) > 10);
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.SWAMP) > 10);
    Assertions.assertEquals(10, resource.getDefaultSupply(Environment.NORMAL, Biome.SUNFLOWER_PLAINS));
}
 
Example #7
Source File: IslandManager.java    From IridiumSkyblock with GNU General Public License v2.0 5 votes vote down vote up
private void makeWorld(Environment env, String name) {
    WorldCreator wc = new WorldCreator(name);
    wc.type(WorldType.FLAT);
    wc.generateStructures(false);
    wc.generator(new SkyblockGenerator());
    wc.environment(env);
    wc.createWorld();
}
 
Example #8
Source File: ImportCommand.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onExecute(String[] args, CommandSender sender) {
    File target = new File(DungeonsXL.MAPS, args[1]);
    File source = new File(Bukkit.getWorldContainer(), args[1]);

    if (!source.exists()) {
        MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[1]));
        return;
    }

    if (target.exists()) {
        MessageUtil.sendMessage(sender, DMessage.ERROR_NAME_IN_USE.getMessage(args[1]));
        return;
    }

    World world = Bukkit.getWorld(args[1]);
    if (world != null) {
        world.save();
    }

    MessageUtil.log(plugin, "&6Creating new map.");
    MessageUtil.log(plugin, "&6Importing world...");

    FileUtil.copyDir(source, target, "playerdata", "stats");

    DResourceWorld resource = new DResourceWorld(plugin, args[1]);
    plugin.getDungeonRegistry().add(args[1], new DDungeon(plugin, resource));
    if (world.getEnvironment() != Environment.NORMAL) {
        WorldConfig config = resource.getConfig(true);
        config.setWorldEnvironment(world.getEnvironment());
        config.save();
    }
    plugin.getMapRegistry().add(resource.getName(), resource);
    MessageUtil.sendMessage(sender, DMessage.CMD_IMPORT_SUCCESS.getMessage(args[1]));
}
 
Example #9
Source File: DebugWorldCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void create_cmd() throws CivException {
	String name = getNamedString(1, "enter a world name");
	
	WorldCreator wc = new WorldCreator(name);
	wc.environment(Environment.NORMAL);
	wc.type(WorldType.FLAT);
	wc.generateStructures(false);
	
	World world = Bukkit.getServer().createWorld(wc);
	world.setSpawnFlags(false, false);
	ChunkCoord.addWorld(world);
	
	CivMessage.sendSuccess(sender, "World "+name+" created.");
	
}
 
Example #10
Source File: ArmorTask.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private boolean hasSunlight(Player p) {
    World world = p.getWorld();

    if (world.getEnvironment() != Environment.NORMAL) {
        // The End and Nether have no sunlight
        return false;
    }

    return (world.getTime() < 12300 || world.getTime() > 23850) && p.getEyeLocation().getBlock().getLightFromSky() == 15;
}
 
Example #11
Source File: UraniumResource.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getDefaultSupply(Environment envionment, Biome biome) {
    if (envionment == Environment.NORMAL) {
        return 5;
    }

    return 0;
}
 
Example #12
Source File: MapLoader.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
public void loadOldWorld(String uuid, Environment env){
	
	if(uuid == null || uuid.equals("null")){
		Bukkit.getLogger().info("[UhcCore] No world to load, defaulting to default behavior");
		this.createNewWorld(env);
	}else{
		File worldDir = new File(uuid);
		if(worldDir.exists()){
			// Loading existing world
			Bukkit.getServer().createWorld(new WorldCreator(uuid));
		}else{
			this.createNewWorld(env);
		}
	}
}
 
Example #13
Source File: MapInfo.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public MapInfo(SemanticVersion proto,
               @Nullable String slug,
               String name,
               SemanticVersion version,
               MapDoc.Edition edition,
               MapDoc.Phase phase,
               @Nullable BaseComponent game,
               MapDoc.Genre genre,
               Set<MapDoc.Gamemode> gamemodes,
               BaseComponent objective,
               List<Contributor> authors,
               List<Contributor> contributors,
               List<String> rules,
               @Nullable Difficulty difficulty,
               Environment dimension,
               boolean friendlyFire) {

    this.id = new MapId(slug != null ? slug : MapId.slugifyName(name), edition, phase);

    this.proto = checkNotNull(proto);
    this.name = checkNotNull(name);
    this.version = checkNotNull(version);
    this.game = game;
    this.genre = checkNotNull(genre);
    this.gamemodes = checkNotNull(gamemodes);
    this.objective = checkNotNull(objective);
    this.authors = checkNotNull(authors);
    this.contributors = checkNotNull(contributors);
    this.rules = checkNotNull(rules);
    this.difficulty = difficulty;
    this.dimension = checkNotNull(dimension);
    this.friendlyFire = friendlyFire;

}
 
Example #14
Source File: NMS_1_13_1.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public Environment getDimension(CommandContext cmdCtx, String key) {
    DimensionManager manager = ArgumentDimension.a(cmdCtx, key);
    switch (manager.getDimensionID()) {
        case 0:
            return Environment.NORMAL;
        case -1:
            return Environment.NETHER;
        case 1:
            return Environment.THE_END;
    }
    return null;
}
 
Example #15
Source File: NMS_1_14_3.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public Environment getDimension(CommandContext cmdCtx, String key) {
    DimensionManager manager = ArgumentDimension.a(cmdCtx, key);
    switch (manager.getDimensionID()) {
        case 0:
            return Environment.NORMAL;
        case -1:
            return Environment.NETHER;
        case 1:
            return Environment.THE_END;
    }
    return null;
}
 
Example #16
Source File: NMS_1_14_4.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public Environment getDimension(CommandContext cmdCtx, String key) {
    DimensionManager manager = ArgumentDimension.a(cmdCtx, key);
    switch (manager.getDimensionID()) {
        case 0:
            return Environment.NORMAL;
        case -1:
            return Environment.NETHER;
        case 1:
            return Environment.THE_END;
    }
    return null;
}
 
Example #17
Source File: SaltResource.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getDefaultSupply(Environment environment, Biome biome) {

    if (environment != Environment.NORMAL) {
        return 0;
    }

    switch (biome) {
    case SNOWY_BEACH:
    case STONE_SHORE:
    case BEACH:
    case DESERT_LAKES:
    case RIVER:
    case ICE_SPIKES:
    case FROZEN_RIVER:
        return 40;

    case DEEP_OCEAN:
    case OCEAN:
    case COLD_OCEAN:
    case DEEP_COLD_OCEAN:
    case DEEP_FROZEN_OCEAN:
    case DEEP_LUKEWARM_OCEAN:
    case DEEP_WARM_OCEAN:
    case FROZEN_OCEAN:
    case LUKEWARM_OCEAN:
    case WARM_OCEAN:
        return 60;

    case SWAMP:
    case SWAMP_HILLS:
        return 20;

    default:
        return 6;
    }
}
 
Example #18
Source File: CarbonWorldGenerator.java    From Carbon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onWorldInit(WorldInitEvent event) {
	//Add new chunkprovidergenerate
	if (plugin.getConfig().getStringList("options.worlds").contains(event.getWorld().getName()) && event.getWorld().getEnvironment() == Environment.NORMAL) {
 	WorldServer nmsWorld = ((CraftWorld) event.getWorld()).getHandle();
 	nmsWorld.chunkProviderServer.chunkProvider = new ChunkProviderGenerate(nmsWorld, nmsWorld.getSeed(), nmsWorld.getWorldData().shouldGenerateMapFeatures());
	}
}
 
Example #19
Source File: Spigot_v1_16_R1.java    From worldedit-adapters with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ResourceKey<WorldDimension> getWorldDimKey(Environment env) {
    switch (env) {
        case NETHER:
            return WorldDimension.THE_NETHER;
        case THE_END:
            return WorldDimension.THE_END;
        case NORMAL:
        default:
            return WorldDimension.OVERWORLD;
    }
}
 
Example #20
Source File: TestResourceRegistration.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testSaltResource() {
    NamespacedKey key = new NamespacedKey(plugin, "salt");
    GEOResource resource = testResource(key, "Salt", SlimefunItems.SALT, true, 18);

    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.THE_END, Biome.THE_END));

    Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS));
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.BEACH) > 10);
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.OCEAN) > 10);
    Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.SWAMP) > 10);
}
 
Example #21
Source File: TestResourceRegistration.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testUraniumResource() {
    NamespacedKey key = new NamespacedKey(plugin, "uranium");
    GEOResource resource = testResource(key, "Small Chunks of Uranium", SlimefunItems.SMALL_URANIUM, true, 2);

    Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS));
    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.THE_END, Biome.THE_END));
}
 
Example #22
Source File: NMS_1_14.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public Environment getDimension(CommandContext cmdCtx, String key) {
	DimensionManager manager = ArgumentDimension.a(cmdCtx, key);
	switch (manager.getDimensionID()) {
	case 0:
		return Environment.NORMAL;
	case -1:
		return Environment.NETHER;
	case 1:
		return Environment.THE_END;
	}
	return null;
}
 
Example #23
Source File: TestResourceRegistration.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testNetherIceResource() {
    NamespacedKey key = new NamespacedKey(plugin, "nether_ice");
    GEOResource resource = testResource(key, "Nether Ice", SlimefunItems.NETHER_ICE, true, 6);

    Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.DESERT));
}
 
Example #24
Source File: NMS_1_15.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public Environment getDimension(CommandContext cmdCtx, String key) {
	DimensionManager manager = ArgumentDimension.a(cmdCtx, key);
	switch (manager.getDimensionID()) {
	case 0:
		return Environment.NORMAL;
	case -1:
		return Environment.NETHER;
	case 1:
		return Environment.THE_END;
	}
	return null;
}
 
Example #25
Source File: NMS_1_13_2.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public Environment getDimension(CommandContext cmdCtx, String key) {
    DimensionManager manager = ArgumentDimension.a(cmdCtx, key);
    switch (manager.getDimensionID()) {
        case 0:
            return Environment.NORMAL;
        case -1:
            return Environment.NETHER;
        case 1:
            return Environment.THE_END;
    }
    return null;
}
 
Example #26
Source File: NetherIceResource.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getDefaultSupply(Environment environment, Biome biome) {
    return environment == Environment.NETHER ? 32 : 0;
}
 
Example #27
Source File: OilResource.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getDefaultSupply(Environment environment, Biome biome) {

    if (environment != Environment.NORMAL) {
        return 0;
    }

    switch (biome) {
    case SNOWY_BEACH:
    case STONE_SHORE:
    case BEACH:
        return 6;

    case DESERT:
    case DESERT_HILLS:
    case DESERT_LAKES:
        return 45;

    case MOUNTAINS:
    case GRAVELLY_MOUNTAINS:
    case MOUNTAIN_EDGE:
    case RIVER:
        return 17;

    case SNOWY_MOUNTAINS:
    case SNOWY_TUNDRA:
    case ICE_SPIKES:
    case FROZEN_OCEAN:
    case FROZEN_RIVER:
        return 14;

    case BADLANDS:
    case BADLANDS_PLATEAU:
    case WOODED_BADLANDS_PLATEAU:
    case ERODED_BADLANDS:
    case MODIFIED_BADLANDS_PLATEAU:
    case MODIFIED_WOODED_BADLANDS_PLATEAU:
    case MUSHROOM_FIELDS:
    case MUSHROOM_FIELD_SHORE:
        return 24;

    case DEEP_OCEAN:
    case OCEAN:
    case COLD_OCEAN:
    case DEEP_COLD_OCEAN:
    case DEEP_FROZEN_OCEAN:
    case DEEP_LUKEWARM_OCEAN:
    case DEEP_WARM_OCEAN:
    case LUKEWARM_OCEAN:
    case WARM_OCEAN:
        return 62;

    case SWAMP:
    case SWAMP_HILLS:
        return 20;

    default:
        return 10;
    }
}
 
Example #28
Source File: Spigot_v1_13_R2_2.java    From worldedit-adapters with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean regenerate(org.bukkit.World bukkitWorld, Region region, EditSession editSession) {
    WorldServer originalWorld = ((CraftWorld) bukkitWorld).getHandle();

    File saveFolder = Files.createTempDir();
    // register this just in case something goes wrong
    // normally it should be deleted at the end of this method
    saveFolder.deleteOnExit();
    saveFolder.deleteOnExit();
    try {
        Environment env = bukkitWorld.getEnvironment();
        ChunkGenerator gen = bukkitWorld.getGenerator();
        MinecraftServer server = originalWorld.getServer().getServer();

        WorldData newWorldData = new WorldData(originalWorld.worldData.a((NBTTagCompound) null),
                server.dataConverterManager, getDataVersion(), null);
        newWorldData.checkName("worldeditregentempworld");
        WorldNBTStorage saveHandler = new WorldNBTStorage(saveFolder,
                originalWorld.getDataManager().getDirectory().getName(), server, server.dataConverterManager);
        try (WorldServer freshWorld = new WorldServer(server, saveHandler, new PersistentCollection(saveHandler),
                newWorldData, originalWorld.worldProvider.getDimensionManager(),
                originalWorld.methodProfiler, env, gen)) {
            freshWorld.savingDisabled = true;

            // Pre-gen all the chunks
            // We need to also pull one more chunk in every direction
            CuboidRegion expandedPreGen = new CuboidRegion(region.getMinimumPoint().subtract(16, 0, 16),
                    region.getMaximumPoint().add(16, 0, 16));
            for (BlockVector2 chunk : expandedPreGen.getChunks()) {
                freshWorld.getChunkAt(chunk.getBlockX(), chunk.getBlockZ());
            }

            CraftWorld craftWorld = freshWorld.getWorld();
            BukkitWorld from = new BukkitWorld(craftWorld);
            for (BlockVector3 vec : region) {
                editSession.setBlock(vec, from.getFullBlock(vec));
            }
        }
    } catch (MaxChangedBlocksException e) {
        throw new RuntimeException(e);
    } finally {
        saveFolder.delete();
        try {
            Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) serverWorldsField.get(Bukkit.getServer());
            map.remove("worldeditregentempworld");
        } catch (IllegalAccessException ignored) {
        }
    }
    return true;
}
 
Example #29
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 4 votes vote down vote up
@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 #30
Source File: DResourceWorld.java    From DungeonsXL with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Environment getWorldEnvironment() {
    return (config != null && config.getWorldEnvironment() != null) ? config.getWorldEnvironment() : Environment.NORMAL;
}