hello! i want to something in my plugin that shows up a title if you join. I came up with an idea but it didnt work anny help? Code: public class PlayerJoin implements Listener { private JDCplugin plugin; public PlayerJoin(JDCplugin pl) { plugin = pl; } @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { sendTitle(player, "Title", "subtitle", 10, 20, 10); } } no hate plz im a beginner before i had something that worked but only the other players got the title and i want that only the player that joins a title has like mineplex. ty
Did you register the listener? Can we see the sendTitle method? Any errors? If it worked before, then the only thing I can see is the problem is the listener not being registered with Bukkit.getPluginManager().registerListeners Sent from my iPhone using Tapatalk
@jarnedeclercq There is no general sendTtile method. You have to use Player#sendTitle(TopMessage,BottomMessage) .Also remember to use schedulers to delay the message by one tick, since playerJoinEvent is triggered before the player joins the server.
never mind it is not working xD Code: package com.jdc6910169.events; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.scheduler.BukkitRunnable; import com.jdc6910169.JDCplugin; public class PlayerJoin extends BukkitRunnable implements Listener { private JDCplugin plugin; private Player player; public PlayerJoin(JDCplugin pl) { plugin = pl; } @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { player = event.getPlayer(); run(); } @Override public void run() { // TODO Auto-generated method stub Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "title" + player.getName() + "title [{\"text\":\"Blah blah\",\"color\":\"gold\"}]"); plugin.getServer().broadcastMessage(ChatColor.DARK_GREEN + player.getName() + " has joined the server!"); } } thats the code i dont know why it is not working i thougt it was easyer to do the title thisway EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@jarnedeclercq Why are you dispatching a command? Why not use Player#sendTitle() like I recommended. Also, you're not delaying the task. You need to call the scheduler and create a delayed task like what is in the wiki.
Try Code: Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "title "+player.getName()+" title {\"text\":\"Welcome!\"}"); It works great!