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


Java First类代码示例

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


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

示例1: onChangeSignEvent

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener
public void onChangeSignEvent(ChangeSignEvent e, @First Player player) {
    if (plugin.getMainConfig().isUseSigns()) {
        if (player.hasPermission("minecraftmarket.signs")) {
            Optional<Text> optionalLine1 = e.getText().get(0);
            Optional<Text> optionalLine2 = e.getText().get(1);
            if (optionalLine1.isPresent() && optionalLine2.isPresent()) {
                String line1 = optionalLine1.get().toPlain();
                String line2 = optionalLine2.get().toPlain();
                if (line1.equals("[RecentDonor]") && Utils.isInt(line2)) {
                    int order = Utils.getInt(line2);
                    if (order > 0) {
                        if (plugin.getSignsConfig().addDonorSign(order, e.getTargetTile().getLocation())) {
                            player.sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_added")));
                            plugin.getSignsTask().updateSigns();
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:23,代码来源:SignsListener.java

示例2: onChangeBlockEvent

import org.spongepowered.api.event.filter.cause.First; //导入依赖的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

示例3: onBlockPrimaryInteract

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener
public void onBlockPrimaryInteract(InteractBlockEvent.Primary.MainHand e, @First Player p) {
	if (!plugin.getInspectManager().isInspector(p))
		return;
	
	e.setCancelled(true);
	BlockSnapshot block = e.getTargetBlock();
	if (block == null || !block.getLocation().isPresent())
		return;
	
	Location<World> loc = block.getLocation().get();
	
	p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
	Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
		plugin.getInspectManager().inspect(p, block.getWorldUniqueId(), loc.getBlockPosition()); });
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:PlayerInspectListener.java

示例4: onBlockSecondaryInteract

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener
public void onBlockSecondaryInteract(InteractBlockEvent.Secondary.MainHand e, @First Player p) {		
	if (!plugin.getInspectManager().isInspector(p))
		return;
	
	//TODO: Figure out why shearing sheep causes weird shit to happen
	
	e.setCancelled(true);
	BlockSnapshot block = e.getTargetBlock();
	if (block == null || !block.getLocation().isPresent())
		return;
	
	Location<World> loc = block.getLocation().get();
	
	p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
	if (loc.getTileEntity().isPresent() && loc.getTileEntity().get() instanceof TileEntityCarrier) {
		Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
			plugin.getInspectManager().inspectContainer(p, block.getWorldUniqueId(), loc.getBlockPosition()); });
	} else {
		Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
			plugin.getInspectManager().inspect(p, block.getWorldUniqueId(), loc.getBlockPosition().add(e.getTargetSide().asBlockOffset())); });
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:24,代码来源:PlayerInspectListener.java

示例5: onEitherClick

import org.spongepowered.api.event.filter.cause.First; //导入依赖的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

示例6: onOpenInventory

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener
public void onOpenInventory(final InteractBlockEvent.Secondary event, @First Player player) {
    Optional<TileEntity> entity = event.getTargetBlock().getLocation().get().getTileEntity();
    if (!entity.isPresent()) {
        return;
    }

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

    if (player.hasPermission("safeguard.mod")) {
        return;
    }

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

示例7: onMessageChannelEventChat

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener(order = Order.LAST)
public void onMessageChannelEventChat(MessageChannelEvent.Chat event, @First Player player) {
	String mode = ConfigManager.get().getConfig().getNode("mode").getString();

	Text tag;

	if (mode.equalsIgnoreCase("default")) {
		tag = defaultTag(player);
	} else if (mode.equalsIgnoreCase("advanced")) {
		tag = advancedTag(player);
	} else {
		return;
	}

	MessageFormatter formatter = event.getFormatter();

	Text prefix = Text.join(tag, formatter.getHeader().toText());
	formatter.setHeader(TextTemplate.of(prefix));
}
 
开发者ID:trentech,项目名称:SimpleTagsNations,代码行数:20,代码来源:EventListener.java

示例8: onPlayerRightClick

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener(order=Order.AFTER_PRE, beforeModifications = true)
public void onPlayerRightClick(InteractBlockEvent.Secondary.MainHand event, @First Player player)
{
	Optional<Location<World>> optLoc = event.getTargetBlock().getLocation();
	if (!optLoc.isPresent())
		return;

	Optional<List<Shop>> shops = ShopsData.getShops(optLoc.get());
	if (shops.isPresent()) {
		shops.get().forEach((shop) -> {
			if (shop.getLocation().equals(optLoc.get())) {
				shop.trigger(player);
				Sponge.getScheduler().createTaskBuilder().delayTicks(4).execute(
						task -> {
							shop.update();
							task.cancel();
						}).submit(CarrotShop.getInstance());
			}
		});
	}
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:22,代码来源:PlayerClickListener.java

示例9: onPlayerLeftClickProtect

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerLeftClickProtect(InteractBlockEvent.Primary.MainHand event, @First Player player)
{
	if (!player.gameMode().get().equals(GameModes.CREATIVE))
		return;

	Optional<Location<World>> optLoc = event.getTargetBlock().getLocation();
	if (!optLoc.isPresent())
		return;

	Optional<List<Shop>> shop = ShopsData.getShops(optLoc.get());
	if (shop.isPresent()) {
		Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND);

		if (!optItem.isPresent() || (!optItem.get().getItem().equals(ItemTypes.BEDROCK) && !optItem.get().getItem().equals(ItemTypes.REDSTONE) && !optItem.get().getItem().equals(ItemTypes.STICK))) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:20,代码来源:PlayerClickListener.java

示例10: onPlayerChangeBlock

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerChangeBlock(ChangeBlockEvent.Pre 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;
	}
	for (Location<World> loc : event.getLocations()) {
		if (!ConfigHandler.isWhitelisted("break", loc.getBlock().getId())
				&& !DataHandler.getPerm("build", player.getUniqueId(), loc))
		{
			event.setCancelled(true);
			try {
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
			} catch (Exception e) {}
			return;
		}
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:24,代码来源:BuildPermListener.java

示例11: onPlayerPlacesBlock

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerPlacesBlock(ChangeBlockEvent.Place 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("build", 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

示例12: onPlayerBreaksBlock

import org.spongepowered.api.event.filter.cause.First; //导入依赖的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

示例13: onSignChanged

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onSignChanged(ChangeSignEvent event, @First User player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetTile().getLocation().getExtent().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetTile().getLocation()))
	{
		event.setCancelled(true);
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:17,代码来源:BuildPermListener.java

示例14: onEntitySpawn

import org.spongepowered.api.event.filter.cause.First; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onEntitySpawn(SpawnEntityEvent event, @First Player player, @First EntitySpawnCause entitySpawnCause)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	if (entitySpawnCause.getType() == SpawnTypes.PLACEMENT)
	{
		try {
			if (!DataHandler.getPerm("build", player.getUniqueId(), event.getEntities().get(0).getLocation()))
				event.setCancelled(true);
		} catch (IndexOutOfBoundsException e) {}
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:20,代码来源:BuildPermListener.java

示例15: onInteract

import org.spongepowered.api.event.filter.cause.First; //导入依赖的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


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