hello i had an couple of problems with this plugin and now the problems are defeated. but now i want that as players never played before on my server that they a first joining message in the actionbar see. and this is the first time with an actionbar. and ofcourse first joining plugin coding how to add it in my build? Code (Text): public class actionbar implements Listener { private PacketPlayOutChat packet; public actionbar(String message){ PacketPlayOutChat packet = new PacketPlayOutChat(ChatSerializer.a("{\"text\": \"" + message + "\"}"), (byte) 2); this.packet = packet; } public void Send(Player player){ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); } @EventHandler public void onJoin(PlayerJoinEvent e){ Player player = e.getPlayer(); actionbar ab = new actionbar("§2Welcome back " + ChatColor.RED + p.getDisplayName() + ChatColor.WHITE + "!"); ab.Send(player); } }
Make a player login event and use the hasPlayedBefore() method. If they haven't played before, send them the actionbar packet.
i have no idea how to add it... i have this now in my build: Code (Text): public void onlogin(PlayerLoginEvent e){ Player player = e.getPlayer(); and how to go further?
Code (Text): public void onlogin(PlayerLoginEvent e){ Player player = e.getPlayer(); if(!player.hasPlayedBefore()){ //Your Code } }
and how should i add that? and this is my first time with that method. EDIT. o like that? alright then i give it a try
Add another @EventHandler, like so: Code (Text): @EventHandler public void onLogin(PlayerLoginEvent event){ Player player = e.getPlayer(); actionbar ab2 = new actionbar("Your text here..."); if(!player.hasPlayedBefore()){ ab2.send(player); } }
i added on the way you say. but i got only an error on the PlayerLoginEvent. and i have 1 JoinEvent and 1 LoginEvent. but i don't know what the error means... here's my error: Code (Text): [14:53:44] [Server thread/ERROR]: Could not pass event PlayerLoginEvent to ActionBar_welcome v1 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[minecraft.jar:git-Spigot-d276ab1-d219213] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[minecraft.jar:git-Spigot-d276ab1-d219213] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [minecraft.jar:git-Spigot-d276ab1-d219213] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.PlayerList.attemptLogin(PlayerList.java:501) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.LoginListener.b(LoginListener.java:121) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.LoginListener.F_(LoginListener.java:57) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.NetworkManager.a(NetworkManager.java:233) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.ServerConnection.c(ServerConnection.java:140) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:842) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [minecraft.jar:git-Spigot-d276ab1-d219213] at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [minecraft.jar:git-Spigot-d276ab1-d219213] at java.lang.Thread.run(Unknown Source) [?:1.8.0_121] Caused by: java.lang.NullPointerException at actionbar.actionbar.Send(actionbar.java:23) ~[?:?] at actionbar.actionbar.onLogin(actionbar.java:32) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[minecraft.jar:git-Spigot-d276ab1-d219213] ... 13 more [14:53:44] [Server thread/INFO]: _Chazzie_[/127.0.0.1:56749] logged in with entity id 2314 at ([world]-77.5, 68.0, 222.5) and here's my build: Code (Text): package actionbar; import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import net.minecraft.server.v1_11_R1.IChatBaseComponent.ChatSerializer; import net.minecraft.server.v1_11_R1.PacketPlayOutChat; public class actionbar implements Listener { private PacketPlayOutChat packet; public actionbar(String message){ PacketPlayOutChat packet = new PacketPlayOutChat(ChatSerializer.a("{\"text\": \"" + message + "\"}"), (byte) 2); this.packet = packet; } public void Send(Player player){ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); } @EventHandler public void onLogin(PlayerLoginEvent e){ Player player = e.getPlayer(); actionbar ab1 = new actionbar(ChatColor.GREEN + "Welcome new player! Have fun!"); if (!player.hasPlayedBefore()){ ab1.Send(player); } } @EventHandler public void onJoin(PlayerJoinEvent e1){ Player player = e1.getPlayer(); actionbar ab2 = new actionbar("§2Welcome back " + ChatColor.RED + player.getName() + ChatColor.WHITE + "!"); ab2.Send(player); } } What did i wrong? that the new player join message doesn't work? only the normal message does work EDIT: it is working now! that playerloginevent must be playerjoinevent. playerloginevent doesn't work in 1.11 i think.