Created
April 11, 2013 22:39
-
-
Save vemacs/5367775 to your computer and use it in GitHub Desktop.
A simple tutorial Bukkit plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.reddit.admincraft.Tutorial; | |
import org.bukkit.Bukkit; | |
import org.bukkit.ChatColor; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.EventPriority; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.world.PlayerJoinEvent; | |
import org.bukkit.plugin.java.JavaPlugin; | |
// This defines our Tutorial class as a Bukkit Plugin, and also adds the listener methods | |
public class Tutorial extends JavaPlugin implements Listener { | |
// onEnable() is run when Bukkit loads the plugin | |
public void onEnable() { | |
// we register the listener, which is located in the same class | |
getServer().getPluginManager().registerEvents(this, this); | |
} | |
// JavaPlugins have to have onDisable(), and since we don't need it, it's going to be empty | |
public void onDisable() { | |
} | |
// we set the priority to highest, so our plugin has the final say | |
@EventHandler(priority = EventPriority.HIGHEST) | |
// this is triggered when a player joins the game | |
public void onPlayerJoin(PlayerJoinEvent event) { | |
Player player = event.getPlayer(); | |
// we set the message that is shown here | |
event.setJoinMessage(ChatColor.YELLOW + "Hello, " + player.getName() + "!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment