Java Code Examples for org.bukkit.entity.Player.sendMessage()

The following are Jave code examples for showing how to use sendMessage() of the org.bukkit.entity.Player class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DogTags   File: PermCommand.java   View Source Code Vote up 6 votes
@Subcommand("perm|permission") @Syntax("<tag>")
public void onCommand(Player p, String ID){
   if(DogTags.getTag(ID) != null){
       DogTag dt = DogTags.getTag(ID);

       if(dt.hasPermission()) p.sendMessage(TagLang.TAG_PERMISSION.get()
           .replace("%id%", dt.getId())
           .replace("%permission%", "dogtags.use."+dt.getId().toLowerCase()));

       else p.sendMessage(TagLang.TAG_NO_PERMISSION.get().replace("%id%", dt.getId()));
       return;
   }else {
       p.sendMessage(TagLang.INVALID_TAG.get());
       return;
   }
}
 
Example 2
Project: AsgardAscension   File: TribeCommand.java   View Source Code Vote up 6 votes
private void helpList(Player player) {
	player.sendMessage(Lang.HEADERS_TRIBES.toString() + "Tribe Commands");
	player.sendMessage(ChatColor.RED + "/tribe create <tribeName>" + ChatColor.GRAY + " - creates a tribe");
	player.sendMessage(ChatColor.RED + "/tribe list" + ChatColor.GRAY + " - shows all tribes");
	player.sendMessage(ChatColor.RED + "/tribe chat" + ChatColor.GRAY + " - sends message to tribe members");
	player.sendMessage(ChatColor.RED + "/tribe leave" + ChatColor.GRAY + " - leaves tribe");
	player.sendMessage(ChatColor.RED + "/tribe chest" + ChatColor.GRAY + " - opens commnunal chest");
	player.sendMessage(ChatColor.RED + "/tribe sword" + ChatColor.GRAY + " - gives tribe sword to use skills");
	player.sendMessage(ChatColor.RED + "/tribe info <*tribeName> " + ChatColor.GRAY + " - shows information of tribe");
	player.sendMessage(ChatColor.RED + "/tribe description" + ChatColor.GRAY + " - displays tribe description");
	player.sendMessage(ChatColor.RED + "/tribe description <description>" + ChatColor.GRAY + " - sets tribe description");
	player.sendMessage(ChatColor.RED + "/tribe type" + ChatColor.GRAY + " - changes tribe type");
	player.sendMessage(ChatColor.RED + "/tribe rankup" + ChatColor.GRAY + " - rankups tribe to next level");
	player.sendMessage(ChatColor.RED + "/tribe invite <playerName>" + ChatColor.GRAY + " - invites player to tribe");
	player.sendMessage(ChatColor.RED + "/tribe kick <playerName>" + ChatColor.GRAY + " - kicks player forom tribe");
	player.sendMessage(ChatColor.RED + "/tribe promote <playerName>" + ChatColor.GRAY + " - sets player as tribe leader");
	player.sendMessage(ChatColor.RED + "/tribe ally <tribeName>" + ChatColor.GRAY + " - offers tribe to become allies");
	player.sendMessage(ChatColor.RED + "/tribe enemy <tribeName>" + ChatColor.GRAY + " - sets tribe as enemy");
	player.sendMessage(ChatColor.RED + "/tribe neutral <tribeName>" + ChatColor.GRAY + " - offers to become neutral");
	player.sendMessage(ChatColor.RED + "/tribe pay <*tribeName> <amount>" + ChatColor.GRAY + " - adds money to tribe's balance");
	player.sendMessage(ChatColor.RED + "/tribe balance <tribeName>" + ChatColor.GRAY + " - displays tribe's balance");
	player.sendMessage(ChatColor.RED + "* before argument means it's optional!");
}
 
Example 3
Project: RealSurvival   File: WorkbenchCMD.java   View Source Code Vote up 6 votes
/**
 * ����һ���䷽
 * @param player ���
 * @param sfName �䷽��
 * @param time ʱ��
 * @return �Ƿ�ɹ�
 */
public static boolean createSF(Player player,String sfName,String time){
	
	if(new File(rs.getDataFolder()+File.separator+"SyntheticFormula"+File.separator+sfName+".yml").exists()){
		 player.sendMessage("��9[RealSurvival] ��b�ϳɹ�ʽ������...");
		 return false;
	 }
	 long l=-1;
	 try{ l=Long.parseLong(time);}catch(Exception e){}
	 if(l<0){
		 player.sendMessage("��9[RealSurvival] ��b����ʱ�����!...");
		 return false;
	 }
	player.openInventory(CraftItemGUI.createWorkbenchRecipeGUI(Items.createItemKey(Material.STAINED_GLASS_PANE, (short)15,sfName+":"+time)));
	return true;
}
 
Example 4
Project: HCFCore   File: BardClass.java   View Source Code Vote up 6 votes
private boolean canUseBardEffect(Player player, BardData bardData, BardEffect bardEffect, boolean sendFeedback) {
    String errorFeedback = null;
    double currentEnergy = bardData.getEnergy();
    if (bardEffect.energyCost > currentEnergy) {
        errorFeedback = ChatColor.RED + "You need at least " + ChatColor.BOLD + bardEffect.energyCost + ChatColor.RED + " energy to use this Bard buff, whilst you only have " + ChatColor.BOLD
                + currentEnergy + ChatColor.RED + '.';
    }

    long remaining = bardData.getRemainingBuffDelay();
    if (remaining > 0L) {
        errorFeedback = ChatColor.RED + "You cannot use this bard buff for another " + ChatColor.BOLD + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + '.';
    }

    Faction factionAt = plugin.getFactionManager().getFactionAt(player.getLocation());
    if (factionAt.isSafezone()) {
        errorFeedback = ChatColor.RED + "You may not use bard buffs in safe-zones.";
    }

    if (sendFeedback && errorFeedback != null) {
        player.sendMessage(errorFeedback);
    }

    return errorFeedback == null;
}
 
Example 5
Project: UltraCore   File: Events.java   View Source Code Vote up 6 votes
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
            event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
                    player.closeInventory();
                    player.teleport(targetPlayer);
                    player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
                    player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                    player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                    targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
                }
            }
        }
    }
}
 
Example 6
Project: UltraCore   File: Events.java   View Source Code Vote up 6 votes
@EventHandler
public void onInventoryClick2(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1")) {
            event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
                    player.closeInventory();
                    targetPlayer.teleport(player);
                    player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
                    player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                    player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                    targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
                }
            }
        }
    }
}
 
Example 7
Project: ProtocolSupportPocketStuff   File: PocketInfoSubCommand.java   View Source Code Vote up 6 votes
@Override
public boolean handle(CommandSender sender, String[] args) {
	if (sender instanceof Player) {
		Player player = (Player) sender;
		if (!PocketPlayer.isPocketPlayer(player)) {
			player.sendMessage(ProtocolSupportPocketStuff.PREFIX + "§cThis command can only be executed by PE players");
			return true;
		}

		player.sendMessage(ProtocolSupportPocketStuff.PREFIX + "§aClient Random ID: §e" + PocketPlayer.getClientRandomId(player));
		player.sendMessage(ProtocolSupportPocketStuff.PREFIX + "§aClient Version: §e" + PocketPlayer.getClientVersion(player));
		player.sendMessage(ProtocolSupportPocketStuff.PREFIX + "§aDevice Model: §e" + PocketPlayer.getDeviceModel(player));
		player.sendMessage(ProtocolSupportPocketStuff.PREFIX + "§aOperating System: §e" + PocketPlayer.getOperatingSystem(player));
	} else {
		sender.sendMessage(ProtocolSupportPocketStuff.PREFIX + "§cThis command can only be executed in game");
	}
	return true;
}
 
Example 8
Project: HCFCore   File: MinerClass.java   View Source Code Vote up 6 votes
/**
 * Applies the {@link MinerClass} invisibility {@link PotionEffect} depending on the {@link Player}s {@link Location}.
 *
 * @param player
 *            the {@link Player} to apply for
 * @param from
 *            the from {@link Location}
 * @param to
 *            the to {@link Location}
 */
private void conformMinerInvisibility(Player player, Location from, Location to) {
    int fromY = from.getBlockY();
    int toY = to.getBlockY();
    if (fromY != toY && plugin.getPvpClassManager().hasClassEquipped(player, this)) {
        boolean isInvisible = player.hasPotionEffect(PotionEffectType.INVISIBILITY);
        if (toY > INVISIBILITY_HEIGHT_LEVEL) {
            if (fromY <= INVISIBILITY_HEIGHT_LEVEL && isInvisible) {
                removeInvisibilitySafely(player);
            }
        } else {
            if (!isInvisible) {
                player.addPotionEffect(HEIGHT_INVISIBILITY, true);
                player.sendMessage(ChatColor.AQUA + getName() + ChatColor.GRAY + " invisibility added.");
            }
        }
    }
}
 
Example 9
Project: HCFCore   File: CombatTimer.java   View Source Code Vote up 5 votes
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onFactionJoin(PlayerJoinFactionEvent event) {
    Optional<Player> optional = event.getPlayer();
    if (optional.isPresent()) {
        Player player = optional.get();
        long remaining = getRemaining(player);
        if (remaining > 0L) {
            event.setCancelled(true);
            player.sendMessage(ChatColor.RED + "You cannot join factions whilst your " + getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(getRemaining(player), true, false) + ChatColor.RED + " remaining]");
        }
    }
}
 
Example 10
Project: AlphaLibary   File: MessageUtil.java   View Source Code Vote up 5 votes
public static void sendCenteredMessage(Player player, String message) {
    if (message == null || message.equals("")) return;

    int messagePxSize = 0;
    boolean previousCode = false;
    boolean isBold = false;

    for (char c : message.toCharArray()) {
        if (c == '&') {
            previousCode = true;
        } else if (previousCode) {
            previousCode = false;
            isBold = c == 'l' || c == 'L';
        } else {
            DefaultFontInfo dFI = DefaultFontInfo.getDefaultFontInfo(c);
            messagePxSize += isBold ? dFI.getBoldLength() : dFI.getLength();
            messagePxSize++;
        }
    }

    int halvedMessageSize = messagePxSize / 2;
    int toCompensate = CENTER_PX - halvedMessageSize;
    int spaceLength = DefaultFontInfo.SPACE.getLength() + 1;
    int compensated = 0;
    StringBuilder sb = new StringBuilder();
    while (compensated < toCompensate) {
        sb.append(" ");
        compensated += spaceLength;
    }
    player.sendMessage(sb.toString().replace("&", "§") + message.replace("&", "§"));
}
 
Example 11
Project: ZentrelaRPG   File: ShadowAcrobat.java   View Source Code Vote up 5 votes
@Override
public boolean cast(final Player p, PlayerDataRPG pd, int level) {
    if (!pd.isStealthed()) {
        p.sendMessage(ChatColor.RED + "Shadow Acrobat can only be used while in stealth.");
        return false;
    }
    int durationSeconds = 0;
    switch (level) {
        case 1:
            durationSeconds = 5;
            break;
        case 2:
            durationSeconds = 7;
            break;
        case 3:
            durationSeconds = 9;
            break;
        case 4:
            durationSeconds = 11;
            break;
        case 5:
            durationSeconds = 13;
            break;
    }
    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, RTicks.seconds(durationSeconds), 4, true, false));
    p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, RTicks.seconds(durationSeconds), 2, true, false));
    Spell.notify(p, "You feel extremely nimble.");
    return true;
}
 
Example 12
Project: Kineticraft   File: Pictionary.java   View Source Code Vote up 5 votes
@EventHandler(priority = EventPriority.LOWEST)
public void onChat(AsyncPlayerChatEvent evt) {
    Player p = evt.getPlayer();
    if (!isPlaying(p))
        return;

    evt.setCancelled(true);
    if (currentWord != null) {
        if (p.equals(currentPainter)) {
            p.sendMessage(ChatColor.RED + "You cannot talk while it is your turn to draw.");
            return;
        }

        if (MetadataManager.hasMetadata(p, "dmtCorrect")) {
            p.sendMessage(ChatColor.RED + "You have already guessed the word this round.");
            return;
        } else if (currentWord.equalsIgnoreCase(evt.getMessage())) {
            broadcastPlayers(ChatColor.GREEN.toString() + ChatColor.BOLD + evt.getPlayer().getName() + " guessed the word! +1 Point!");
            setScore(p, getScore(p) + 1); // Increase score of guesser
            setScore(currentPainter, getScore(currentPainter) + 1); // Increase score of drawer.
            MetadataManager.setMetadata(p, "dmtCorrect", true);
            return;
        }
    }

    getPlayers().forEach(pl -> pl.sendMessage(ChatColor.YELLOW + p.getName() + ": " + ChatColor.GRAY + evt.getMessage()));
}
 
Example 13
Project: HCFCore   File: ModeratorMode.java   View Source Code Vote up 5 votes
public static void leaveMod(Player p)
{
  modMode.remove(p.getName());
  p.setGameMode(GameMode.SURVIVAL);
  p.getInventory().clear();
  loadInventory(p);
  p.sendMessage(" §6§ §rYou have §cdisabled §rModerator Mode!");
}
 
Example 14
Project: SuperiorCraft   File: Minigame.java   View Source Code Vote up 5 votes
public boolean join(Player player) {
	if (canJoin()) {
		getPlayers().add(player);
		player.teleport(getLocation());
		return true;
	} else {
		player.sendMessage("Cannot join minigame");
	}
	return false;
}
 
Example 15
Project: ZentrelaRPG   File: EnvironmentManager.java   View Source Code Vote up 5 votes
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
    final Player p = event.getPlayer();
    for (String s : BUILD_WORLD) {
        if (!event.getFrom().getWorld().getName().equalsIgnoreCase(s) && event.getTo().getWorld().getName().equalsIgnoreCase(s)) {
            if (WorldEditCommand.worldedit_pa.containsKey(p.getUniqueId())) {
                WorldEditCommand.worldedit_pa.remove(p.getUniqueId()).unsetPermission("worldedit.*");
                p.sendMessage("Removed worldedit perms due to worldchange into build world.");
            }
        }
    }
    BackCommand.lastLoc.put(p.getName(), event.getFrom());
}
 
Example 16
Project: ZentrelaRPG   File: ChatFilter.java   View Source Code Vote up 5 votes
public static void sendMessage(Player p, PlayerDataRPG pd, String s) {
    if (pd.getOption(SakiOption.CHAT_FILTER)) {
        p.sendMessage(getFiltered(s));
    } else {
        p.sendMessage(s);
    }
}
 
Example 17
Project: NavyCraft2-Lite   File: NavyCraft_InventoryListener.java   View Source Code Vote up 5 votes
@EventHandler(priority = EventPriority.HIGH)
public void onCraftItem(CraftItemEvent event) 
{
	if( event.getRecipe().getResult().getType() == Material.STONE_SWORD
			|| event.getRecipe().getResult().getType() == Material.IRON_SWORD
			|| event.getRecipe().getResult().getType() == Material.GOLD_SWORD
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_SWORD
|| event.getRecipe().getResult().getType() == Material.LEATHER_BOOTS
			|| event.getRecipe().getResult().getType() == Material.LEATHER_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.LEATHER_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.LEATHER_HELMET
|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_BOOTS
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_HELMET
|| event.getRecipe().getResult().getType() == Material.GOLD_BOOTS
			|| event.getRecipe().getResult().getType() == Material.GOLD_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.GOLD_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.GOLD_HELMET
			|| event.getRecipe().getResult().getType() == Material.IRON_BOOTS
			|| event.getRecipe().getResult().getType() == Material.IRON_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.IRON_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.IRON_HELMET
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_BOOTS
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_HELMET)
	{
		if( event.getWhoClicked().getType() == EntityType.PLAYER )
		{
			Player p = (Player)event.getWhoClicked();
			p.sendMessage("Sorry, you are not allowed to craft this item. Purchase it from a Safe Dock instead.");
		}
		event.setCancelled(false);
	}
 
}
 
Example 18
Project: uppercore   File: Message.java   View Source Code Vote up 4 votes
public void broadcast(Iterable<? extends Player> players) {
    for(Player player : players)
        for(PlaceholderValue<String> message : lines)
            player.sendMessage(message.resolve(player));
}
 
Example 19
Project: Locked   File: PayCommand.java   View Source Code Vote up 4 votes
@Override
public boolean execute(CommandSender sender, String[] args) throws CommandException {
    if (!(sender instanceof Player)) {
        throw new CommandException("Only players can use this command!");
    }
    Player player = (Player) sender;
    try {
        int playerBal = ScrapsUtil.getScraps(player);
        if (args.length != 2) {
            return false;
        }
        if (!StringUtils.isNumeric(args[1])) {
            return false;
        }
        int amount = Integer.valueOf(args[1]);
        boolean x = false;
        for (Player p : Bukkit.getOnlinePlayers()) {
            if (p.getName().equals(args[0])) {
                x = true;
                break;
            }
        }
        if (!x) {
            player.sendMessage(ChatColor.RED + "Could not find the specified player.");
            return true;
        }
        Player target = Bukkit.getPlayer(args[0]);
        if (amount > playerBal) {
            player.sendMessage(ChatColor.RED + "You do not have " + ChatColor.DARK_RED + String.valueOf(amount) + ChatColor.RED + " scraps!");
            return true;
        }
        if (amount == 0) {
            player.sendMessage(ChatColor.RED + "You can not pay " + ChatColor.DARK_RED + "0" + ChatColor.RED + " scraps to someone!");
            return true;
        }
        ScrapsUtil.payScraps(player, target, amount);
        player.sendMessage(ChatColor.GREEN + "You payed " + target.getName() + " " + ChatColor.GOLD + String.valueOf(amount) + ChatColor.GREEN + " scraps!");
        target.sendMessage(ChatColor.GREEN + "You received " + ChatColor.GOLD + String.valueOf(amount) + ChatColor.GREEN + " scraps from " + player.getName() + "!");
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return true;
}
 
Example 20
Project: HCFCore   File: KeyListener.java   View Source Code Vote up 4 votes
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Action action = event.getAction();
    ItemStack stack = event.getItem();

    // Keys can only be used by right clicking blocks.
    if (action != Action.RIGHT_CLICK_BLOCK)
        return;

    Key key = plugin.getKeyManager().getKey(stack);

    // No keys were used in the making of this video.
    if (key == null)
        return;

    Block block = event.getClickedBlock();
    BlockState state = block.getState();
    if (key instanceof EventKey && state instanceof Chest) {
        EventKey eventKey = (EventKey) key;
        EventKey.EventKeyData eventKeyData = eventKey.getData(stack.getItemMeta().getLore());
        EventType eventType = eventKeyData.getEventType();
        List<Inventory> inventories = eventKey.getInventories(eventType);
        int inventoryNumber = eventKeyData.getInventoryNumber();

        if (inventories.size() < inventoryNumber) {
            player.sendMessage(ChatColor.RED + "This key is for " + eventType.getDisplayName() + ChatColor.RED + " loottable " + inventoryNumber + ", whilst there are only " + inventories.size()
                    + " possible. Please inform an admin.");

            return;
        }

        Inventory inventory = inventories.get(inventoryNumber - 1);
        ItemStack[] contents = inventory.getContents();

        Chest chest = (Chest) state;
        InventoryHolder inventoryHolder = chest.getInventory().getHolder();
        if (inventoryHolder instanceof DoubleChestInventory) {
            inventoryHolder = ((DoubleChestInventory) inventoryHolder).getHolder();
        }

        if (contents.length > chest.getInventory().getSize()) {
            player.sendMessage(ChatColor.RED + "This single chest is too small to fit the contents of this key.");
            return;
        }

        Inventory chestInventory = inventoryHolder.getInventory();

        if (!InventoryUtils.isEmpty(chestInventory)) {
            player.sendMessage(ChatColor.RED + "This chest is not empty.");
            return;
        }

        chestInventory.setContents(inventory.getContents());
        decrementHand(player);
        event.setCancelled(true);

        player.openInventory(chestInventory);
        player.sendMessage(ChatColor.YELLOW + "Your " + ChatColor.AQUA + eventType.getDisplayName() + ' ' + eventKey.getDisplayName() + ChatColor.YELLOW + " key has transferred loot "
                + inventoryNumber + ChatColor.YELLOW + " to the chest.");
    }
}