Code:java @EventHandler public void Join(PlayerJoinEvent e){ Player p = e.getPlayer(); if(Main.oponly == false){ p.chat("/spawn"); e.setJoinMessage(ChatColor.GOLD + "[DerpCraft]" + ChatColor.YELLOW + "[Join] " + ChatColor.GRAY + p.getName()); }else{ if(p.isOp()){ p.chat("/spawn"); e.setJoinMessage(ChatColor.GOLD + "[DerpCraft]" + ChatColor.YELLOW + "[Join] " + ChatColor.GRAY + p.getName()); }else{ try { e.wait(2000); } catch (InterruptedException e2) { e2.printStackTrace(); } p.kickPlayer("Only op's can join!"); } } }
Code:java import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.plugin.java.JavaPlugin;import org.bukkit.scheduler.BukkitRunnable;import org.bukkit.scheduler.BukkitTask; public final class ExamplePlugin extends JavaPlugin { @Override public void onEnable() { new ExampleListener(this); }} class ExampleListener implements Listener { private final ExamplePlugin plugin; public ExampleListener(ExamplePlugin plugin) { this.plugin = plugin; plugin.getServer().getPluginManager().registerEvents(this, plugin); } @EventHandler public void onJoin(PlayerJoinEvent event) { // Create the task anonymously and schedule to run it once, after 20 ticks new BukkitRunnable() { @Override public void run() { // What you want to schedule goes here plugin.getServer().broadcastMessage( "Welcome to Bukkit! Remember to read the documentation!"); } }.runTaskLater(this.plugin, 20); } } Code:java @EventHandler public void onJoin(final PlayerJoinEvent event) { // Create the task anonymously and schedule to run it once, after 20 ticks new BukkitRunnable() { @Override public void run() { // What you want to schedule goes here event.getPlayer().kickPlayer("Derp"); } }.runTaskLater(this.plugin, 100); } } EDIT by Moderator: merged posts, please use the edit button instead of double posting.