mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-29 03:13:52 -07:00
First two hooks working, updated sample
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
|
||||
package com.dinnerbone.bukkit.sample;
|
||||
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* Handle events for all Player related events
|
||||
* @author Dinnerbone
|
||||
*/
|
||||
public class SamplePlayerListener extends PlayerListener {
|
||||
private final SamplePlugin plugin;
|
||||
|
||||
public SamplePlayerListener(SamplePlugin instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerEvent event) {
|
||||
System.out.println(event.getPlayer().getName() + " joined the server! :D");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
System.out.println(event.getPlayer().getName() + " left the server! :'(");
|
||||
}
|
||||
}
|
@@ -3,6 +3,8 @@ package com.dinnerbone.bukkit.sample;
|
||||
|
||||
import java.io.File;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.player.PlayerEvent.EventType;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -13,9 +15,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
* @author Dinnerbone
|
||||
*/
|
||||
public class SamplePlugin extends JavaPlugin {
|
||||
private final SamplePlayerListener playerListener = new SamplePlayerListener(this);
|
||||
|
||||
public SamplePlugin(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
|
||||
super(pluginLoader, instance, desc, plugin, cLoader);
|
||||
|
||||
System.out.println("Johnny five is alive!");
|
||||
|
||||
registerEvents();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
@@ -25,4 +32,9 @@ public class SamplePlugin extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
getServer().getPluginManager().registerEvent(EventType.Join, playerListener, Priority.Normal, this);
|
||||
getServer().getPluginManager().registerEvent(EventType.Quit, playerListener, Priority.Normal, this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user