org.spongepowered.api.effect.sound.SoundTypes Java Examples

The following examples show how to use org.spongepowered.api.effect.sound.SoundTypes. 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: Action.java    From HuskyUI-Plugin with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Performs this Action.
 *
 * @param currentState the current State before the Action is performed
 */
public void runAction(@Nonnull final String currentState, final Inventory inventory) {
    switch (this.type) {
        case CLOSE:
            InventoryUtil.close(this.observer);
            break;
        case BACK:
            if (this.container.hasState(currentState)) {
                if (this.container.getState(currentState).hasParent()) {
                    this.container.openState(this.observer, this.container.getState(currentState).getParent());
                } else {
                    this.observer.playSound(SoundTypes.BLOCK_ANVIL_LAND, this.observer.getLocation().getPosition(), 0.5);
                    InventoryUtil.close(this.observer);
                    this.observer.sendMessage(Text.of(TextColors.RED, "Impossible BACK action - closing broken State."));
                }
            }
            break;
        case NORMAL:
            this.container.openState(this.observer, this.goalState);
            break;
        case NONE:
            // do nothing
            break;
        case REFRESH:
            Page page = ((Page)getContainer().getState(currentState));
            try {
                Consumer<Page> goo = page.getUpdateConsumer();
                if (goo != null) {
                    goo.accept(page);
                }
            }catch (Exception e){
                this.observer.sendMessage(Text.of(TextColors.RED, "Impossible refresh action - closing broken State."));
            }
            break;
        default:
            this.observer.sendMessage(Text.of("??"));
            break;
    }
}
 
Example #2
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnAddAccessParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.FIREWORKS_SPARK).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(400).offset(new Vector3d(8, 2, 8)).build(), position);
	world.playSound(SoundTypes.ENTITY_EXPERIENCE_ORB_PICKUP, position, 5, 10);
}
 
Example #3
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnRemoveAccessParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.LARGE_SMOKE).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(400).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.ITEM_FIRECHARGE_USE, position, 5, -10);
}
 
Example #4
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnClaimParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.END_ROD).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(400).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.BLOCK_ENDERCHEST_OPEN, position, 5, -20);
}
 
Example #5
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnUnclaimParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.CLOUD).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(800).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.ENTITY_SHULKER_SHOOT, position, 5, -20);
}
 
Example #6
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnDestroyClaimParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.FLAME).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(800).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.ENTITY_BLAZE_SHOOT, position, 5, -20);
}
 
Example #7
Source File: DoorManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public static void ChangeDoor(BlockSnapshot b, Region r) {
    if ((!r.flagExists("smart-door") && !RedProtect.get().config.configRoot().flags.get("smart-door")) || !r.getFlagBool("smart-door")) {
        return;
    }

    Location<World> loc = b.getLocation().get();
    World w = loc.getExtent();

    if (isDoor(b)) {
        boolean iron = b.getState().getType() == BlockTypes.IRON_DOOR;
        if (iron) {
            changeDoorState(b);
            if (getDoorState(b)) {
                w.playSound(SoundTypes.BLOCK_IRON_DOOR_OPEN, loc.getPosition(), 1);
            } else {
                w.playSound(SoundTypes.BLOCK_IRON_DOOR_CLOSE, loc.getPosition(), 1);
            }
        }

        if (loc.getRelative(Direction.DOWN).getBlock().getType() == b.getState().getType() && loc.get(Keys.PORTION_TYPE).get() == PortionTypes.TOP) {
            loc = loc.getRelative(Direction.DOWN);
        }

        //check side block if is door
        BlockSnapshot[] block = new BlockSnapshot[4];
        block[0] = loc.getRelative(Direction.EAST).createSnapshot();
        block[1] = loc.getRelative(Direction.WEST).createSnapshot();
        block[2] = loc.getRelative(Direction.NORTH).createSnapshot();
        block[3] = loc.getRelative(Direction.SOUTH).createSnapshot();

        for (BlockSnapshot b2 : block) {
            if (b.getState().getType() == b2.getState().getType()) {
                changeDoorState(b2);
                break;
            }
        }
    }
}