[INACTIVE] [ADMN] KiwiAdmin 2.2 - ban/tempban/kick/ipban, (MySQL or txt) [670-1158]

Discussion in 'Inactive/Unsupported Plugins' started by yottabyte, Jan 23, 2011.

  1. Offline

    yottabyte

    This plugin is no longer being updated for the public. The source is still being updated though, grab that and use it if you want to. Note that you might need to change some hard coded database names and such. (Advanced users only, basically)
    https://github.com/yottabyte/KiwiAdmin

    If you wish to continue the plugin in some form, please contact me first.

    things (open)

    KiwiAdmin 2.2
    Built against Craftbukkit #1000


    Hello people, I'm releasing my first public plugin!
    This is a very simple plugin, it adds the banning and kicking stuff for more people than just ops!

    KiwiAdmin requires either the Permissions or the GroupManager plugin!

    Features
    • Banning
    • Kicking
    • Unbanning
    • IP bans
    • Reloading banlist from either flatfile or database
    • MySQL support!
    • All actions are broadcasted to the people!
    • Case insensitivity!
    • Partial names support
    • 100% custom messages with colors
    • Temporary bans
    • Stores kicker, time, reason etc.
    • PHP script for a public banlist table. Example
    Partial names for /kick, /tempban, /ipban and /ban is optional although it is highly recommended as it seems like Bukkit has a built in feature where it can recognize a player just from the first part of their name. Eg. you ban player with "/ban playe", the ban will then be stored as playe and player will still be able to log in.


    In permissions, add these:

    Code:
    kiwiadmin.ban - Ban players
    kiwiadmin.kick - Kick players
    kiwiadmin.kick.all - Kick all players
    kiwiadmin.unban - Unban a player
    kiwiadmin.reload - Reload from the database
    kiwiadmin.tempban - Temporarily ban a player
    kiwiadmin.ipban - IP ban a player
    kiwiadmin.export - Export banlist
    
    Commands are simple:
    Code:
    /ban [player] (reason) - Ban a player, the reason will be in the kick message.
    /kick [player] (reason) - Kick a player, the reason will be in the kick message.
    /kick * (reason) - Kick all players on the server
    /tempban [player] [time] [sec/min/hour/day/week/month] (reason)
    /unban [player] - Unban a player
    /ipban [player] (reason)
    /reloadka - Reload KiwiAdmin from banlist.txt
    /checkban [player] - check if a player is banned
    /exportbans - export all bans to banned-players.txt
    
    If using flatfile, bans are stored in /plugins/KiwiAdmin/banlist.txt.
    IP bans are stored in plugins/KiwiAdmin/iplist.txt

    If you are using MySQL, run this query:
    Code:
    CREATE TABLE  `banlist` (
      `name` varchar(32) NOT NULL,
      `reason` text NOT NULL,
      `admin` varchar(32) NOT NULL,
      `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `temptime` TIMESTAMP NOT NULL ,
      PRIMARY KEY (`name`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    CREATE TABLE  `banlistip` (
      `name` varchar(32) NOT NULL,
      `ip` varchar(15) NOT NULL,
      PRIMARY KEY (`name`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    You will also need the Connector/J in your root bukkit folder just like all other MySQL plugins!

    Using the php viewer
    You can download the php file here.
    Open it in any notepad style program and change the database settings. Save and upload to website!

    Updating from 1.x
    If you have a database from KiwiAdmin 1.x you have to run
    Code:
    ALTER TABLE  `banlist` ADD  `temptime` TIMESTAMP NOT NULL ;
    Updating database from 2.0 to 2.1
    2.1 introduces IP bans, you have to create this table to use them
    Code:
    CREATE TABLE  `minecraft`.`banlistip` (
      `name` varchar(32) NOT NULL,
      `ip` varchar(15) NOT NULL,
      PRIMARY KEY (`name`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    [​IMG] Download
    Source (not updated too often)

    Update 2.2
    • Fixed /kick *
    • Added /exportbans
    Changelog (open)


    Update 2.1
    • Added IP bans
    Update 2.0

    • Almost completely rewrote the entire plugin
    • Added temporary bans, full flatfile support
    • New configuration file
    • Added customizable messages!
    • Now displays ban reason when player tries to log in
    Update 1.2

    • Added partial names support for kicking and banning.
    • Fixed the kicking message when banning showing "Reason:" although there were no reason. (Only for MySQL users)
    Update 1.1

    • Reverted back to normal commands, /ban, /kick and /unban
    • More case insensitivity improvements. The banlists are no longer lower case only.
    • Fixed the ugly blank lines in the txt file if using flatfile
    Update 1.0


    • MySQL support!
    • Cleaned up A LOT of code.
    Update 0.5


    • Removed TSLPC
    • Added console commands support. These will be displayed as "server" eg. "yottabyte has been kicked by server!"
    Update 0.4


    • Updated to work with version 183+
    • Reformatted the commands to avoid interfering with the vanilla commands.
    Version 0.3


    • Added /unban
    • Added /reloadka - reloads the banlist from banlist.txt
    Version 0.2


    • When a player is kicked or banned, a global message is sent. Includes reason if there is one.
    • Changed PLAYER_JOIN to PLAYER_LOGIN, banned players are now kicked before they enter the server.

     
    losdamianos, malex, zcleaver and 3 others like this.
  2. Offline

    yottabyte

    @thestriker095

    Could you post the entire error message? It seems like it cuts off at the end.
     
  3. Offline

    Niaghaman

    If I don't want to let players see messages when someone is banning etc., is it enough to remove
    Code:
        banMsgFailed: "Gracz %victim% otrzymal bana."
    or to set this command like this:
    Code:
        banMsgFailed: ""
     
  4. Offline

    yottabyte

    @Niaghaman
    Nope, I haven't added a function like that. If you remove that line or set it to blank, I'm pretty sure you will get an error.
     
  5. Offline

    Niaghaman

    You should do that. ;-)
     
  6. Offline

    jzsig

    @yottabyte i was wondering if you would add a silent parameter (like -s or -silent like some of the command book commands) to the bans/kicks /ban person reason -s so that it doesn't display in chat, there are times when the players don't need to see reasons or other things like that it would be very helpful and in my opinion a very good addition to your already awesome plugin! o one more thing a command to change the reason for the ban would be very helpful so admins dont have to unban them then ban them again -thanks jzsig

    ps, if your looking for a good anti x ray plugin check out logores imo its alot better then ore to client obfuscation :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 6, 2016
  7. Offline

    thestriker095

    Sorry about that here it is!

    >kick *
    21:47:33 [WARNING] Unexpected exception while parsing console command
    org.bukkit.command.CommandException: Unhandled exception executing command 'kick' in plugin KiwiAdmin v2.1
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:129)
    at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:312)
    at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:480)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:465)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.NullPointerException
    at ru.tehkode.permissions.compat.PermissionHandler.permission(PermissionHandler.java:70)
    at com.yottabyte.bukkit.KiwiAdmin.kickPlayer(KiwiAdmin.java:314)
    at com.yottabyte.bukkit.KiwiAdmin.onCommand(KiwiAdmin.java:230)
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
    ... 6 more
     
  8. Offline

    Worlther

    You rollback version? Download link is still to 2.1 version or i'm too stupid ;f
     
  9. Offline

    o0AzzA0o


    /exportbans returns unknown console command

    using the plugin linked as above
    http://dl.dropbox.com/u/11931950/minecraft/plugins/KiwiAdmin.rar

    my guess is that link is still pointing to version 2.1 since this is what i get in log
    2011-08-02 13:16:46 [INFO] [KiwiAdmin] Initialized db connection
    2011-08-02 13:16:46 [INFO] KiwiAdmin version 2.1 is enabled!

    sorry to be a pain :p
     
  10. Offline

    thestriker095

    @yottabyte the download like seems to link to KiwiAdmin v.2.1 still can you create a new download link for the time being?

    Thanks!
     
  11. Offline

    19jojo93

    Does this plugin conflict with Commandbook?

    When ever I try to kick or ban someone etc, my server uses commandbook to kick and ban them instead of KiwiAdmin, how can I fix this please :( ?
     
  12. Offline

    yottabyte

    When you download commandbook you can choose to customize it. Remove the ban functions!
     
  13. Offline

    19jojo93

    Thanks very much!
     
  14. Offline

    Keetveter

    Download link links to 2.1 not 2.2.
     
  15. Offline

    dataviruset

    It's a great plugin. I would like to modify it so that it catches the IP address of a player when he gets banned and also stores that in the database table, though.
    The source code on GitHub, is it up to date? If it isn't, can you please update it so that I can download the source code and modify it myself? Or can you add an IP address column to the ordinary bans table and add the function that saves the IP address there as well as the other info? Thanks in advance :)
     
  16. Offline

    Keetveter

    Title says 2.2. Title in post says 2.1. When I download server says 2.1. What is the latest and how can I download the latest version?
     
  17. Offline

    Mathiasbk

    Could you make it possible to change the date text if someone has been tempbanned?
    for example. let me change "tue" and "aug" to whatever i want.
     
  18. Offline

    a_dizzle

    Would it be possible to add a couple of things.

    1. Add a notify system (permission) so instead of the message being global you can choose with permission who will see the message.

    2. For /checkban <user>, If the user has a ban make it return the admin responsible and the reason along with time and time of unban. Blank if perm.

    Notes for players including ban history or admin notes.

    3. On the Login screen when a banned played tried to login, I would like it to be able to change %admin% to the appropriate term (ie person who banned ) and %time% banned.
     
  19. Offline

    Charant

    Need ip unban from in-game console please
     
  20. Offline

    [qwerty]

    When a griefer is IP banned, does it automatically ban their name along with the IP address? Or do you have to ban their name AND IP?
     
  21. Offline

    a_dizzle

    It bans the user as well

    (I looked at the code)

    I also made a mod from this. Here it is if anyone wants it <Edit by Moderator: Redacted mediafire url>

    1. Included Perm node "kiwiadmin.notify" Groups with this will see ban/unban/kick message. As i changed all broadcast messages to this. Config says the same except all global/broadcast things will now work under .notify

    2. Included %admin% in login messages. (It will now replace %admin% on login msg)

    3. When a user types /checkban <username> and the user has been banned.

    This will appear.

    Line one. <username> has been banned
    Line two. <Reason> [Admin]
    Line three. <Time banned> ---- <Time unbanned> *If no time unbanned will return "Permanent"

    ***Problems, Since there are two methods of banning a person temp/perm the tables are different for these two situations. When you type /checkban on a perm user it will produce errors in the log. This will spam your logs.
    I could fix it but i cant be bothered. If the author decides to add this in the future i'm sure he will.

    I'm just providing this temporarily fix/addons ;) since I need them.

    Untested without SQL tables. Probably will not work.

    SRC of CHANGE
    Code:
    package com.yottabyte.bukkit;
    
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintStream;
    import java.io.PrintWriter;
    import java.net.InetAddress;
    import java.net.InetSocketAddress;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Timestamp;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.Map;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import org.bukkit.Server;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.PluginManager;
    
    public class Database
    {
      public Database(Plugin plugin)
      {
        if (KiwiAdmin.useMysql) {
          Connection conn = SQLConnection.getSQLConnection();
          if (conn == null) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Could not establish SQL connection. Disabling KiwiAdmin");
            plugin.getServer().getPluginManager().disablePlugin(plugin);
            return;
          }
    
          PreparedStatement ps = null;
          ResultSet rs = null;
          try {
            ps = conn.prepareStatement("SELECT * FROM " + KiwiAdmin.mysqlTable);
            rs = ps.executeQuery();
            while (rs.next()) { String pName = rs.getString("name").toLowerCase();
              Timestamp pTime;
              try { pTime = rs.getTimestamp("temptime");
              }
              catch (SQLException ex)
              {
                pTime = new Timestamp(0L);
              }
              KiwiAdmin.bannedPlayers.add(pName.toLowerCase());
              if (pTime.getTime() != 0L) {
                KiwiAdmin.tempBans.put(rs.getString("name").toLowerCase(), Long.valueOf(pTime.getTime()));
              }
            }
            ps = conn.prepareStatement("SELECT * FROM " + KiwiAdmin.mysqlTableIp);
            rs = ps.executeQuery();
            while (rs.next()) {
              String ip = rs.getString("ip");
              System.out.println("Added " + ip);
              KiwiAdmin.bannedIPs.add(ip);
            }
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
            try
            {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex4) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex4);
            }
          }
          finally
          {
            try
            {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
          try
          {
            conn.close();
            KiwiAdmin.log.log(Level.INFO, "[KiwiAdmin] Initialized db connection");
          } catch (SQLException e) {
            e.printStackTrace();
            plugin.getServer().getPluginManager().disablePlugin(plugin);
          }
    
        }
        else
        {
          try
          {
            File banlist = new File("plugins/KiwiAdmin/banlist.txt");
    
            if (banlist.exists()) {
              BufferedReader in = new BufferedReader(new FileReader(banlist));
              String data = null;
    
              while ((data = in.readLine()) != null)
              {
                if ((data.startsWith("#")) ||
                  (data.length() <= 0)) continue;
                String[] values = data.split(">>");
                String player = values[0];
                try {
                  Timestamp pTime = Timestamp.valueOf(values[4]);
    
                  KiwiAdmin.tempBans.put(player.toLowerCase(), Long.valueOf(pTime.getTime()));
                }
                catch (Exception localException)
                {
                }
                KiwiAdmin.bannedPlayers.add(player.toLowerCase());
              }
    
              in.close();
            }
    
            File banlistip = new File("plugins/KiwiAdmin/iplist.txt");
    
            if (banlistip.exists()) {
              BufferedReader in = new BufferedReader(new FileReader(banlistip));
              String data = null;
    
              while ((data = in.readLine()) != null)
              {
                if ((data.startsWith("#")) ||
                  (data.length() <= 0)) continue;
                String[] values = data.split(">>");
                String ip = values[1];
                KiwiAdmin.bannedIPs.add(ip);
              }
    
              in.close();
            }
    
          }
          catch (IOException e)
          {
            e.printStackTrace();
          }
        }
      }
    
      public static void updateFlatFile()
      {
        try
        {
          File banlist = new File("plugins/KiwiAdmin/banlist.txt");
          if (banlist.exists()) {
            BufferedReader in = new BufferedReader(new FileReader(banlist));
            File tempFile = new File(banlist.getAbsolutePath() + ".tmp");
            PrintWriter out = new PrintWriter(new FileWriter(tempFile));
            String data = null;
            while ((data = in.readLine()) != null)
            {
              if (data.length() > 0) {
                if (!data.contains(">>")) {
                  String player = data;
                  out.println(player + ">>undefined>>?>>?>>0");
                } else {
                  out.println(data);
                }
              }
            }
            in.close();
            out.close();
    
            banlist.delete();
            tempFile.renameTo(banlist);
          }
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
      }
    
      public static boolean removeFromBanlist(String p)
      {
        if (!KiwiAdmin.bannedPlayers.contains(p.toLowerCase())) {
          return false;
        }
        if (KiwiAdmin.useMysql)
        {
          Connection conn = null;
          PreparedStatement ps = null;
          try {
            conn = SQLConnection.getSQLConnection();
            ps = conn.prepareStatement("DELETE FROM " + KiwiAdmin.mysqlTable + " WHERE name = ?");
            ps.setString(1, p.toLowerCase());
            ps.executeUpdate();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
            return false;
          } finally {
            try {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
          try
          {
            if (ps != null)
              ps.close();
            if (conn == null)  conn.close();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
          }
        }
        else
        {
          try
          {
            String file = "plugins/KiwiAdmin/banlist.txt";
            File banlist = new File(file);
    
            File tempFile = new File(banlist.getAbsolutePath() + ".tmp");
    
            BufferedReader br = new BufferedReader(new FileReader(file));
            PrintWriter pw = new PrintWriter(new FileWriter(tempFile));
    
            String line = null;
    
            while ((line = br.readLine()) != null) {
              if ((!line.trim().toLowerCase().startsWith(p.toLowerCase())) && (line.length() > 0)) {
                pw.println(line);
                pw.flush();
              }
            }
    
            pw.close();
            br.close();
    
            banlist.delete();
            tempFile.renameTo(banlist);
    
            return true;
          }
          catch (FileNotFoundException ex)
          {
            ex.printStackTrace();
          }
          catch (IOException ex) {
            ex.printStackTrace();
          }
        }
        label387: return true;
      }
    
      public void addPlayer(String p, String reason, String kicker)
      {
        addPlayer(p, reason, kicker, 0L);
      }
    
      public void addPlayer(String p, String reason, String kicker, long tempTime)
      {
        Date date = new Date();
        Timestamp time = new Timestamp(date.getTime());
        Timestamp temptime = new Timestamp(tempTime);
    
        if (KiwiAdmin.useMysql)
        {
          Connection conn = null;
          PreparedStatement ps = null;
          try {
            conn = SQLConnection.getSQLConnection();
            if (tempTime > 0L) {
              ps = conn.prepareStatement("INSERT INTO " + KiwiAdmin.mysqlTable + " (name,reason,admin,time,temptime) VALUES(?,?,?,?,?)");
              ps.setTimestamp(5, temptime);
            } else {
              ps = conn.prepareStatement("INSERT INTO " + KiwiAdmin.mysqlTable + " (name,reason,admin,time) VALUES(?,?,?,?)");
            }ps.setString(1, p);
            ps.setString(2, reason);
            ps.setString(3, kicker);
            ps.setTimestamp(4, time);
            ps.executeUpdate();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
            try
            {
              if (ps != null)
                ps.close();
              if (conn == null) return; conn.close();
            } catch (SQLException ex2) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex2);
            }
          }
          finally
          {
            try
            {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
          try
          {
            if (ps != null)
              ps.close();
            if (conn == null) return; conn.close();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
          }
        }
        else
        {
          String temptimeStr;
          if (tempTime <= 0L)
            temptimeStr = "0";
          else
            temptimeStr = temptime.toString();
          try
          {
            BufferedWriter banlist = new BufferedWriter(new FileWriter("plugins/KiwiAdmin/banlist.txt", true));
            banlist.newLine();
            banlist.write(p + ">>" + reason + ">>" + kicker + ">>" + time + ">>" + temptimeStr);
            banlist.close();
          }
          catch (IOException e)
          {
            KiwiAdmin.log.log(Level.SEVERE, "KiwiAdmin: Couldn't write to banlist.txt");
          }
        }
      }
    
      public static String getReason(String p)
      {
        if (KiwiAdmin.useMysql) {
          Connection conn = SQLConnection.getSQLConnection();
          PreparedStatement ps = null;
          ResultSet rs = null;
          try {
            ps = conn.prepareStatement("SELECT * FROM " + KiwiAdmin.mysqlTable + " WHERE name = ?");
            ps.setString(1, p);
            rs = ps.executeQuery();
            if (rs.next()) {
              String reason = rs.getString("reason");
              String str1 = reason;
              return str1;
            }
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
          } finally {
            try {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
          try
          {
            if (ps != null)
              ps.close();
            if (conn != null)
              conn.close();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
          }
    
          return null;
        }
        try {
          BufferedReader in = new BufferedReader(new FileReader("plugins/KiwiAdmin/banlist.txt"));
          String data = null;
    
          while ((data = in.readLine()) != null)
          {
            if ((data.startsWith("#")) ||
              (!data.trim().toLowerCase().startsWith(p.toLowerCase())) || (data.length() <= 0))
              continue;
            String[] values = data.split(">>");
    
            return values[1];
          }
    
          in.close();
        } catch (Exception e) {
          e.printStackTrace();
        }
    
        return null;
      }
    
      public static String getAdmin(String p)
      {
        if (KiwiAdmin.useMysql) {
          Connection conn = SQLConnection.getSQLConnection();
          PreparedStatement ps = null;
          ResultSet rs = null;
          try {
            ps = conn.prepareStatement("SELECT * FROM " + KiwiAdmin.mysqlTable + " WHERE name = ?");
            ps.setString(1, p);
            rs = ps.executeQuery();
            if (rs.next()) {
              String admin = rs.getString("admin");
              String str1 = admin;
              return str1;
            }
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
          } finally {
            try {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
          try
          {
            if (ps != null)
              ps.close();
            if (conn != null)
              conn.close();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
          }
    
          return null;
        }
        return null;
      }
    
      public static String getTime(String p)
      {
        if (KiwiAdmin.useMysql) {
          Connection conn = SQLConnection.getSQLConnection();
          PreparedStatement ps = null;
          ResultSet rs = null;
          try {
            ps = conn.prepareStatement("SELECT * FROM " + KiwiAdmin.mysqlTable + " WHERE name = ?");
            ps.setString(1, p);
            rs = ps.executeQuery();
            if (rs.next()) {
              String time = rs.getString("time");
              String str1 = time;
              return str1;
            }
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
          } finally {
            try {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
          try
          {
            if (ps != null)
              ps.close();
            if (conn != null)
              conn.close();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
          }
    
          return null;
        }
        return null;
      }
    
      public static String getTemptime(String p)
      {
        if (KiwiAdmin.useMysql) {
          Connection conn = SQLConnection.getSQLConnection();
          PreparedStatement ps = null;
          ResultSet rs = null;
          try {
            ps = conn.prepareStatement("SELECT * FROM " + KiwiAdmin.mysqlTable + " WHERE name = ?");
            ps.setString(1, p);
            rs = ps.executeQuery();
            if (rs.next()) {
              String temptime = rs.getString("temptime");
              String str1 = temptime;
              return str1;
            }
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
          } finally {
            try {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
          try
          {
            if (ps != null)
              ps.close();
            if (conn != null)
              conn.close();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
          }
    
          return null;
        }
        return null;
      }
    
      public void addAddress(String p, InetSocketAddress address)
      {
        String ip = address.getAddress().getHostAddress();
    
        if (KiwiAdmin.useMysql)
        {
          Connection conn = null;
          PreparedStatement ps = null;
          try {
            conn = SQLConnection.getSQLConnection();
            ps = conn.prepareStatement("INSERT INTO " + KiwiAdmin.mysqlTableIp + " (name,ip) VALUES(?,?)");
            ps.setString(1, p);
            ps.setString(2, ip);
            ps.executeUpdate();
          } catch (SQLException ex) {
            KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Couldn't execute MySQL statement: ", ex);
            try
            {
              if (ps != null)
                ps.close();
              if (conn == null) return; conn.close();
            } catch (SQLException ex1) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex1);
            }
          }
          finally
          {
            try
            {
              if (ps != null)
                ps.close();
              if (conn != null)
                conn.close();
            } catch (SQLException ex) {
              KiwiAdmin.log.log(Level.SEVERE, "[KiwiAdmin] Failed to close MySQL connection: ", ex);
            }
          }
        }
        else
        {
          try {
            BufferedWriter banlist = new BufferedWriter(new FileWriter("plugins/KiwiAdmin/iplist.txt", true));
            banlist.newLine();
            banlist.write(p + ">>" + ip);
            banlist.close();
          }
          catch (IOException e)
          {
            KiwiAdmin.log.log(Level.SEVERE, "KiwiAdmin: Couldn't write to iplist.txt");
          }
        }
      }
    }
     
    Last edited by a moderator: Dec 15, 2016
  22. Offline

    phrstbrn

    Whenever I run /checkban <player> it immediately lags the server. My guess is you're running the SQL lookups in the main server thread, which is really, really bad.

    Can you provide source to the latest version (2.2) so I can fix this (GitHub seems out of date)? Or can you fix this?
    ------
    I looked at the Github source and see it's an in-memory ArrayList. Not sure how many bans we have, but for whatever reason it appears to be causing some lag. I would consider changing the ban list to a HashSet (or TreeSet), since there should be no duplicates anyways.
     
  23. Offline

    BarelyMissed

    Possible to make /reloadka reload the iplist.txt file too?
     
  24. Offline

    venom1324

    Code:
    2011-08-12 15:43:23 [SEVERE] Could not load 'plugins/KiwiAdmin.jar' in folder 'plugins': 
    unacceptable character #FFFD special characters are not allowed
    in "<reader>", position 694
        at org.yaml.snakeyaml.reader.StreamReader.checkPrintable(StreamReader.java:68)
        at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:159)
        at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:117)
        at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:106)
        at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:964)
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:237)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:183)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:200)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:163)
        at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148)
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:104)
        at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:124)
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:264)
        at org.bukkit.util.config.Configuration.load(Configuration.java:82)
        at org.bukkit.plugin.java.JavaPlugin.initialize(JavaPlugin.java:157)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:175)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:207)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:130)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:128)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:97)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:51)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:132)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    When i restart server, i get this .
     
  25. Offline

    Hayaku

    mysql-database: 'jdbc:mysql://localhost:3306/minecraft'

    What I place where: minecraft is database name? why there's port 3306?
     
  26. Offline

    Mapatti

    Port 3306 is default mySQL port. jdbc:mysql://servernameherecanbeiptoo.com/databasenamehere
     
  27. Offline

    Hayaku

    Code:
    14:40:23 [SEVERE] Unable to retreive connection
    
    java.sql.SQLException: No suitable driver found for jdbc:mysql://censored:3306/censored?autoReconnect=true&user=censored&password=censored
    
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    
    at java.sql.DriverManager.getConnection(DriverManager.java:207)
    
    at com.yottabyte.bukkit.SQLConnection.getSQLConnection(SQLConnection.java:21)
    
    at com.yottabyte.bukkit.Database.<init>(Database.java:26)
    
    at com.yottabyte.bukkit.KiwiAdmin.onEnable(KiwiAdmin.java:134)
    
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:126)
    
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:878)
    
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:272)
    
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:162)
    
    at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:146)
    
    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:284)
    
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:271)
    
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:148)
    
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
    
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    
    14:40:23 [SEVERE] [KiwiAdmin] Could not establish SQL connection. Disabling KiwiAdmin
    
    14:40:23 [INFO] KiwiAdmin disabled.
    
    14:40:23 [SEVERE] Error occurred while enabling KiwiAdmin v2.2 (Is it up to date?): Plugin attempted to register PLAYER_LOGIN while not enabled
    
    org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register PLAYER_LOGIN while not enabled
    
    at org.bukkit.plugin.SimplePluginManager.registerEvent(SimplePluginManager.java:368)
    
    at com.yottabyte.bukkit.KiwiAdmin.onEnable(KiwiAdmin.java:138)
    
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:126)
    
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:878)
    
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:272)
    
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:162)
    
    at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:146)
    
    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:284)
    
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:271)
    
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:148)
    
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
    
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
     
  28. Offline

    dataviruset

    "No suitable driver found"? That sounds like you have broke MySQL libraries somehow...
     
  29. Offline

    Hayaku

    I don't know. I have typed ip of my site, good database name and user. It should work... "You will also need the Connector/J in your root bukkit folder just like all other MySQL plugins!" - maybe this is what I need couse idk what that means.
     
  30. Offline

    dog.big

    Hello,
    could you help me?
    i configured KA 2.2. to use MYSQL, but when doing /ipban, the name is banned but IP still can connect (IP ban is also showed in banlistip table.
     
  31. Offline

    Mapatti

    I have problem where IP is banned aswell as user but when I unban user, IP will be banned still.
     

Share This Page