Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from KarlOfDuty/autobanrelease
Browse files Browse the repository at this point in the history
Database things removed for rushed release
  • Loading branch information
KarlOfDuty authored Jul 23, 2018
2 parents 4c4acf3 + 6e6ca06 commit 701d8be
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 85 deletions.
22 changes: 0 additions & 22 deletions src/main/java/com/karlofduty/altfinder/AltFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@

import com.karlofduty.altfinder.commands.IPCommand;
import com.karlofduty.altfinder.commands.MCLeaksCommand;
import com.karlofduty.altfinder.eventlisteners.MCLeaksAutoCheck;
import com.karlofduty.altfinder.eventlisteners.OnPlayerJoin;
import me.gong.mcleaks.MCLeaksAPI;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.sql.SQLException;
import java.util.concurrent.TimeUnit;

public class AltFinder extends JavaPlugin
{
public static FileConfiguration config;
private static String configVersion = "00001";

public static Database database = new Database();


public final MCLeaksAPI mcLeaksAPI = MCLeaksAPI.builder()
.threadCount(2)
.expireAfter(30, TimeUnit.MINUTES).build();
Expand All @@ -43,22 +38,6 @@ public void onEnable()
"Compatible config version: " + configVersion + "\n");
}

//TODO: Add database integration and begin player logging
try
{
database.connect(
config.getString("database.mysql.hostname"),
config.getInt ("database.mysql.port"),
config.getString("database.mysql.database"),
config.getString("database.mysql.username"),
config.getString("database.mysql.password")
);
}
catch (SQLException e)
{
e.printStackTrace();
}

// Set command executors
this.getCommand("ip").setExecutor(new IPCommand());
this.getCommand("mcleaks").setExecutor(new MCLeaksCommand());
Expand All @@ -72,7 +51,6 @@ public void onEnable()
public void onDisable()
{
mcLeaksAPI.shutdown();
database.disconnect();
}

public static AltFinder getInstance() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,69 +1,19 @@
package com.karlofduty.altfinder.eventlisteners;

import com.karlofduty.altfinder.ConfigValues;
import com.karlofduty.altfinder.Database;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

//TODO: Restructure class after temporary database functionality has been added
public class OnPlayerJoin implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
logPlayerJoin(event);
if(ConfigValues.getBool("mcleaks.join-check.enable-join-check"))
{
MCLeaksAutoCheck.checkPlayer(event);
}
}
private void logPlayerJoin(PlayerJoinEvent event)
{
boolean exists = false;
try
{
String sql = "SELECT * FROM " + Database.uuidTable + " WHERE uuid=?";
PreparedStatement stmt = Database.getDB().prepareStatement(sql);
stmt.setString(1, event.getPlayer().getUniqueId().toString());
ResultSet results = stmt.executeQuery();

if (!results.next())
{
System.out.println("Failed");
}
else
{
exists = true;
System.out.println("Success");
}
}
catch (SQLException e)
{
e.printStackTrace();
}

if(!exists)
{
String sql = "INSERT INTO " + Database.uuidTable + "(`uuid`, `latestusername`, `latestip`, `lastseen`) VALUES (?,?,?,?);";
try
{
PreparedStatement stmt = Database.getDB().prepareStatement(sql);
stmt.setString(1, event.getPlayer().getUniqueId().toString());
stmt.setString(2, event.getPlayer().getName());
stmt.setString(3, event.getPlayer().getAddress().getHostName());
stmt.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
stmt.executeUpdate();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
13 changes: 0 additions & 13 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
# Only change this value if you have manually added new config entries and want to remove the console warning
config-version: "00001"

database:
type: "mysql"
mysql:
hostname: "localhost"
port: 3306
database: "altfinder"
username: "root"
password: ""

# Settings related to the anti-mcleaks part of the plugin
mcleaks:
join-check:
Expand Down Expand Up @@ -73,10 +64,6 @@ mcleaks:
execute-command: true
command: "ban <targetplayer> Using a stolen/hacked account."





# Settings for command responses
commands:

Expand Down

0 comments on commit 701d8be

Please sign in to comment.