Guest User

Untitled

a guest
May 28th, 2017
36
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package event.player;
  2.  
  3. import net.minecraft.server.v1_11_R1.PacketPlayOutTitle;
  4. import net.minecraft.server.v1_11_R1.IChatBaseComponent.ChatSerializer;
  5. import net.minecraft.server.v1_11_R1.PacketPlayOutTitle.EnumTitleAction;
  6. import net.minecraft.server.v1_11_R1.PlayerConnection;
  7.  
  8. import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.player.PlayerJoinEvent;
  13.  
  14. import com.hibba.plugin.Plugin;
  15.  
  16. public class PlayerJoin implements Listener {
  17.  
  18. private Plugin plugin;
  19.  
  20. public PlayerJoin(Plugin pl) {
  21. // plugin = pl;
  22. }
  23.  
  24. @EventHandler
  25. public void onPlayerJoin(PlayerJoinEvent event) {
  26.  
  27. Player player = event.getPlayer();
  28. String welcomeMessage = plugin.getConfig().getString("Welcome Message")
  29. .replace("&", "§");
  30. welcomeMessage = welcomeMessage.replace("%player%",
  31. player.getDisplayName()); // Replace %player% with the player's
  32. // name.
  33.  
  34. PacketPlayOutTitle welcomeTitle = new PacketPlayOutTitle(
  35. EnumTitleAction.TITLE,
  36. ChatSerializer
  37. .a(",{\"text\":\"Hibba\",\"color\":\"green\",\"bold\":true}"),
  38. 30, 50, 20);
  39. PacketPlayOutTitle welcomeSubtitle = new PacketPlayOutTitle(
  40. EnumTitleAction.SUBTITLE,
  41. ChatSerializer
  42. .a(",{\"text\":\"Welkom\",\"color\":\"green\",\"bold\":true,\"underlined\":true}"),
  43. 30, 50, 20);
  44.  
  45. PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
  46. connection.sendPacket(welcomeTitle);
  47. connection.sendPacket(welcomeSubtitle);
  48.  
  49. player.sendMessage(welcomeMessage);
  50. }
  51. }
RAW Paste Data