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