本文整理汇总了Java中org.spongepowered.api.block.BlockTypes.STANDING_SIGN属性的典型用法代码示例。如果您正苦于以下问题:Java BlockTypes.STANDING_SIGN属性的具体用法?Java BlockTypes.STANDING_SIGN怎么用?Java BlockTypes.STANDING_SIGN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.block.BlockTypes
的用法示例。
在下文中一共展示了BlockTypes.STANDING_SIGN属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSignAndShop
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;
}
示例2: onBlockBreak
@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);
}
}
}
}
}
示例3: checkPhysicalLobbySign
@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;
}
}
示例4: onPlayerLeftClickNormal
@Listener(beforeModifications = true)
public void onPlayerLeftClickNormal(InteractBlockEvent.Primary.MainHand event, @First Player player)
{
Optional<Location<World>> optLoc = event.getTargetBlock().getLocation();
if (!optLoc.isPresent())
return;
Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND);
if (optItem.isPresent() && optItem.get().getItem().equals(ItemTypes.REDSTONE)) {
if (optLoc.get().getBlockType() == BlockTypes.CHEST || optLoc.get().getBlockType() == BlockTypes.TRAPPED_CHEST || optLoc.get().getBlockType() == BlockTypes.LEVER) {
event.setCancelled(true);
ShopsData.storeItemLocation(player, optLoc.get());
} else if (optLoc.get().getBlockType() == BlockTypes.STANDING_SIGN || optLoc.get().getBlockType() == BlockTypes.WALL_SIGN) {
event.setCancelled(true);
Shop.build(player, optLoc.get());
}
} else if (ShopsData.hasMultipleCurrencies() && optItem.isPresent() && optItem.get().getItem().equals(ItemTypes.STICK)
&& (optLoc.get().getBlockType() == BlockTypes.STANDING_SIGN || optLoc.get().getBlockType() == BlockTypes.WALL_SIGN)) {
Optional<List<Shop>> optShop = ShopsData.getShops(optLoc.get());
if (optShop.isPresent()) {
event.setCancelled(true);
for (Shop shop : optShop.get()) {
if (shop.canLoopCurrency(player)) {
shop.loopCurrency();
if (shop.hasCurrency())
player.sendMessage(Text.of(TextColors.DARK_GREEN, "Shop currency set to ", TextColors.YELLOW, shop.getCurrency().getDisplayName()));
else
player.sendMessage(Text.of(TextColors.DARK_GREEN, "Shop currency set to match server's config"));
}
}
}
}
}
示例5: onPlayerInteract
@Listener(order = Order.POST)
public void onPlayerInteract(InteractBlockEvent event) {
BlockState state = event.getTargetBlock().getState();
if (state.getType() == BlockTypes.WALL_SIGN || state.getType() == BlockTypes.STANDING_SIGN) {
Optional<Player> player = event.getCause().first(Player.class);
if (!event.getTargetBlock().getLocation().isPresent() || !player.isPresent()) {
return;
}
Location3D loc = WorldLocationConverter.of(event.getTargetBlock().getLocation().get());
CommonCore.getMinigames().values().forEach(mg -> mg.getArenas().stream()
.filter(arena -> arena.getLobbySignAt(loc).isPresent()).forEach(arena -> {
Optional<Boolean> sneaking = player.get().get(Keys.IS_SNEAKING);
if (event instanceof InteractBlockEvent.Primary
&& sneaking.isPresent() && sneaking.get()
|| !mg.getConfigValue(ConfigNode.REQUIRE_SNEAK_TO_DESTROY_LOBBY)) {
if (player.get().hasPermission(mg.getPlugin() + ".lobby.destroy")
|| player.get().hasPermission(mg.getPlugin() + ".lobby.*")) {
arena.getLobbySignAt(loc).get().unregister();
player.get().sendMessage(Text.builder("Unregistered lobby sign")
.color(TextColors.DARK_AQUA).build());
return;
}
}
mg.getEventBus().post(new CommonPlayerClickLobbySignEvent(
player.get().getUniqueId(),
arena.getLobbySignAt(loc).get(),
event instanceof InteractBlockEvent.Primary
? PlayerClickLobbySignEvent.ClickType.LEFT
: PlayerClickLobbySignEvent.ClickType.RIGHT
));
})
);
}
}
示例6: validate
@Override
protected boolean validate() {
final Location<World> location = WorldLocationConverter.of(this.getLocation());
return location.getBlock().getType() == BlockTypes.WALL_SIGN
|| location.getBlock().getType() == BlockTypes.STANDING_SIGN;
}