Albert3069

메인클래스에 온조인

Feb 9th, 2020
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.first.testpl;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.player.PlayerJoinEvent;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10.  
  11. import net.minecraft.server.v1_12_R1.PacketPlayOutTitle;
  12. import net.minecraft.server.v1_12_R1.IChatBaseComponent.ChatSerializer;
  13. import net.minecraft.server.v1_12_R1.PacketPlayOutTitle.EnumTitleAction;
  14.  
  15. public class Main extends JavaPlugin implements Listener{
  16.     @Override
  17.     public void onEnable(){
  18.         Bukkit.getConsoleSender().sendMessage(ChatColor.BLUE + "플러그인이 활성화 되었습니다.");
  19.         getCommand("test").setExecutor(new Cmd());
  20.         getCommand("test2").setExecutor(new Cmd());
  21.         getServer().getPluginManager().registerEvents((Listener) this, this);
  22.  
  23.     }
  24.    
  25.     @Override
  26.     public void onDisable(){
  27.         Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "플러그인이 비활성화 되었습니다.");
  28.     }
  29.    
  30.         public void onJoin(PlayerJoinEvent event){
  31.             Player player = event.getPlayer();
  32.             PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.ACTIONBAR,
  33.             ChatSerializer.a("{\"text\":\"§a안녕하세요.\"}"),100,20,20);     
  34.             ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
  35.         }
  36.     }
RAW Paste Data