edited staticness
This commit is contained in:
@@ -8,11 +8,11 @@ import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class Main {
|
||||
|
||||
MySQL msql;
|
||||
Homes homes;
|
||||
public void enableAPI(String user, String pw, String Database, String host){
|
||||
MySQL.connect();
|
||||
homes = new Homes();
|
||||
public void enableAPI(String user, String pw, String Database, String host, int port){
|
||||
msql = new MySQL(host, port, Database, user, host);
|
||||
homes = new Homes(msql);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,11 +7,16 @@ import java.util.ArrayList;
|
||||
|
||||
public class Homes {
|
||||
|
||||
MySQL msql;
|
||||
public Homes(MySQL msql) {
|
||||
msql = msql;
|
||||
}
|
||||
|
||||
|
||||
public PlayerHome getHomeByName(String name){
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
ps = MySQL.getConnection().prepareStatement("SELECT * FROM homes WHERE Name = '" + name + "';");
|
||||
ps = msql.getConnection().prepareStatement("SELECT * FROM homes WHERE Name = '" + name + "';");
|
||||
} catch (SQLException ex) {
|
||||
System.getLogger(Homes.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex);
|
||||
}
|
||||
@@ -40,7 +45,7 @@ public class Homes {
|
||||
public void createNewHome(PlayerHome playerHome){
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
ps = MySQL.getConnection().prepareStatement("INSERT INTO homes (Name, UUID, World, x, y, z) VALUES ('"+playerHome.getName()+"','"+playerHome.getUUID()+"','"+playerHome.getWorld()+"','"+playerHome.getX()+"','"+playerHome.getY()+"','"+playerHome.getZ()+"');");
|
||||
ps = msql.getConnection().prepareStatement("INSERT INTO homes (Name, UUID, World, x, y, z) VALUES ('"+playerHome.getName()+"','"+playerHome.getUUID()+"','"+playerHome.getWorld()+"','"+playerHome.getX()+"','"+playerHome.getY()+"','"+playerHome.getZ()+"');");
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -59,7 +64,7 @@ public class Homes {
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
ps = MySQL.getConnection().prepareStatement("SELECT * FROM homes WHERE uuid = '" + UUID + "';");
|
||||
ps = msql.getConnection().prepareStatement("SELECT * FROM homes WHERE uuid = '" + UUID + "';");
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MySQL {
|
||||
connect();
|
||||
}
|
||||
|
||||
public static void connect() {
|
||||
public void connect() {
|
||||
try {
|
||||
con = DriverManager.getConnection("jdbc:mysql://45.85.219.106:3306/Bansystem?autoRecconnect=true", "craftunity", "zFtf5zFTS*ncJrXT");
|
||||
} catch (SQLException var1) {
|
||||
@@ -33,7 +33,7 @@ public class MySQL {
|
||||
|
||||
}
|
||||
|
||||
public static Connection getConnection() {
|
||||
public Connection getConnection() {
|
||||
return con;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user