Solved Need Help for PlayerLoginEvent.

Discussion in 'Plugin Development' started by StreamNet, Oct 6, 2020.

  1. Offline

    StreamNet

    My code is
    Code:
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.player.PlayerLoginEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin {
      //로그인 이벤트 생성
      @EventHandler(priority= EventPriority.MONITOR)
      public void onPlayerLogin(PlayerLoginEvent event)
      {
      //플레이어 표시 이름 받아오기
      String player = event.getPlayer().getDisplayName();
      System.out.println( player + "Connected.");
      if(event.getPlayer().hasPermission("streamnetmg.STREAMER")){
      //스트리머일 경우 메시지 표시
      Bukkit.broadcastMessage("&4> &1> &4> &d[ STREAMER ] " + player + "&b님이 StreamNet에 접속하셨습니다! &4< &1< &4<");
      }
      if(event.getPlayer().hasPermission("streamnetmg.MVP")){
      //MVP일 경우 메시지 표시
      System.out.println(player + "Connected.");
      Bukkit.broadcastMessage("&4> &1> &4> &3[ MVP ] " + player + "&b님이 StreamNet에 접속하셨습니다! &4< &1< &4<");
      }
      if(event.getPlayer().hasPermission("streamnetmg.VIP")){
      //VIP일 경우 메시지 표시
      System.out.println(player + "Connected.");
      Bukkit.broadcastMessage("&4> &1> &4> &e[ VIP ] " + player + "&b님이 StreamNet에 접속하셨습니다! &4< &1< &4<");
      }
      if(event.getPlayer().hasPermission("streamnetmg.SUPERUSER")){
      //SU일 경우 메시지 표시
      Bukkit.broadcastMessage("&4> &1> &4> &4[ SUPERUSER ] " + player + "&b님이 StreamNet에 접속하셨습니다! &4< &1< &4<");
      }
      }
    }
    Sorry for non-english. I want to print Welcome messages if ranked player join to server. I got permission with LuckPerms but when join, nothing happens. What is Problem?

    I use OpenJDK 8 on CentOS.
     
    Last edited by a moderator: Oct 6, 2020
  2. Offline

    timtower Moderator Moderator

    @StreamNet You didn't register the event in the onEnable.
     
  3. Offline

    StreamNet

    Does Main.class needs event registration?
     
  4. Offline

    timtower Moderator Moderator

    Events yes, commands not.
     
  5. Offline

    StreamNet

    Thanks. How can i register Playerloginevent? Sorry. I'm new to bukkit.
     
  6. Offline

    timtower Moderator Moderator

  7. Offline

    StreamNet

Share This Page