当前位置: 首页>>代码示例>>Java>>正文


Java Environment类代码示例

本文整理汇总了Java中org.bukkit.World.Environment的典型用法代码示例。如果您正苦于以下问题:Java Environment类的具体用法?Java Environment怎么用?Java Environment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Environment类属于org.bukkit.World包,在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateChunkData

import org.bukkit.World.Environment; //导入依赖的package包/类
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid biomeGrid) {
    if (world.getEnvironment().equals(World.Environment.NETHER)) {
        return generateNetherChunks(world, random, chunkX, chunkZ, biomeGrid);
    }
    ChunkData result = createChunkData(world);
    if (Settings.seaHeight != 0) {
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                for (int y = 0; y < Settings.seaHeight; y++) {
                    result.setBlock(x, y, z, Material.STATIONARY_WATER);
                }
            }
        }

    }
    return result;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:19,代码来源:ChunkGeneratorWorld.java

示例2: toPocketDimension

import org.bukkit.World.Environment; //导入依赖的package包/类
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));
		}
	}
}
 
开发者ID:ProtocolSupport,项目名称:ProtocolSupportPocketStuff,代码行数:17,代码来源:DimensionPacket.java

示例3: onPlayerSwitchWorlds

import org.bukkit.World.Environment; //导入依赖的package包/类
@EventHandler
public void onPlayerSwitchWorlds(PlayerChangedWorldEvent event) {
	World world = event.getPlayer().getWorld();
	if (world.getEnvironment() != Environment.THE_END) return;
	
	EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);
	
	// Start the respawn countdown if joining an empty world
	if (plugin.getConfig().getBoolean("respawn-on-join", false)) {
		if (world.getPlayers().size() > 1 || worldWrapper.isRespawnInProgress()
				|| world.getEntitiesByClass(EnderDragon.class).size() == 0) 
			return;
		
		manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
	}
	
	// Reset end crystal states just in case something went awry
	if (!worldWrapper.isRespawnInProgress()) {
		world.getEntitiesByClass(EnderCrystal.class).forEach(e -> {
			e.setInvulnerable(false);
			e.setBeamTarget(null);
		});
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:25,代码来源:RespawnListeners.java

示例4: onClickEndPortalFrame

import org.bukkit.World.Environment; //导入依赖的package包/类
@EventHandler
public void onClickEndPortalFrame(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	World world = player.getWorld();
	Block clickedBlock = event.getClickedBlock();
	if (event.getAction() != Action.RIGHT_CLICK_BLOCK || world.getEnvironment() != Environment.THE_END 
			|| clickedBlock.getType() != Material.BEDROCK || event.getHand() != EquipmentSlot.HAND
			|| (player.getInventory().getItemInMainHand() != null || player.getInventory().getItemInOffHand() != null)) return;
	
	NMSAbstract nmsAbstract = plugin.getNMSAbstract();
	DragonBattle dragonBattle = nmsAbstract.getEnderDragonBattleFromWorld(world);
	Location portalLocation = dragonBattle.getEndPortalLocation();
	
	if (event.getClickedBlock().getLocation().distanceSquared(portalLocation) > 36) return; // 5 blocks
	
	EndWorldWrapper endWorld = plugin.getDEDManager().getWorldWrapper(world);
	int secondsRemaining = endWorld.getTimeUntilRespawn();
	if (secondsRemaining <= 0) return;
	
	plugin.sendMessage(player, "Dragon will respawn in " + ChatColor.YELLOW + secondsRemaining);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:22,代码来源:PortalClickListener.java

示例5: sendWorldEnvironment

import org.bukkit.World.Environment; //导入依赖的package包/类
private void sendWorldEnvironment(Player player, Environment environment) {
    CraftPlayer craftPlayer = (CraftPlayer) player;
    CraftWorld world = (CraftWorld) player.getWorld();
    Location location = player.getLocation();

    PacketPlayOutRespawn packet = new PacketPlayOutRespawn(environment.getId(), EnumDifficulty.getById(world.getDifficulty().getValue()), WorldType.NORMAL, WorldSettings.EnumGamemode.getById(player.getGameMode().getValue()));

    craftPlayer.getHandle().playerConnection.sendPacket(packet);

    int viewDistance = plugin.getServer().getViewDistance();

    int xMin = location.getChunk().getX() - viewDistance;
    int xMax = location.getChunk().getX() + viewDistance;
    int zMin = location.getChunk().getZ() - viewDistance;
    int zMax = location.getChunk().getZ() + viewDistance;

    for (int x = xMin; x < xMax; ++x) {
        for (int z = zMin; z < zMax; ++z) {
            world.refreshChunk(x, z);
        }
    }

    //player.updateInventory(); Possibly no longer needed
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:25,代码来源:NetherSkyListener.java

示例6: transferEntityToDimension

import org.bukkit.World.Environment; //导入依赖的package包/类
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);
	}
 
开发者ID:CyberdyneCC,项目名称:Thermos,代码行数:20,代码来源:ThermiteTeleportationHandler.java

示例7: removeDumpedFluids

import org.bukkit.World.Environment; //导入依赖的package包/类
private void removeDumpedFluids()
{
	//remove any surface water or lava above sea level, presumed to be placed by players
	//sometimes, this is naturally generated.  but replacing it is very easy with a bucket, so overall this is a good plan
	if(this.environment == Environment.NETHER) return;
	for(int x = 1; x < snapshots.length - 1; x++)
	{
		for(int z = 1; z < snapshots[0][0].length - 1; z++)
		{
			for(int y = this.seaLevel - 1; y < snapshots[0].length - 1; y++)
			{
				BlockSnapshot block = snapshots[x][y][z];
				if(block.typeId == Material.STATIONARY_WATER.getId() || block.typeId == Material.STATIONARY_LAVA.getId() ||
				   block.typeId == Material.WATER.getId() || block.typeId == Material.LAVA.getId())
				{
					block.typeId = Material.AIR.getId();
				}
			}
		}
	}
}
 
开发者ID:john01dav,项目名称:GriefPreventionPlus,代码行数:22,代码来源:RestoreNatureProcessingTask.java

示例8: getEnvironment

import org.bukkit.World.Environment; //导入依赖的package包/类
/**
 * Determines the environment of the given world based on its folder
 * structure.
 *
 * @param world the name of the world to determine the environment of
 * @return the environment of the given world
 * @since 0.3.0
 */
public static Environment getEnvironment(String world) {
	File worldFolder = new File(Bukkit.getWorldContainer(), world);
	if (worldFolder.exists()) {
		for (File f : worldFolder.listFiles()) {
			if (f.getName().equals("region")) {
				return Environment.NORMAL;
			}
			else if (f.getName().equals("DIM1")) {
				return Environment.THE_END;
			}
			else if (f.getName().equals("DIM-1")) {
				return Environment.NETHER;
			}
		}
	}
	return null;
}
 
开发者ID:myiume,项目名称:MyiuLib,代码行数:26,代码来源:MGUtil.java

示例9: createWorld

import org.bukkit.World.Environment; //导入依赖的package包/类
public void createWorld(String name, long seed, String generator, Environment env, WorldType type, boolean genStructures, boolean providedSeed) {
    name = name.toLowerCase();
    World w = this.createBukkitWorld(name, seed, generator, env, type, genStructures, providedSeed);
    this.database.setValue("worlds." + name + ".seed", seed);
    if(generator != null) {
        this.database.setValue("worlds." + name + ".generator", generator);
    }

    this.database.setValue("worlds." + name + ".environment", env.name());
    this.database.setValue("worlds." + name + ".type", type.name());
    this.database.setValue("worlds." + name + ".generateStructures", genStructures);
    this.database.setValue("worlds." + name + ".pvp", false);
    this.database.setValue("worlds." + name + ".difficulty", Difficulty.EASY.name());
    this.database.setValue("worlds." + name + ".gamemode", GameMode.SURVIVAL.name());
    WorldData world = new WorldData(this.module, this, name);
    world.setWorld(w);
    this.worlds.put(name, world);
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:19,代码来源:WorldManager.java

示例10: createArenaWorld

import org.bukkit.World.Environment; //导入依赖的package包/类
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;
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:19,代码来源:ArenaManager.java

示例11: generateBlockSections

import org.bukkit.World.Environment; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:25,代码来源:ChunkGeneratorWorld.java

示例12: registerProviderType

import org.bukkit.World.Environment; //导入依赖的package包/类
public static boolean registerProviderType(int id, Class<? extends WorldProvider> provider, boolean keepLoaded)
{
    if (providers.containsKey(id))
    {
        return false;
    }
    // Cauldron start - register provider with bukkit and add appropriate config option
    String worldType = "unknown";
    if (id != -1 && id != 0 && id != 1) // ignore vanilla
    {
        worldType = provider.getSimpleName().toLowerCase();
        worldType = worldType.replace("worldprovider", "");
        worldType = worldType.replace("provider", "");
        registerBukkitEnvironment(id, worldType);
    }
    else
    {
        worldType = Environment.getEnvironment(id).name().toLowerCase();
    }
    keepLoaded = MinecraftServer.getServer().cauldronConfig.getBoolean("world-environment-settings." + worldType + ".keep-world-loaded", keepLoaded);
    // Cauldron end
    providers.put(id, provider);
    classToProviders.put(provider, id);
    spawnSettings.put(id, keepLoaded);
    return true;
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:27,代码来源:DimensionManager.java

示例13: CreatureSpawnTask

import org.bukkit.World.Environment; //导入依赖的package包/类
public CreatureSpawnTask(SwornCritters plugin)
{
	this.plugin = plugin;
	this.spawnChance = plugin.getConfig().getInt("spawnChance");
	this.monsterCapPerPlayer = plugin.getConfig().getInt("monsterCapPerPlayer");
	this.animalCapPerPlayer = plugin.getConfig().getInt("animalCapPerPlayer");

	this.passiveEntities = new HashMap<Environment, List<EntityType>>();
	this.hostileEntities = new HashMap<Environment, List<EntityType>>();

	this.passiveEntities.put(World.Environment.NORMAL, getEntityListFromConfig("passiveNormal"));
	this.passiveEntities.put(World.Environment.THE_END, getEntityListFromConfig("passiveEnd"));
	this.passiveEntities.put(World.Environment.NETHER, getEntityListFromConfig("passiveNether"));
	this.hostileEntities.put(World.Environment.NORMAL, getEntityListFromConfig("hostileNormal"));
	this.hostileEntities.put(World.Environment.THE_END, getEntityListFromConfig("hostileEnd"));
	this.hostileEntities.put(World.Environment.NETHER, getEntityListFromConfig("hostileNether"));
}
 
开发者ID:MineSworn,项目名称:SwornCritters,代码行数:18,代码来源:CreatureSpawnTask.java

示例14: onPlayerInteract

import org.bukkit.World.Environment; //导入依赖的package包/类
/**
 * Permits water to be placed in the Nether if in a greenhouse and in an acceptable biome 
 * @param event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onPlayerInteract(PlayerInteractEvent event){        
    Player player = event.getPlayer();
    World world = player.getWorld();
    // Check we are in the right world
    if (!Settings.worldName.contains(world.getName())) {
        return;
    }
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        // Find out which greenhouse the player is in
        if(event.getClickedBlock().getWorld().getEnvironment() == Environment.NETHER 
                && event.getItem() != null && event.getItem().getType() == Material.WATER_BUCKET) {
            Greenhouse g = plugin.players.getInGreenhouse(player);
            if (g != null && !g.getBiome().equals(Biome.HELL) && !g.getBiome().equals(Biome.DESERT)
                    && !g.getBiome().equals(Biome.DESERT_HILLS)) {
                event.setCancelled(true);
                event.getClickedBlock().getRelative(event.getBlockFace()).setType(Material.WATER);
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:greenhouses,代码行数:26,代码来源:GreenhouseEvents.java

示例15: onIceBreak

import org.bukkit.World.Environment; //导入依赖的package包/类
/**
 * Makes water in the Nether if ice is broken and in a greenhouse
 * @param event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onIceBreak(BlockBreakEvent event){        
    Player player = event.getPlayer();
    World world = player.getWorld();
    // Check we are in the right world
    if (!Settings.worldName.contains(world.getName())) {
        return;
    }
    // Find out which greenhouse the player is in
    if(event.getBlock().getWorld().getEnvironment() == Environment.NETHER 
            && event.getBlock().getType() == Material.ICE) {
        Greenhouse g = plugin.players.getInGreenhouse(player);
        if (g != null && !g.getBiome().equals(Biome.HELL) && !g.getBiome().equals(Biome.DESERT)
                && !g.getBiome().equals(Biome.DESERT_HILLS)) {
            event.setCancelled(true);
            event.getBlock().setType(Material.WATER);
        }
    }
}
 
开发者ID:tastybento,项目名称:greenhouses,代码行数:24,代码来源:GreenhouseEvents.java


注:本文中的org.bukkit.World.Environment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。