Auto-Kick players on certain date.

Discussion in 'Plugin Development' started by TheMeq, Jul 21, 2014.

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

    TheMeq

    Hello, I am trying to develop a plugin that automatically kicks players on a certain date. Currently it is set to today's date and has a message of "This is a test" but I will be changing this later. The code looks perfectly fine and Bukkit says the plugin has started but players can still join without a problem. Can anyone spot what I'm doing wrong?

    Code:java
    1. package ch.redstonetor.minecraftBlackout;
    2. import java.util.Calendar;
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.player.PlayerJoinEvent;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public final class MinecraftBlackout extends JavaPlugin {
    10. Logger logger = Logger.getLogger("Minecraft");
    11. Calendar cal = Calendar.getInstance();
    12. int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
    13. String dayOfMonthStr = String.valueOf(dayOfMonth);
    14.  
    15. @Override
    16. public void onEnable() {
    17. logger.info("Minecraft Blackout has been enabled");
    18. }
    19.  
    20. @Override
    21. public void onDisable() {
    22. logger.info("Minecraft Blackout has been disabled");
    23. }
    24.  
    25. public void onPlayerJoin(PlayerJoinEvent event) {
    26. Player player = event.getPlayer();
    27. dayOfMonthStr = String.valueOf(dayOfMonth);
    28.  
    29. if (dayOfMonthStr == "21")
    30. {
    31. if ((player.getName() != "TheMeq") || (player.getName() != "wesley27") || (player.getName() != "Niverive") || (player.getName() != "don4of4"))
    32.  
    33. {
    34. player.kickPlayer("This is a test!");
    35. }
    36.  
    37. }
    38. }
    39. }
    40.  
     
  2. Offline

    hintss

    if you're kicking players on join, you'll want to just disallow them in the asyncplayerprelogin
     
  3. Offline

    TheMeq

    This is my first Minecraft plugin, so asyncplayersrelogin is foreign to me :(
     
  4. Offline

    Flegyas

    From this thread -> http://forums.bukkit.org/threads/common-mistakes.100544/
     
  5. Offline

    Necrodoom

    TheMeq In addition, do not compare strings and objects using ==, use .equals, See a java document about the differences between == and .equals.
     
  6. Offline

    fireblast709

    Flegyas that event has a disallow method and a player name straight from the event. No thread safety worries needed
     
  7. Offline

    Zarkopafilis

    You should have a timer , running. Get the date from your machine , if its >= that day you want , kick everyone (and maybe turn whitelist on idk) ~Or atleast thats what I understood.
     
  8. Offline

    ReadySetPawn

    On line 24 you should have "@EventHandler"

    Also, in your onEnable method, you don't have the listener registered
     
Thread Status:
Not open for further replies.

Share This Page