當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。