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


Java World.getEnvironment方法代码示例

本文整理汇总了Java中org.bukkit.World.getEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Java World.getEnvironment方法的具体用法?Java World.getEnvironment怎么用?Java World.getEnvironment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.World的用法示例。


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

示例1: onPlayerPortal

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerPortal(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    if (event.getTo() != null) {
        World toWorld = event.getTo().getWorld();
        if (toWorld != null && toWorld.getEnvironment() == World.Environment.THE_END) {
            event.useTravelAgent(false);
            event.setTo(toWorld.getSpawnLocation());
            return;
        }
    }

    World fromWorld = event.getFrom().getWorld();
    if (fromWorld != null && fromWorld.getEnvironment() == World.Environment.THE_END) {
        event.useTravelAgent(false);
        event.setTo(endExit);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:22,代码来源:PortalListener.java

示例2: onClickEndPortalFrame

import org.bukkit.World; //导入方法依赖的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

示例3: onPlayerSwitchWorlds

import org.bukkit.World; //导入方法依赖的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: onCombust

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Triggers when something combusts in the world.
 * 
 * @param event
 *            The event being fired.
 * @author HomieDion
 * @since 1.1.0
 */
@EventHandler(ignoreCancelled = true)
public void onCombust(final EntityCombustEvent event) {
	// Ignore if this is caused by an event lower down the chain.
	if (event instanceof EntityCombustByEntityEvent || event instanceof EntityCombustByBlockEvent) {
		return;
	}

	// Variables
	final EntityType type = event.getEntityType();
	final World world = event.getEntity().getWorld();

	// Ignore world's without sunlight
	if (world.getEnvironment() != Environment.NORMAL) {
		return;
	}

	// Ignore disabled worlds
	if (settings.isDisabledWorld(world)) {
		return;
	}

	// Ignore someone without sunscreen
	if (!settings.hasSunscreen(type)) {
		return;
	}

	// Prevent the target from burning.
	event.setCancelled(true);
}
 
开发者ID:homiedion,项目名称:Sunscreen,代码行数:38,代码来源:CombustionListener.java

示例5: onWorldChanged

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onWorldChanged(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    World from = event.getFrom();
    World to = player.getWorld();
    if (from.getEnvironment() != World.Environment.THE_END && to.getEnvironment() == World.Environment.THE_END && player.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
        player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:PortalListener.java

示例6: onItemSpawn

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
	Item item = event.getEntity();
	ItemStack stack = item.getItemStack();
	World world = item.getWorld();
	
	if (world.getEnvironment() != Environment.THE_END || stack.getType() != Material.DRAGON_EGG
			|| stack.hasItemMeta()) return;
	
	DragonTemplate dragon = plugin.getDEDManager().getWorldWrapper(world).getActiveBattle();
	DragonLoot loot = dragon.getLoot();
	
	String eggName = loot.getEggName().replace("%dragon%", dragon.getName());
	List<String> eggLore = loot.getEggLore().stream()
			.map(s -> s.replace("%dragon%", dragon.getName()))
			.collect(Collectors.toList());

	ItemMeta eggMeta = stack.getItemMeta();
	
	if (eggName != null && !eggName.isEmpty()) {
		eggMeta.setDisplayName(eggName);
	}
	if (eggLore != null && !eggLore.isEmpty()) {
		eggMeta.setLore(eggLore);
	}
	
	stack.setItemMeta(eggMeta);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:29,代码来源:LootListeners.java

示例7: NorthRoadFaction

import org.bukkit.World; //导入方法依赖的package包/类
public NorthRoadFaction() {
    super("NorthRoad");
    for (World world : Bukkit.getWorlds()) {
        World.Environment environment = world.getEnvironment();
        if (environment != World.Environment.THE_END) {
            int roadLength = SettingsYML.ROAD_LENGTHS.get(environment);
            int offset = SettingsYML.SPAWN_RADIUS_MAP.get(environment) + 1;
            addClaim(new Claim(this, new Location(world, -ROAD_WIDTH_LEFT, ROAD_MIN_HEIGHT, -offset), new Location(world, ROAD_WIDTH_RIGHT, ROAD_MAX_HEIGHT, -roadLength + ROAD_EDGE_DIFF)),
                    null);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:13,代码来源:RoadFaction.java

示例8: EastRoadFaction

import org.bukkit.World; //导入方法依赖的package包/类
public EastRoadFaction() {
    super("EastRoad");
    for (World world : Bukkit.getWorlds()) {
        World.Environment environment = world.getEnvironment();
        if (environment != World.Environment.THE_END) {
            int roadLength = SettingsYML.ROAD_LENGTHS.get(environment);
            int offset = SettingsYML.SPAWN_RADIUS_MAP.get(environment) + 1;
            addClaim(new Claim(this, new Location(world, offset, ROAD_MIN_HEIGHT, -ROAD_WIDTH_LEFT), new Location(world, roadLength - ROAD_EDGE_DIFF, ROAD_MAX_HEIGHT, ROAD_WIDTH_RIGHT)), null);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:RoadFaction.java

示例9: SouthRoadFaction

import org.bukkit.World; //导入方法依赖的package包/类
public SouthRoadFaction() {
    super("SouthRoad");
    for (World world : Bukkit.getWorlds()) {
        World.Environment environment = world.getEnvironment();
        if (environment != World.Environment.THE_END) {
            int roadLength = SettingsYML.ROAD_LENGTHS.get(environment);
            int offset = SettingsYML.SPAWN_RADIUS_MAP.get(environment) + 1;
            addClaim(new Claim(this, new Location(world, ROAD_WIDTH_LEFT, ROAD_MIN_HEIGHT, offset), new Location(world, -ROAD_WIDTH_RIGHT, ROAD_MAX_HEIGHT, roadLength - ROAD_EDGE_DIFF)), null);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:RoadFaction.java

示例10: WestRoadFaction

import org.bukkit.World; //导入方法依赖的package包/类
public WestRoadFaction() {
    super("WestRoad");
    for (World world : Bukkit.getWorlds()) {
        World.Environment environment = world.getEnvironment();
        if (environment != World.Environment.THE_END) {
            int roadLength = SettingsYML.ROAD_LENGTHS.get(environment);
            int offset = SettingsYML.SPAWN_RADIUS_MAP.get(environment) + 1;
            addClaim(new Claim(this, new Location(world, -offset, ROAD_MIN_HEIGHT, ROAD_WIDTH_LEFT), new Location(world, -roadLength + ROAD_EDGE_DIFF, ROAD_MAX_HEIGHT, -ROAD_WIDTH_RIGHT)),
                    null);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:13,代码来源:RoadFaction.java

示例11: onPlayerJoin

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
	// Version notification
	Player player = event.getPlayer();
	if (player.isOp() && plugin.isNewVersionAvailable()) {
		this.plugin.sendMessage(player, ChatColor.GRAY + "A new version is available for download (Version " + this.plugin.getNewVersion() + "). " + RESOURCE_PAGE);
	}
	
	World world = player.getWorld();
	if (world.getEnvironment() != Environment.THE_END) return;
	
	EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);
	
	// 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);
		});
	}
	
	// Dragon respawn logic
	if (!plugin.getConfig().getBoolean("respawn-on-join", false)) return;
	if (!world.getPlayers().isEmpty() || manager.getWorldWrapper(world).isRespawnInProgress()
			|| world.getEntitiesByClass(EnderDragon.class).size() == 0) 
		return;
	
	manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:30,代码来源:RespawnListeners.java

示例12: EndWorldWrapper

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Construct a new EndWorldWrapper around an existing world
 * 
 * @param plugin the plugin instance
 * @param world the world to wrap
 */
protected EndWorldWrapper(DragonEggDrop plugin, World world) {
	this.plugin = plugin;
	this.world = world.getUID();
	
	if (world.getEnvironment() != Environment.THE_END)
		throw new IllegalArgumentException("EndWorldWrapper worlds must be of environment \"THE_END\"");
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:14,代码来源:EndWorldWrapper.java

示例13: onPortalEnter

import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPortalEnter(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    Location to = event.getTo();
    World toWorld = to.getWorld();
    if (toWorld == null)
        return; // safe-guard if the End or Nether is disabled

    if (toWorld.getEnvironment() == World.Environment.THE_END) {
        Player player = event.getPlayer();

        // Prevent entering the end if it's closed.
        if (false /* TODO:plugin.getEndManager().isOpened() */) {
            message(player, ChatColor.RED + "The End is currently closed.");
            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is Spawn Tagged.
        PlayerTimer timer = plugin.getTimerManager().getCombatTimer();
        long remaining;
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is PVP Protected.
        timer = plugin.getTimerManager().getInvincibilityTimer();
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        event.useTravelAgent(false);
        event.setTo(toWorld.getSpawnLocation().add(0.5, 0, 0.5));
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:47,代码来源:PortalListener.java

示例14: canClaimHere

import org.bukkit.World; //导入方法依赖的package包/类
/**
 * Checks if a {@link Player} is eligible to {@link Claim} at a given {@link Location}.
 *
 * @param player
 *            the {@link Player} to check for
 * @param location
 *            the {@link Location} to check at
 * @return true if the {@link Player} can Claim at the {@link Location}
 */
public boolean canClaimHere(Player player, Location location) {
    World world = location.getWorld();

    if (world.getEnvironment() != World.Environment.NORMAL) {
        player.sendMessage(ChatColor.RED + "You can only claim land in the Overworld.");
        return false;
    }

    if (!(plugin.getFactionManager().getFactionAt(location) instanceof WildernessFaction)) {
        player.sendMessage(ChatColor.RED + "You can only claim land in the " + SettingsYML.WILDERNESS_COLOUR + "Wilderness" + ChatColor.RED + ". " + "Make sure you are past "
                + SettingsYML.WARZONE_RADIUS + " blocks from spawn..");

        return false;
    }

    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);

    if (playerFaction == null) {
        player.sendMessage(ChatColor.RED + "You must be in a faction to claim land.");
        return false;
    }

    if (playerFaction.getMember(player.getUniqueId()).getRole() == Role.MEMBER) {
        player.sendMessage(ChatColor.RED + "You must be an officer to claim land.");
        return false;
    }

    if (playerFaction.getClaims().size() >= SettingsYML.MAX_CLAIMS_PER_FACTION) {
        player.sendMessage(ChatColor.RED + "Your faction has maximum claims - " + SettingsYML.MAX_CLAIMS_PER_FACTION);
        return false;
    }

    int locX = location.getBlockX();
    int locZ = location.getBlockZ();

    final FactionManager factionManager = plugin.getFactionManager();
    for (int x = locX - CLAIM_BUFFER_RADIUS; x < locX + CLAIM_BUFFER_RADIUS; x++) {
        for (int z = locZ - CLAIM_BUFFER_RADIUS; z < locZ + CLAIM_BUFFER_RADIUS; z++) {
            Faction factionAtNew = factionManager.getFactionAt(world, x, z);
            if (!SettingsYML.ALLOW_CLAIMING_BESIDES_ROADS && factionAtNew instanceof ClaimableFaction && playerFaction != factionAtNew && !(factionAtNew instanceof RoadFaction)) {
                player.sendMessage(ChatColor.RED + "This position contains enemy claims within a " + CLAIM_BUFFER_RADIUS + " block buffer radius.");
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:58,代码来源:ClaimHandler.java


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