Hi all! Okay,i'm noob =D I need an example plugin with source about the new event system. Just a simple plugin what gives 1000 experience to the player onlogin. Thanks !!!
This is roughly how it would be done, haven't tested it though, so it may not work; Main: Code:java package me.crazy.loginxp; import org.bukkit.Bukkit;import org.bukkit.plugin.PluginManager;import org.bukkit.plugin.java.JavaPlugin; public class LoginXP extends JavaPlugin{ LoginXPListener listener; public void onEnable(){ listener = new LoginXPListener(this); PluginManager pm = Bukkit.getServer().getPluginManager(); pm.registerEvents(this.listener, this); } } Listener: Code:java package me.crazy.loginxp; import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerJoinEvent; public class LoginXPListener implements Listener { public static LoginXP plugin; public LoginXPListener(LoginXP instance) { instance = plugin; } @EventHandler public void onPlayerJoin(PlayerJoinEvent event){ Player player = event.getPlayer(); player.setExp(player.getExp() + 1000); player.sendMessage("1000 XP has been added"); // Optional } }
Yes thanks,i checked and i did a plugin,but it wasn't works,that's why i wanted an example Thanks a lot!
If you ever need help with anything else, the Plugin Development or Resources forums are also helpful.
I prefer doing it all on one line Code:java @Overridepublic void onEnable(){ getServer().getPluginManager().registerEvents(new myListener(this), this);} Of course when im using multiple Listeners its much cleaner to use variables :