Solved Chat problem

Discussion in 'Plugin Development' started by kamcio96, Dec 31, 2012.

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

    kamcio96

    Hey,
    I create simple login plugin with wordpress integration. I have a problem :/ My login messages is above <player> join the game message. How I can dispaly my text under this message?
     

    Attached Files:

  2. Offline

    viruzin

    I did not understand well what do you need but maybe you can use the PlayerJoinEvent.
    Ex:
    Code:
    @EventHandler(priority = EventPriority.HIGH)
    public void onLogin(PlayerJoinEvent evt){
        evt.setJoinMessage(ChatColor.BLUE + "Welcome " + ChatColor.YELLOW + evt.getPlayer().getDisplayName());
    }
    // This message will be sent to all players online.
    
     
  3. Offline

    MP5K

    hello kamcio96,
    i don't really know what you want but i can imagine.
    if your trying to send a message to the player how is joined use the PlayerJoin event.
    Code:
        @EventHandler()
        public void onJoin(PlayerJoinEvent event){
            event.getPlayer().sendMessage("My awsome Join message!");
        }
    if your trying to change the join message use:
    Code:
        @EventHandler()
        public void onJoin(PlayerJoinEvent event){
            event.setJoinMessage("Some random text...");
        }
     
  4. Offline

    xize

    I also don't understand but you may can check my source code:
    Code:
    @EventHandler
    public void onJoin(PlayerJoinEvent p) {
        Calendar cal = Calendar.getInstance();
        cal.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("[HH:mm] E dd/MM/yy z");
      if(p.getPlayer().hasPlayedBefore()) {
      if(p.getPlayer().hasPermission("fuze.onjoin.staff")) {
        p.setJoinMessage(ChatColor.GOLD + "[" + p.getPlayer().getServer().getServerName() + "] " + ChatColor.RED  + "Staff member " + ChatColor.GREEN + p.getPlayer().getName() + ChatColor.RED + " has joined the game\n" + ChatColor.GREEN + "Current time: " + sdf.format(cal.getTime()));
        p.getPlayer().getWorld().playEffect(p.getPlayer().getLocation(), Effect.MOBSPAWNER_FLAMES, 30);
        p.getPlayer().getWorld().playEffect(p.getPlayer().getLocation(), Effect.BLAZE_SHOOT, 1);
        p.getJoinMessage();
      } else {
        p.setJoinMessage(ChatColor.GOLD + "[" + p.getPlayer().getServer().getServerName() + "] " + ChatColor.RED  + p.getPlayer().getName() + " has joined the game\n" + ChatColor.GREEN + "Current time: " + sdf.format(cal.getTime()));
        p.getJoinMessage();
      }
      } else {
      p.setJoinMessage(ChatColor.GOLD + "[" + p.getPlayer().getServer().getServerName() + "] " + ChatColor.RED + "Welcome " + p.getPlayer().getName() + "\n" + ChatColor.GREEN + "Current time: " + sdf.format(cal.getTime()));
      p.getPlayer().getWorld().playEffect(p.getPlayer().getLocation(), Effect.MOBSPAWNER_FLAMES, 30);
      p.getPlayer().getWorld().playSound(p.getPlayer().getLocation(), Sound.EXPLODE, 1, 5);
      p.getJoinMessage();
      }
    }
    @EventHandler
    public void onLeave(PlayerQuitEvent p) {
      if(p.getPlayer().hasPermission("fuze.onjoin.staff")) {
      p.setQuitMessage(ChatColor.GOLD + "[" + p.getPlayer().getServer().getServerName() + "] " + ChatColor.GREEN + p.getPlayer().getName() + ChatColor.RED + " leaves the game");
      p.getPlayer().getWorld().playEffect(p.getPlayer().getLocation(), Effect.MOBSPAWNER_FLAMES, 30);
      p.getPlayer().getWorld().playEffect(p.getPlayer().getLocation(), Effect.BLAZE_SHOOT, 1);
      p.getQuitMessage();
      } else {
      p.setQuitMessage(ChatColor.GOLD + "[" + p.getPlayer().getServer().getServerName() + "] " + ChatColor.RED + p.getPlayer().getName() + " leaves the game");
      p.getQuitMessage();
      }
    }
    
    it has plenty of shiny effects etc, welcome and quit messages

    Edit

    You may want to do this?

    Code:
    public void onJoin(PlayerJoinEvent p) {
          p.setMessage("Welcome back, " + p.getPlayer.getName() + "\n This is a new line under welcome message");
          p.getMessage();
    }
    
     
  5. Offline

    kamcio96

    I have:
    [​IMG]
    But I want to have:
    kamcio96 joined the game.
    Use /login <password> or Use /register etc...
     
  6. Offline

    fireblast709

    schedule a task sending the message 1 tick later
     
  7. Offline

    DirtyGameLp

    Look in the config.yml and look there Must stand joinmessage: Use: /login password edit this
     
  8. Offline

    kamcio96

    fireblast709
    I use
    Code:
    Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(),new Runnable() {@Override public void run(){}}, 10);
    
    But this delay event, not sendmessage.
     
  9. Offline

    fireblast709

    inside the run() method, do the player.sendMessage(), obviously ;3
     
  10. Offline

    kamcio96

    It works. Thanks :D
     
Thread Status:
Not open for further replies.

Share This Page