Kobe helpen.

Discussion in 'Bukkit Help' started by MvpWouterske23, May 2, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    MvpWouterske23

  2. Code:java
    1. @EventHandler
    2. public void Join(PlayerJoinEvent e){
    3. Player p = e.getPlayer();
    4. if(Main.oponly == false){
    5. p.chat("/spawn");
    6. e.setJoinMessage(ChatColor.GOLD + "[DerpCraft]" + ChatColor.YELLOW + "[Join] " + ChatColor.GRAY + p.getName());
    7. }else{
    8. if(p.isOp()){
    9. p.chat("/spawn");
    10. e.setJoinMessage(ChatColor.GOLD + "[DerpCraft]" + ChatColor.YELLOW + "[Join] " + ChatColor.GRAY + p.getName());
    11. }else{
    12. try {
    13. e.wait(2000);
    14. } catch (InterruptedException e2) {
    15. e2.printStackTrace();
    16. }
    17. p.kickPlayer("Only op's can join!");
    18. }
    19. }
    20. }
     
  3. Offline

    MvpWouterske23

    Code:java
    1. import org.bukkit.event.EventHandler;
    2. import org.bukkit.event.Listener;
    3. import org.bukkit.event.player.PlayerJoinEvent;
    4. import org.bukkit.plugin.java.JavaPlugin;
    5. import org.bukkit.scheduler.BukkitRunnable;
    6. import org.bukkit.scheduler.BukkitTask;
    7.  
    8. public final class ExamplePlugin extends JavaPlugin {
    9.  
    10. @Override
    11. public void onEnable() {
    12. new ExampleListener(this);
    13. }
    14. }
    15.  
    16. class ExampleListener implements Listener {
    17.  
    18. private final ExamplePlugin plugin;
    19.  
    20. public ExampleListener(ExamplePlugin plugin) {
    21. this.plugin = plugin;
    22. plugin.getServer().getPluginManager().registerEvents(this, plugin);
    23. }
    24.  
    25. @EventHandler
    26. public void onJoin(PlayerJoinEvent event) {
    27. // Create the task anonymously and schedule to run it once, after 20 ticks
    28. new BukkitRunnable() {
    29.  
    30. @Override
    31. public void run() {
    32. // What you want to schedule goes here
    33. plugin.getServer().broadcastMessage(
    34. "Welcome to Bukkit! Remember to read the documentation!");
    35. }
    36.  
    37. }.runTaskLater(this.plugin, 20);
    38. }
    39.  
    40. }


    Code:java
    1. @EventHandler
    2. public void onJoin(final PlayerJoinEvent event) {
    3. // Create the task anonymously and schedule to run it once, after 20 ticks
    4. new BukkitRunnable() {
    5.  
    6. @Override
    7. public void run() {
    8. // What you want to schedule goes here
    9. event.getPlayer().kickPlayer("Derp");
    10. }
    11.  
    12. }.runTaskLater(this.plugin, 100);
    13. }
    14.  
    15. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page