How to TempBan someone?

Discussion in 'Plugin Development' started by Surrend3r, May 19, 2018.

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

    Surrend3r

    So I'm currently working on a punishment plugin and I need to create a tempban command tho using
    Bukkit#getBanList(BanList.Type.NAME)#addBan() isn't working for me...
    Here is my code, maybe you can find a problem in it:
    Code:
    if (timeFormat.equalsIgnoreCase("hour(s)")) {
                            Bukkit.getBanList(BanList.Type.NAME).addBan(target.toString(), msg, new Date(System.currentTimeMillis()+1000*60*60*amount), null);
                            Bukkit.broadcastMessage(new Date(System.currentTimeMillis()+1000*60*60*24*7*amount) + "");
                            target.kickPlayer(msg);
                        } else if (timeFormat.equalsIgnoreCase("day(s)")) {
                            Bukkit.getBanList(BanList.Type.NAME).addBan(target.toString(), msg, new Date(System.currentTimeMillis()+1000*60*60*24*amount), null);
                            Bukkit.broadcastMessage(new Date(System.currentTimeMillis()+1000*60*60*24*7*amount) + "");
                            target.kickPlayer(msg);
                        } else if (timeFormat.equalsIgnoreCase("week(s)")) {
                            Bukkit.getBanList(BanList.Type.NAME).addBan(target.toString(), msg, new Date(System.currentTimeMillis()+1000*60*60*24*7*amount), null);
                            Bukkit.broadcastMessage(new Date(System.currentTimeMillis()+1000*60*60*24*7*amount) + "");
                            target.kickPlayer(msg);
                        } else if (timeFormat.equalsIgnoreCase("month(s)")) {
                            Bukkit.getBanList(BanList.Type.NAME).addBan(target.toString(), msg, new Date(System.currentTimeMillis()+1000*60*60*24*30*amount), null);
                            Bukkit.broadcastMessage(new Date(System.currentTimeMillis()+1000*60*60*24*7*amount) + "");
                            target.kickPlayer(msg);
                        }
    And if you ask if timeFormat is changed to be one of these arguments so yeah, it's changed.
    I know that because it kicks the target as soon as I use the command.
     
    Last edited: May 19, 2018
  2. Offline

    PriorityHacker

    Hi @Surrend3r , can you post your entire class with PasteBin ?

    Why are you using The currentTimeMillis() at the place of a Calendar ?
     
  3. Offline

    Surrend3r

    I already got it solved thanks anyways
     
  4. Offline

    KarimAKL

    If that's the case then remember to change title prefix to solved. :p
     
Thread Status:
Not open for further replies.

Share This Page