exiflame
4/11/2020 - 7:27 AM

Simple Plugin + Events

// getLogger()
// This function gets the logging tool for the plugin. Accessible within the main class.
getLogger().info("Hi!");

// Registering Events
// Event class must be imported.
getServer().getPluginManager().registerEvents(new onDeath(), this);

//
// EVENTS
//

// Example event class
public class OnDeath implements Listener {
    
    // Event Name
    @EventHandler
    public void onDeath(PlayerDeathEvent e) {
        // Sends a message to the client
        e.getEntity().sendMessage("Take the L.");
        // Makes them fly
        e.getEntity().setFlying(true);
    }
}

// Leaving
public class PlayerLeave implements Listener {
    @EventHandler
    void onPlayerLeave(PlayerQuitEvent e) {
        Player player = e.getPlayer();
        e.setQuitMessage(ChatColor.AQUA + "Goodbye " + ChatColor.RED + player.getDisplayName() + "!");
    }
}
// equiv is e.SetJoinMessage();