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


Java ChangeBlockEvent.Break方法代码示例

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


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

示例1: onChangeBlockEvent

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onChangeBlockEvent(ChangeBlockEvent.Break e, @First Player player) {
    if (plugin.getMainConfig().isUseSigns()) {
        if (player.hasPermission("minecraftmarket.signs")) {
            if (e.getTransactions().size() > 0) {
                BlockSnapshot blockSnapshot = e.getTransactions().get(0).getOriginal();
                Optional<Location<World>> optionalLocation = blockSnapshot.getLocation();
                if (optionalLocation.isPresent()) {
                    if (plugin.getSignsConfig().getDonorSignFor(optionalLocation.get()) != null) {
                        if (plugin.getSignsConfig().removeDonorSign(optionalLocation.get())) {
                            player.sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_removed")));
                            plugin.getSignsTask().updateSigns();
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:20,代码来源:SignsListener.java

示例2: onPlayerBreaksBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerBreaksBlock(ChangeBlockEvent.Break event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	event
	.getTransactions()
	.stream()
	.forEach(trans -> trans.getOriginal().getLocation().ifPresent(loc -> {
		if (!ConfigHandler.isWhitelisted("break", trans.getFinal().getState().getType().getId())
				&& !DataHandler.getPerm("build", player.getUniqueId(), loc))
		{
			trans.setValid(false);
			try {
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
			} catch (Exception e) {}
		}
	}));
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:26,代码来源:BuildPermListener.java

示例3: onBreakBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBreakBlock(ChangeBlockEvent.Break event) {
    java.util.Optional<Player> player = event.getCause().first(Player.class);
    if (!player.isPresent()) {
        return;
    }

    // check if the damager is a challenger
    Optional<Challenger> challenger = Main.getMinigame().getChallenger(player.get().getUniqueId());
    if (challenger.isPresent()) {
        if (player.get().getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
            if (player.get().getItemInHand(HandTypes.MAIN_HAND).get().getValue(Keys.ITEM_DURABILITY).isPresent()) {
                player.get().getItemInHand(HandTypes.MAIN_HAND).get().getValue(Keys.ITEM_DURABILITY).get().set(0);
            }
        }
    }
}
 
开发者ID:caseif,项目名称:InfernoSpleef,代码行数:18,代码来源:BlockListener.java

示例4: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的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

示例5: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Root Player player) {
    List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
    for (Transaction<BlockSnapshot> transaction : transactions) {

        BlockSnapshot snapshot = transaction.getOriginal();
        BlockState blockState = snapshot.getState();
        String blockTypeId = blockState.getType().getId();
        String blockStateId = blockState.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.block.break." + blockTypeId,
                "protectionperms.block.break." + blockStateId)) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR,
                    Text.of(TextColors.RED, "You don't have permission to break " + blockState.getName() + '!'));
            break;
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:22,代码来源:BreakListener.java

示例6: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event) {
	event.getTransactions().forEach(trans -> {
		if (trans.getOriginal().getState().getType().equals(BlockTypes.CHEST)) {
			Optional<Location<World>> w = trans.getOriginal().getLocation(); 
			if (!w.isPresent()) return;
			Extent tex = w.get().getExtent();
			Vector3i tv3 = w.get().getBlockPosition(); 
			for (NPCguard g : VillagerShops.npcs) {
				if (g.playershopcontainer != null &&
						g.playershopcontainer.getExtent().equals(tex) &&
						g.playershopcontainer.getBlockPosition().equals(tv3)) {
					trans.setValid(false);
				}
			}
		}
	});
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:19,代码来源:EventListeners.java

示例7: onBreakBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBreakBlock(ChangeBlockEvent.Break event, @Root Player player)
{
	if (!player.hasPermission("essentialcmds.blacklist.bypass"))
	{
		for (Transaction<BlockSnapshot> transaction : event.getTransactions())
		{
			if (Utils.getBlacklistItems().contains(transaction.getOriginal().getState().getType().getId()))
			{
				if (Utils.areBlacklistMsgsEnabled())
					player.sendMessage(Text.of(TextColors.RED, "The item ", TextColors.GRAY, transaction.getFinal().getState().getType().getId(), TextColors.RED, " has been confiscated as it is blacklisted."));

				event.setCancelled(true);
			}
		}
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:18,代码来源:BlacklistListener.java

示例8: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event) {
    Optional<Player> playerOptional = event.getCause().first(Player.class);
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        if (transaction.isValid()) {
            if (transaction.getOriginal().get(LiteKeys.JOB_NAME).isPresent()) {
                if (!playerOptional.isPresent()) {
                    event.setCancelled(true);
                    return;
                }
                Player player = playerOptional.get();
                if (!player.hasPermission("jobs.admin.sign.delete")) {
                    player.sendMessage(messageStorage.getMessage("sign.nopermission"));
                    event.setCancelled(true);
                }
            }
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:20,代码来源:SignListeners.java

示例9: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @First(typeFilter = Player.class) Player player) {
	if (event.isCancelled()) {
		return;
	}

	IActiveCharacter character = characterService.getCharacter(player.getUniqueId());
	for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
		BlockType type = transaction.getFinal().getState().getType();
		Double d = experienceService.getMinningExperiences(type);
		if (d != null) {
			characterService.addExperiences(character, d, ExperienceSource.MINING);
		} else {
			d = experienceService.getLoggingExperiences(type);
			if (d != null) {
				characterService.addExperiences(character, d, ExperienceSource.LOGGING);
			}
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:21,代码来源:BasicListener.java

示例10: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Root Player player) {
  Optional<JungleRaidInstance> optInst = manager.getApplicableZone(player);
  if (!optInst.isPresent()) {
    return;
  }

  JungleRaidInstance inst = optInst.get();
  if (inst.isFlagEnabled(JungleRaidFlag.NO_BLOCK_BREAK)) {
    player.sendMessage(Text.of(TextColors.RED, "You cannot break blocks by hand this game."));
    event.setCancelled(true);
  } else if (inst.isFlagEnabled(JungleRaidFlag.NO_MINING)) {
    List<BlockType> unbreakableBlocks = Lists.newArrayList(BlockTypes.STONE, BlockTypes.GRASS, BlockTypes.DIRT);
    for (Transaction<BlockSnapshot> block : event.getTransactions()) {
      if (unbreakableBlocks.contains(block.getOriginal().getState().getType())) {
        player.sendMessage(Text.of(TextColors.RED, "You cannot mine this game."));
        event.setCancelled(true);
        return;
      }
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:JungleRaidEffectListener.java

示例11: listen

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void listen(ChangeBlockEvent.Break event, @First Player player)
{
    // TODO indirect falling sand has no player in Notifier cause
    // TODO player is source when destroying block /w hanging blocks on it but should be notifier? source is the block

    // TODO cause filtering ?
    if (!(event.getCause().root() instanceof Explosive)) // Handle Explosions later
    {
        report(event);
    }
    // TODO remove
    /*
    System.out.print("ChangeBlockEvent.Break caused by\n");
    for (Map.Entry<String, Object> entry : event.getCause().getNamedCauses().entrySet())
    {
        System.out.print("  " + entry.getKey() + ": " + entry.getValue() + "\n");
    }
    //*/
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:21,代码来源:BreakBlockReport.java

示例12: onSignDestroy

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onSignDestroy(ChangeBlockEvent.Break event, @Root Player p) {
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        BlockSnapshot snapshot = transaction.getOriginal();
        if (snapshot.supports(Keys.SIGN_LINES) && snapshot.getLocation().isPresent()) {
            List<Text> texts = snapshot.get(Keys.SIGN_LINES).get();
            //Checking for sign contents
            for (UCSign usign : UltimateCore.get().getSignService().get().getRegisteredSigns()) {
                if (texts.get(0).toPlain().equalsIgnoreCase("[" + usign.getIdentifier() + "]")) {
                    if (!p.hasPermission(usign.getDestroyPermission().get())) {
                        Messages.send(p, "core.nopermissions");
                    }
                    SignDestroyEvent cevent = new SignDestroyEvent(usign, snapshot.getLocation().get(), Cause.builder().owner(UltimateCore.getContainer()).notifier(p).build());
                    Sponge.getEventManager().post(cevent);
                    if (!cevent.isCancelled() && usign.onDestroy(p, event, texts)) {
                        Messages.send(p, "sign.destroy", "%sign%", usign.getIdentifier());
                    }
                }
            }
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:23,代码来源:SignListener.java

示例13: onBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBreak(ChangeBlockEvent.Break event) {
    ModuleConfig config = Modules.BLOCKPROTECTION.get().getConfig().get();
    if (!config.get().getNode("protections", "allow-interact-primary").getBoolean()) return;
    Player p = event.getCause().first(Player.class).orElse(null);

    boolean modified = false;
    for (Protection prot : GlobalData.get(BlockprotectionKeys.PROTECTIONS).get()) {
        //Ignore protection if the player is allowed to modify it
        if (p != null && prot.getPlayers().contains(p.getUniqueId())) continue;
        //For each location of the protection,
        for (Transaction trans : event.getTransactions().stream().filter(trans -> trans.getFinal().getLocation().isPresent() && prot.getLocations().contains(trans.getFinal().getLocation().get())).collect(Collectors.toList())) {
            modified = true;
            trans.setValid(false);
        }

        //If anything has been cancelled & caused by player, send message
        if (p != null && modified) {
            p.sendMessage(prot.getLocktype().getErrorMessage(p, prot));
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:23,代码来源:BlockprotectionListener.java

示例14: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onBlockBreak(ChangeBlockEvent.Break e, @Root Player p) {		
	long time = new Date().getTime();
	for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
		db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.DESTROY, p.getUniqueId().toString(), time));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:8,代码来源:PlayerBlockChangeListener.java

示例15: onBlockBreak

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onBlockBreak(ChangeBlockEvent.Break e, @Root Agent a) {
	if (a instanceof Player) return;
	long time = new Date().getTime();
	for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
		db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, a.getType().getName(), time));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:9,代码来源:MobBlockChangeListener.java


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