This repository has been archived by the owner on Apr 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Database things removed for rushed release
- Loading branch information
1 parent
4c4acf3
commit 6e6ca06
Showing
3 changed files
with
0 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
src/main/java/com/karlofduty/altfinder/eventlisteners/OnPlayerJoin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters