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


Java BlockTypes类代码示例

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


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

示例1: performRemoval

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
private void performRemoval(LookupLine line) {
	World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
	if (w == null) return;
	
	if (line.getTarget() instanceof ItemType) {
		
		Optional<TileEntity> te = w.getTileEntity(line.getPos());
		if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
			TileEntityCarrier c = (TileEntityCarrier) te.get();
			Inventory i = c.getInventory();
			
			Inventory slot = i.query(new SlotIndex(line.getSlot()));
			slot.set(ItemStack.of(ItemTypes.NONE, 0));
		}
		
	} else if (line.getTarget() instanceof BlockType) {
		
		BlockState block = BlockState.builder().blockType(BlockTypes.AIR).build();
		w.setBlock(line.getPos(), block, Cause.source(container).build());
		
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:23,代码来源:RollbackManager.java

示例2: onLiquidFlow

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
@Listener(order = Order.POST)
public void onLiquidFlow(ChangeBlockEvent.Pre e) {
	if (e.getLocations().isEmpty()) return;
			
	Location<World> loc = e.getLocations().get(0);
	BlockSnapshot snapshot = loc.getExtent().createSnapshot(loc.getBlockPosition());
	
	Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
	if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
		String name = "Water";
		BlockType type = snapshot.getState().getType();
		if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA)
			name = "Lava";
		db.addToQueue(new BlockQueueEntry(snapshot, ActionType.FLOW, name, new Date().getTime()));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:LiquidFlowListener.java

示例3: getAddTrailCommand

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
private static CommandSpec getAddTrailCommand() {
    return CommandSpec.builder()
        .permission("happytrails.command.add")
        .description(Text.of("Adds a new trail"))
        .executor((src, args) -> {
            if (!(src instanceof Player)) {
                return CommandResult.empty();
            }
            final Inventory creator = Inventory.builder()
                .of(InventoryArchetypes.CHEST)
                .property(InventoryTitle.PROPERTY_NAME, new InventoryTitle(Text.of(TextColors.AQUA, "Create a Trail")))
                .listener(ClickInventoryEvent.Primary.class, (event) -> {

                })
                .build(HappyTrails.getInstance());
            creator.offer(ItemStack.of(ItemTypes.FIREWORKS, 1));
            creator.offer(ItemStack.builder().fromBlockState(BlockTypes.REDSTONE_BLOCK.getDefaultState()).build());
            ((Player) src).openInventory(creator);
            return CommandResult.success();
        })
        .build();

}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:24,代码来源:TrailCommands.java

示例4: onEitherClick

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
@Listener
public void onEitherClick(final InteractBlockEvent event, @First Player player) {
    if (player.hasPermission("safeguard.mod")) {
        return;
    }

    // Ignore clicks in the air
    if (event.getTargetBlock().equals(BlockSnapshot.NONE) || !event.getTargetBlock().getLocation().isPresent()) {
        return;
    }

    if (!event.getTargetBlock().getState().getType().equals(BlockTypes.DRAGON_EGG)) {
        return;
    }

    if (!SafeGuard.getZoneManager().allows(player, changeFlag, event.getTargetBlock().getLocation().get())) {
        player.sendMessage(Format.error("Sorry, this zone doesn't allow you to do that."));
        event.setCancelled(true);
    }
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:21,代码来源:InteractBlockListener.java

示例5: isSignAndShop

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
private boolean isSignAndShop(Location<World> loc, Direction dir, boolean wall) {
	if (loc.getRelative(dir).getBlockType() == (wall ? BlockTypes.WALL_SIGN : BlockTypes.STANDING_SIGN)) {
		if (wall) {
			Location<World> sign = loc.getRelative(dir);
			if (sign.supports(Keys.DIRECTION)) {
				Optional<Direction> direction = sign.get(Keys.DIRECTION);
				if (direction.isPresent()) {
					if (direction.get() != dir)
						return false;
				}
			}
		}
		Optional<List<Shop>> shops = ShopsData.getShops(loc.getRelative(dir));
		if (shops.isPresent())
			return true;
	}
	return false;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:19,代码来源:BlockBreakListener.java

示例6: DeviceOff

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
public DeviceOff(Player player, Location<World> sign) throws ExceptionInInitializerError {
	super(sign);
	if (!player.hasPermission("carrotshop.create.device"))
		throw new ExceptionInInitializerError("You don't have perms to build a device sign");
	Stack<Location<World>> locations = ShopsData.getItemLocations(player);
	if (locations.isEmpty())
		throw new ExceptionInInitializerError("Device signs require a lever");
	BlockState targetBlock = locations.peek().getBlock();
	if (!targetBlock.getType().equals(BlockTypes.LEVER))
		throw new ExceptionInInitializerError("Device signs require a lever");

	lever = locations.peek();

	if (CarrotShop.getEcoService() != null) {
		price = getPrice(sign);
		if (price < 0)
			throw new ExceptionInInitializerError("bad price");
	}

	ShopsData.clearItemLocations(player);
	player.sendMessage(Text.of(TextColors.DARK_GREEN, "You have setup a device sign:"));
	done(player);
	info(player);
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:25,代码来源:DeviceOff.java

示例7: Toggle

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
public Toggle(Player player, Location<World> sign) throws ExceptionInInitializerError {
	super(sign);
	if (!player.hasPermission("carrotshop.create.device"))
		throw new ExceptionInInitializerError("You don't have perms to build a device sign");
	Stack<Location<World>> locations = ShopsData.getItemLocations(player);
	if (locations.isEmpty())
		throw new ExceptionInInitializerError("Device signs require a lever");
	BlockState targetBlock = locations.peek().getBlock();
	if (!targetBlock.getType().equals(BlockTypes.LEVER))
		throw new ExceptionInInitializerError("Device signs require a lever");

	lever = locations.peek();

	if (CarrotShop.getEcoService() != null) {
		price = getPrice(sign);
		if (price < 0)
			throw new ExceptionInInitializerError("bad price");
	}

	ShopsData.clearItemLocations(player);
	player.sendMessage(Text.of(TextColors.DARK_GREEN, "You have setup a device sign:"));
	done(player);
	info(player);
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:25,代码来源:Toggle.java

示例8: DeviceOn

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
public DeviceOn(Player player, Location<World> sign) throws ExceptionInInitializerError {
	super(sign);
	if (!player.hasPermission("carrotshop.create.device"))
		throw new ExceptionInInitializerError("You don't have perms to build a device sign");
	Stack<Location<World>> locations = ShopsData.getItemLocations(player);
	if (locations.isEmpty())
		throw new ExceptionInInitializerError("Device signs require a lever");
	BlockState targetBlock = locations.peek().getBlock();
	if (!targetBlock.getType().equals(BlockTypes.LEVER))
		throw new ExceptionInInitializerError("Device signs require a lever");

	lever = locations.peek();

	if (CarrotShop.getEcoService() != null) {
		price = getPrice(sign);
		if (price < 0)
			throw new ExceptionInInitializerError("bad price");
	}

	ShopsData.clearItemLocations(player);
	player.sendMessage(Text.of(TextColors.DARK_GREEN, "You have setup a device sign:"));
	done(player);
	info(player);
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:25,代码来源:DeviceOn.java

示例9: onInteract

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractBlockEvent event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.interact"))
	{
		return;
	}
	Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND);
	if (optItem.isPresent() && (ConfigHandler.isWhitelisted("use", optItem.get().getItem().getId()) || optItem.get().getItem().equals(ItemTypes.GOLDEN_AXE) && ConfigHandler.getNode("others", "enableGoldenAxe").getBoolean(true)))
		return;
	event.getTargetBlock().getLocation().ifPresent(loc -> {
		if (!DataHandler.getPerm("interact", player.getUniqueId(), loc))
		{
			event.setCancelled(true);
			if (loc.getBlockType() != BlockTypes.STANDING_SIGN && loc.getBlockType() != BlockTypes.WALL_SIGN)
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
		}
	});
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:24,代码来源:InteractPermListener.java

示例10: onFire

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
@Listener(order=Order.EARLY, beforeModifications = true)
public void onFire(ChangeBlockEvent event)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	event
	.getTransactions()
	.stream()
	.filter(trans -> trans.getFinal().getState().getType() == BlockTypes.FIRE)
	.filter(trans -> {
		Optional<Location<World>> optLoc = trans.getFinal().getLocation();
		if (!optLoc.isPresent())
			return false;
		return !DataHandler.getFlag("fire", optLoc.get());
	})
	.forEach(trans -> trans.setValid(false));
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:20,代码来源:FireListener.java

示例11: onBlockBreak

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
@Listener(order = Order.LAST)
public void onBlockBreak(ChangeBlockEvent.Break event) {
    for (Transaction<BlockSnapshot> blockSnapshotTransaction : event.getTransactions()) {
        final BlockSnapshot original = blockSnapshotTransaction.getOriginal();

        if (original.getState().getType() == BlockTypes.STANDING_SIGN
                || original.getState().getType() == BlockTypes.WALL_SIGN) {
            if (original.getLocation().isPresent()) {
                final Location3D location3D = WorldLocationConverter.of(original.getLocation().get());

                // iterate all arenas of all minigames to see if sign is registered
                //TODO: This is more expensive than it needs to be.
                //      We should maintain a global index of registered signs.
                if (InfernoCore.getMinigames().values().stream()
                        .filter(minigame -> minigame.getArenas().stream()
                                .filter(arena -> arena.getLobbySignAt(location3D).isPresent()).count() > 0)
                        .count() > 0) {
                    event.setCancelled(true);
                }
            }
        }
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:24,代码来源:LobbyListener.java

示例12: checkPhysicalLobbySign

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
@Override
protected int checkPhysicalLobbySign(Location3D loc) {
    if (loc.getWorld().isPresent()) {
        Optional<World> world = Sponge.getGame().getServer().getWorld(loc.getWorld().get());

        if (world.isPresent()) {
            BlockState blockState = world.get().getBlock(LocationConverter.floor(loc));

            if (blockState.getType() == BlockTypes.STANDING_SIGN
                    || blockState.getType() == BlockTypes.WALL_SIGN) {
                return 0;
            } else {
                InfernoCore.logWarning("Found lobby sign with location not containing a sign block. Removing...");
                return 2;
            }
        } else {
            InfernoCore.logVerbose("Cannot load world \"" + loc.getWorld().get()
                    + "\" - not loading contained lobby sign");
            return 1;
        }
    } else {
        InfernoCore.logWarning("Found lobby sign in store with invalid location serial. Removing...");
        return 2;
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:26,代码来源:InfernoMinigame.java

示例13: checkLocationForLobbySign

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
private boolean checkLocationForLobbySign(Location3D location) throws IllegalArgumentException {
    checkArgument(location.getWorld().isPresent(), "Location for lobby sign must contain world");
    java.util.Optional<World> world = Sponge.getServer().getWorld(location.getWorld().get());
    if (!world.isPresent()) {
        throw new IllegalArgumentException("Invalid world for lobby sign location");
    }

    Location<World> loc = WorldLocationConverter.of(location);
    if (!getLobbySignMap().containsKey(location)) {
        java.util.Optional<TileEntity> tile = loc.getExtent().getTileEntity(LocationConverter.floor(location));
        if (!tile.isPresent() || tile.get().getType() != TileEntityTypes.SIGN) {
            //TODO: maybe detect which sign type it should be?
            loc.setBlockType(BlockTypes.WALL_SIGN,
                    Cause.of(NamedCause.of("inferno:lobbyCreation", InfernoPlugin.getInstance())));
        }
        return true;
    }
    return false;
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:20,代码来源:InfernoArena.java

示例14: getColor

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
private TextColor getColor(BlockType type) {
    TextColor color = TextColors.WHITE;

    if (type.equals(BlockTypes.IRON_ORE)) {
        color = TextColors.GRAY;
    }
    else if (type.equals(BlockTypes.LAPIS_ORE)) {
        color = TextColors.BLUE;
    }
    else if (type.equals(BlockTypes.GOLD_ORE)) {
        color = TextColors.YELLOW;
    }
    else if (type.equals(BlockTypes.EMERALD_ORE)) {
        color = TextColors.GREEN;
    }
    else if (type.equals(BlockTypes.DIAMOND_ORE)) {
        color = TextColors.AQUA;
    }

    return color;
}
 
开发者ID:prism,项目名称:OreAlerts,代码行数:22,代码来源:ChangeBlockBreakListener.java

示例15: setPlayerShop

import org.spongepowered.api.block.BlockTypes; //导入依赖的package包/类
/** by setting a owner id this will try to turn into a player shop.<br>
 * If there's no chest below the shop this will throw a IllegalStateException.<br>
 * If the argument is null the playershop accociation is lifted */
public void setPlayerShop(UUID owner) throws IllegalStateException {
	if (owner == null) {
		playershopholder = null;
		playershopcontainer = null;
		return;
	}
	Location<World> scan = getLoc().sub(0, 0.5, 0);
	if (!scan.getBlockType().equals(BlockTypes.CHEST)) 
		scan = scan.sub(0, 1, 0);
	if (!scan.getBlockType().equals(BlockTypes.CHEST))
		throw new IllegalStateException("Shop is not placed above a chest");
	
	playershopholder = owner;
	playershopcontainer = scan;
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:19,代码来源:NPCguard.java


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