Solved Gettin a player chat messages?

Discussion in 'Plugin Development' started by VictoryShot, Apr 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    VictoryShot

    Alright so I want it for a player to click on an Item in an inventory and send them a message saying "Please enter a message to broadcast. and when they type a message its going todo a Bukkit Broadcast message. Code so far:

    Code:java
    1. ArrayList<String> broadcast = new ArrayList<String>();
    2.  
    3. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Broadcast Message")) {
    4. e.setCancelled(true);
    5. Player p = (Player) e.getWhoClicked();
    6. if (!this.broadcast.contains(p.getName())) {
    7. this.broadcast.add(p.getName());
    8. }
    9. }


    Then

    Code:java
    1. @EventHandler
    2. public void broadcaster(AsyncPlayerChatEvent e) {
    3. Player p = e.getPlayer();
    4. if(this.broadcast.contains(p.getName())) {
    5. p.sendMessage(ChatColor.DARK_PURPLE + "Please enter in the chat what you want to broadcast!");
    6.  
    7. }
    8. }
     
  2. Offline

    Nateb1121

    I think what you want to do is put your
    p.sendMessage()

    line in your first snippet, that way when they click the item they get the message (Instead of next time they chat) and change your p.sendMessage in your snippet #2 to the broadcasting code.
     
  3. Offline

    VictoryShot

    nvm solved by me! :p
     
    Nateb1121 likes this.
Thread Status:
Not open for further replies.

Share This Page