當前位置: 首頁>>代碼示例>>Java>>正文


Java Player.sendMessage方法代碼示例

本文整理匯總了Java中org.spongepowered.api.entity.living.player.Player.sendMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.sendMessage方法的具體用法?Java Player.sendMessage怎麽用?Java Player.sendMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.spongepowered.api.entity.living.player.Player的用法示例。


在下文中一共展示了Player.sendMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBlockPrimaryInteract

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的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

示例2: onBlockSecondaryInteract

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的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

示例3: onPlayerDeath

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Listener
public void onPlayerDeath(DestructEntityEvent.Death event)
{
    if(event.getTargetEntity() instanceof Player)
    {
        Player player = (Player)event.getTargetEntity();

        PowerService.decreasePower(player.getUniqueId());

        player.sendMessage(Text.of(PluginInfo.PluginPrefix, "Your power has been decreased by ", TextColors.GOLD, String.valueOf(MainLogic.getPowerDecrement()) + "\n",
                TextColors.GRAY, "Current power: ", String.valueOf(PowerService.getPlayerPower(player.getUniqueId())) + "/" + String.valueOf(PowerService.getPlayerMaxPower(player.getUniqueId()))));

        PlayerService.setPlayerChunkPosition(player.getUniqueId(), null);

        return;
    }
    else return;
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:19,代碼來源:PlayerDeathListener.java

示例4: printCorrectHelper

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
private void printCorrectHelper(int cost, Player player)
{
    if (cost != 0)
        player.sendMessage(Text.of("§4Usage: §c" + commandAlias + " <Pokémon name/number> {-c to confirm}"));
    else
        player.sendMessage(Text.of("§4Usage: §c" + commandAlias + " <Pokémon name/number>"));
}
 
開發者ID:xPXpanD,項目名稱:PixelUpgrade,代碼行數:8,代碼來源:CheckTypes.java

示例5: openBlockCase

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Listener(order = Order.LATE)
public void openBlockCase(InteractBlockEvent.Secondary.MainHand event) {
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    Optional<Location<World>> optional_location = event.getTargetBlock().getLocation();
    if (!optional_location.isPresent()) return;
    Location<World> location = optional_location.get();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        Case caze = manager.getCase();
        if (!(caze instanceof BlockCase)) continue;
        Location<World> block_case_location = ((BlockCase) caze).getLocation();
        if (!block_case_location.equals(location)) continue;
        event.setCancelled(true);
        OpenManager open_manager = manager.getOpenManager();
        if (!open_manager.canOpen(player, manager)) {
            player.sendMessage(LanguageUtils.getText("CAN_NOT_OPEN_CASE"));
            return;
        }
        Key key = manager.getKey();
        if (key.get(player) < 1) {
            player.sendMessage(LanguageUtils.getText("HAVE_NOT_KEY"));
            return;
        }
        key.add(player, -1);
        manager.getOpenManager().open(player, manager);
        break;
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:30,代碼來源:BlockCaseListener.java

示例6: onInteract

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
/***
 * A method to listen to right click block interaction events
 * @param event the event object
 * @param player the player who fired it
 */
@Listener
public void onInteract(InteractBlockEvent.Secondary.MainHand event, @Root Player player) {
	if (!player.hasPermission(Permissions.PLAYER_SELECT_REGION))
		return;

	Optional<ItemStack> item = player.getItemInHand(HandTypes.MAIN_HAND);
	if (item.isPresent() && item.get().getItem().equals(ItemTypes.BLAZE_ROD) && event.getTargetBlock() != BlockSnapshot.NONE) {
		get(player).setPos2(event.getTargetBlock().getPosition());
		player.sendMessage(Text.of(TextColors.LIGHT_PURPLE, "Position 2 set to " + event.getTargetBlock().getPosition()));
		event.setCancelled(true);
	}
}
 
開發者ID:DevOnTheRocks,項目名稱:StickyChunk,代碼行數:18,代碼來源:RegionAreaListener.java

示例7: execute

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
    if (source instanceof Player)
    {
        Player player = (Player)source;

        if(EagleFactions.AdminList.contains(player.getUniqueId().toString()))
        {
            EagleFactions.AdminList.remove(player.getUniqueId().toString());
            player.sendMessage(Text.of(PluginInfo.PluginPrefix, TextColors.GOLD, "Admin Mode", TextColors.WHITE, " has been turned ", TextColors.GOLD, "off"));
            return CommandResult.success();
        }
        else
        {
            EagleFactions.AdminList.add(player.getUniqueId().toString());
            player.sendMessage(Text.of(PluginInfo.PluginPrefix, TextColors.GOLD, "Admin Mode", TextColors.WHITE, " has been turned ", TextColors.GOLD, "on"));
            return CommandResult.success();
        }
    }
    else
    {
        source.sendMessage (Text.of (PluginInfo.ErrorPrefix, TextColors.RED, "Only in-game players can use this command!"));
    }

    return CommandResult.success();
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:28,代碼來源:AdminCommand.java

示例8: throwArg1Error

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
private void throwArg1Error(int cost, boolean hasOtherPerm, Player player)
{
    checkAndAddHeader(cost, player);
    if (hasOtherPerm)
        player.sendMessage(Text.of("§4Error: §cInvalid target or slot on first argument. See below."));
    else if (cost > 0)
        player.sendMessage(Text.of("§4Error: §cInvalid slot provided on first argument. See below."));
    else
        player.sendMessage(Text.of("§4Error: §cInvalid slot provided. See below."));
    printCorrectPerm(cost, player);
    checkAndAddFooter(cost, player);
}
 
開發者ID:xPXpanD,項目名稱:PixelUpgrade,代碼行數:13,代碼來源:CheckStats.java

示例9: showPlayerInfo

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
private void showPlayerInfo(CommandSource source, Player player)
{
    if(player.hasPlayedBefore())
    {
        List<Text> playerInfo = new ArrayList<Text>();

        String playerFactionName = FactionLogic.getFactionName(player.getUniqueId());
        if(playerFactionName == null) playerFactionName = "";

        Date lastPlayed = Date.from(player.getJoinData().lastPlayed().get());
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
        String formattedDate = formatter.format(lastPlayed);

        //TODO: Show if player is online or offline.

        Text info = Text.builder()
                .append(Text.of(TextColors.AQUA, "Name: ", TextColors.GOLD, PlayerService.getPlayerName(player.getUniqueId()).get() + "\n"))
                .append(Text.of(TextColors.AQUA, "Last Played: ", TextColors.GOLD, formattedDate + "\n"))
                .append(Text.of(TextColors.AQUA, "Faction: ", TextColors.GOLD, playerFactionName + "\n"))
                .append(Text.of(TextColors.AQUA, "Power: ", TextColors.GOLD, PowerService.getPlayerPower(player.getUniqueId()) + "/" + PowerService.getPlayerMaxPower(player.getUniqueId())))
                .build();

        playerInfo.add(info);

        PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get();
        PaginationList.Builder paginationBuilder = paginationService.builder().title(Text.of(TextColors.GREEN, "Player Info")).padding(Text.of("=")).contents(playerInfo);
        paginationBuilder.sendTo(source);
    }
    else
    {
        player.sendMessage (Text.of (PluginInfo.ErrorPrefix, TextColors.RED, "This player has not played on this server!"));
    }
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:34,代碼來源:PlayerCommand.java

示例10: execute

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (!(src instanceof Player)) {
        throw new CommandException(Text.of("You must be a player to use this command!"));
    }

    Player player = (Player) src;

    AccountConfigData data = (AccountConfigData) this.plugin.getAllConfigs().get(AccountConfigData.class);

    if (player.getSubjectData().getOptions(SubjectData.GLOBAL_CONTEXT).containsKey("discord-user")) {
        String id = player.getSubjectData().getOptions(SubjectData.GLOBAL_CONTEXT).get("discord-user");
        if (data.getAccounts().containsKey(id)) {
            throw new CommandException(Text.of("Your accounts are already linked!"));
        }
    }

    String code = generateCode(5);
    while (this.bot.getCodes().containsKey(code)) {
        code = generateCode(5);
    }
    this.bot.getCodes().put(code, player.getUniqueId());
    player.sendMessage(Text.of(
            TextColors.GREEN, "Your code is: ", TextColors.GOLD, code, TextColors.GREEN, ".", Text.NEW_LINE,
            TextColors.AQUA, "Use the command !confirmaccount <code> in a private message to the Phonon bot in Discord "
                    + "using your code in order to confirm the link."));

    return CommandResult.success();
}
 
開發者ID:NucleusPowered,項目名稱:Phonon,代碼行數:30,代碼來源:AccountLinkCommand.java

示例11: execute

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    if(commandContext.getOne("type").isPresent()) {
        String type = commandContext.<String>getOne("type").get();
        VirtualCrate virtualCrate = HuskyCrates.instance.getCrateUtilities().getVirtualCrate(type);
        int quantity = commandContext.getOne("quantity").isPresent() ? commandContext.<Integer>getOne("quantity").get() : 1;
        if (virtualCrate == null) {
            commandSource.sendMessage(Text.of("Invalid crate id: " + type + ". Please check your config."));
            return CommandResult.empty();
        }


        for(Player player : Sponge.getServer().getOnlinePlayers()) {
            ItemStack keyItemStack = virtualCrate.getCrateKey(quantity);
            InventoryTransactionResult.Type mainInventory = player.getInventory().offer(keyItemStack.copy()).getType();
            if (!mainInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                InventoryTransactionResult.Type enderInventory = player.getEnderChestInventory().offer(keyItemStack.copy()).getType();
                if (!enderInventory.equals(InventoryTransactionResult.Type.SUCCESS)) {
                    commandSource.sendMessage(Text.of("Couldn't give key to " + player.getName() + " because of a full inventory and enderchest"));
                    HuskyCrates.instance.logger.info("Couldn't give key to " + player.getName() + " because of a full inventory and enderchest");
                } else {
                    player.sendMessage(Text.of("You have been given 1 or more ", TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName), " key(s), but some have been placed in your Ender Chest."));
                }
            }
        }
    }else{
        commandSource.sendMessage(Text.of("Usage: /crate keyall <id> [count]"));
    }
    return CommandResult.success();
}
 
開發者ID:codeHusky,項目名稱:HuskyCrates-Sponge,代碼行數:30,代碼來源:KeyAll.java

示例12: execute

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
    Optional<Player> optionalSelectedPlayer = context.<Player>getOne("player");
    Optional<String> optionalPower = context.<String>getOne("power");

    if (optionalSelectedPlayer.isPresent() && optionalPower.isPresent())
    {
        if (source instanceof Player)
        {
            Player player = (Player) source;

            if (EagleFactions.AdminList.contains(player.getUniqueId().toString()))
            {
                BigDecimal newPower = new BigDecimal(optionalPower.get());

                PowerService.setPower(optionalSelectedPlayer.get().getUniqueId(), newPower);

                player.sendMessage(Text.of(PluginInfo.PluginPrefix, TextColors.GREEN, "Player's power has been changed!"));
                return CommandResult.success();
            }
            else
            {
                player.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "You need to toggle faction admin mode to do this!"));
            }
        }
        else
        {
            source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Only in-game players can use this command!"));
        }
    }
    else
    {
        source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Wrong command arguments!"));
        source.sendMessage(Text.of(TextColors.RED, "Usage: /f setpower <player> <power>"));
    }

    return CommandResult.success();
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:40,代碼來源:SetPowerCommand.java

示例13: checkAndAddFooter

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
private void checkAndAddFooter(int cost, Player player)
{
    player.sendMessage(Text.of(""));
    player.sendMessage(Text.of("§6Warning: §eAdd the -c flag only if you're sure!"));
    if (cost > 0)
        player.sendMessage(Text.of("§eConfirming will cost you §6" + cost + "§e coins."));
    player.sendMessage(Text.of("§5-----------------------------------------------------"));
}
 
開發者ID:xPXpanD,項目名稱:PixelUpgrade,代碼行數:9,代碼來源:FixLevel.java

示例14: checkAndAddFooter

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
private void checkAndAddFooter(int cost, Player player)
{
    player.sendMessage(Text.of("§4Usage: §c" + commandAlias + " <slot, 1-6> {-c to confirm}"));
    player.sendMessage(Text.of(""));
    player.sendMessage(Text.of("§6Warning: §eAdd the -c flag only if you're sure!"));
    if (cost > 0)
        player.sendMessage(Text.of("§eConfirming will cost you §6" + cost + "§e coins."));
    player.sendMessage(Text.of("§5-----------------------------------------------------"));
}
 
開發者ID:xPXpanD,項目名稱:PixelUpgrade,代碼行數:10,代碼來源:SwitchGender.java

示例15: execute

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Override
public CommandResult execute(CommandSource source, CommandContext context) throws CommandException
{
    Optional<Player> optionalSelectedPlayer = context.<Player>getOne(Text.of("player"));
    Optional<String> optionalPower = context.<String>getOne(Text.of("power"));

    if (optionalSelectedPlayer.isPresent() && optionalPower.isPresent())
    {
        if (source instanceof Player)
        {
            Player player = (Player) source;

            if (EagleFactions.AdminList.contains(player.getUniqueId().toString()))
            {
                BigDecimal newPower = new BigDecimal(optionalPower.get());

                PowerService.setMaxPower(optionalSelectedPlayer.get().getUniqueId(), newPower);

                player.sendMessage(Text.of(PluginInfo.PluginPrefix, TextColors.GREEN, "Player's maxpower has been changed!"));
                return CommandResult.success();
            }
            else
            {
                player.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "You need to toggle faction admin mode to do this!"));
            }
        }
        else
        {
            source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Only in-game players can use this command!"));
        }
    }
    else
    {
        source.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "Wrong command arguments!"));
        source.sendMessage(Text.of(TextColors.RED, "Usage: /f maxpower <player> <power>"));
    }

    return CommandResult.success();
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:40,代碼來源:MaxPowerCommand.java


注:本文中的org.spongepowered.api.entity.living.player.Player.sendMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。