Java Code Examples for org.bukkit.World.Environment#NETHER

The following examples show how to use org.bukkit.World.Environment#NETHER . 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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: EntityEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityExplodeEvent(EntityExplodeEvent event) {
    final World world = event.getEntity().getLocation().getWorld();
    if (!GDFlags.EXPLOSION_BLOCK || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    GDCauseStackManager.getInstance().pushCause(event.getEntity());
    // check entity tracker
    final GDEntity gdEntity = EntityTracker.getCachedEntity(event.getEntity().getEntityId());
    GDPermissionUser user = null;
    if (gdEntity != null) {
        user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID());
    }

    Entity source = event.getEntity();
    if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.EXPLOSION_BLOCK.toString(), source, world.getUID())) {
        return;
    }

    final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
    boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
    if (!denySurfaceExplosion) {
        denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
    }
    GDTimings.EXPLOSION_EVENT.startTiming();
    GDClaim targetClaim = null;
    final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit;
    final List<Block> filteredLocations = new ArrayList<>();
    for (Block block : event.blockList()) {
        final Location location = block.getLocation();
        targetClaim =  GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location);
        if (denySurfaceExplosion && block.getWorld().getEnvironment() != Environment.NETHER && location.getBlockY() >= location.getWorld().getSeaLevel()) {
            filteredLocations.add(block);
            GDPermissionManager.getInstance().processEventLog(event, location, targetClaim, Flags.EXPLOSION_BLOCK.getPermission(), source, block, user, "explosion-surface", Tristate.FALSE);
            continue;
        }
        final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
        if (result == Tristate.FALSE) {
            // Avoid lagging server from large explosions.
            if (event.blockList().size() > cancelBlockLimit) {
                event.setCancelled(true);
                break;
            }
            filteredLocations.add(block);
        }
    }

    if (event.isCancelled()) {
        event.blockList().clear();
    } else if (!filteredLocations.isEmpty()) {
        event.blockList().removeAll(filteredLocations);
    }
    GDTimings.EXPLOSION_EVENT.stopTiming();
}
 
Example 8
Source File: BlockEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onExplosionEvent(BlockExplodeEvent event) {
    final World world = event.getBlock().getLocation().getWorld();
    if (!GDFlags.EXPLOSION_BLOCK || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    Block source = event.getBlock();
    GDCauseStackManager.getInstance().pushCause(source);
    if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.EXPLOSION_BLOCK.toString(), source, world.getUID())) {
        return;
    }

    final GDPermissionUser user = CauseContextHelper.getEventUser(event.getBlock().getLocation(), PlayerTracker.Type.OWNER);
    GDTimings.EXPLOSION_EVENT.startTiming();
    GDClaim targetClaim = null;
    final List<Block> filteredLocations = new ArrayList<>();
    final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
    final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit;
    boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
    if (!denySurfaceExplosion) {
        denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
    }
    for (Block block : event.blockList()) {
        final Location location = block.getLocation();
        targetClaim =  GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location);
        if (denySurfaceExplosion && block.getWorld().getEnvironment() != Environment.NETHER && location.getBlockY() >= location.getWorld().getSeaLevel()) {
            filteredLocations.add(block);
            GDPermissionManager.getInstance().processEventLog(event, location, targetClaim, Flags.EXPLOSION_BLOCK.getPermission(), source, block, user, "explosion-surface", Tristate.FALSE);
            continue;
        }
        Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
        if (result == Tristate.FALSE) {
            // Avoid lagging server from large explosions.
            if (event.blockList().size() > cancelBlockLimit) {
                event.setCancelled(true);
                break;
            }
            filteredLocations.add(block);
        }
    }

    if (event.isCancelled()) {
        event.blockList().clear();
    } else if (!filteredLocations.isEmpty()) {
        event.blockList().removeAll(filteredLocations);
    }
    GDTimings.EXPLOSION_EVENT.stopTiming();
}
 
Example 9
Source File: CommandHelper.java    From GriefDefender with MIT License 4 votes vote down vote up
public static Consumer<CommandSender> createTeleportConsumer(CommandSender src, Location location, Claim claim, boolean isClaimSpawn) {
    return teleport -> {
        if (!(src instanceof Player)) {
            // ignore
            return;
        }

        final Player player = (Player) src;
        // check if world is loaded
        if (Bukkit.getWorld(location.getWorld().getUID()) == null) {
            TextAdapter.sendComponent(player, MessageCache.getInstance().TELEPORT_NO_SAFE_LOCATION);
            return;
        }

        final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId());
        final int teleportDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PLAYER_TELEPORT_DELAY, claim);
        if (isClaimSpawn) {
            if (teleportDelay > 0) {
                playerData.teleportDelay = teleportDelay + 1;
                playerData.teleportSourceLocation = player.getLocation();
                playerData.teleportLocation = location;
                return;
            }
            player.teleport(location, TeleportCause.PLUGIN);
            return;
        }

        final double safeY = location.getWorld().getHighestBlockYAt(location);
        location.setY(safeY);
        int currentY = location.getBlockY();
        while (currentY > 0 && currentY < location.getWorld().getMaxHeight()) {
            if (PlayerUtil.getInstance().isSafeLocation(location)) {
                if (teleportDelay > 0) {
                    playerData.teleportDelay = teleportDelay + 1;
                    playerData.teleportLocation = location;
                    return;
                }
                player.teleport(location, TeleportCause.PLUGIN);
                return;
            }
            if (location.getWorld().getEnvironment() == Environment.NETHER) {
                currentY--;
            } else {
                currentY++;
            }
            location.setY(currentY);
        }

        TextAdapter.sendComponent(player, MessageCache.getInstance().TELEPORT_NO_SAFE_LOCATION);
    };
}
 
Example 10
Source File: TeleportListener.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerPortalEvent (PlayerPortalEvent event){
	GameManager gm = GameManager.getGameManager();
	Player player = event.getPlayer();

	// Disable nether/end in deathmatch
	if (gm.getGameState() == GameState.DEATHMATCH){
		event.setCancelled(true);
		return;
	}
	
	if (event.getCause() == TeleportCause.NETHER_PORTAL) {

		if (!gm.getConfiguration().getEnableNether()){
			player.sendMessage(Lang.PLAYERS_NETHER_OFF);
			event.setCancelled(true);
			return;
		}

		// No Going back!
		if (gm.getScenarioManager().isActivated(Scenario.NOGOINGBACK) && event.getFrom().getWorld().getEnvironment() == Environment.NETHER){
			player.sendMessage(Lang.SCENARIO_NOGOINGBACK_ERROR);
			event.setCancelled(true);
			return;
		}

		// Handle event using versions utils as on 1.14+ PortalTravelAgent got removed.
		VersionUtils.getVersionUtils().handleNetherPortalEvent(event);

	}else if (event.getCause() == TeleportCause.END_PORTAL){

		if (gm.getConfiguration().getEnableTheEnd() && event.getFrom().getWorld().getEnvironment() == Environment.NORMAL){
			// Teleport to end
			Location end = new Location(Bukkit.getWorld(gm.getConfiguration().getTheEndUuid()), -42, 48, -18);

			createEndSpawnAir(end);
			createEndSpawnObsidian(end);

			event.setTo(end);
		}
	}
}
 
Example 11
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 12
Source File: GPSNetwork.java    From Slimefun4 with GNU General Public License v3.0 3 votes vote down vote up
/**
 * This returns an icon for the given waypoint.
 * The icon is dependent on the {@link Environment} of the waypoint's {@link World}.
 * However if the name of this waypoint indicates that this is actually a deathmarker
 * then a different texture will be used.
 * 
 * Otherwise it will return a globe, a nether or end sphere according to the {@link Environment}.
 * 
 * @param name
 *            The name of a waypoint
 * @param environment
 *            The {@link Environment} of the waypoint's {@link World}
 * 
 * @return An icon for this waypoint
 */
public ItemStack getIcon(String name, Environment environment) {
    if (name.startsWith("player:death ")) {
        return HeadTexture.DEATHPOINT.getAsItemStack();
    }
    else if (environment == Environment.NETHER) {
        return HeadTexture.GLOBE_NETHER.getAsItemStack();
    }
    else if (environment == Environment.THE_END) {
        return HeadTexture.GLOBE_THE_END.getAsItemStack();
    }
    else {
        return HeadTexture.GLOBE_OVERWORLD.getAsItemStack();
    }
}