initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.softwarerat;
|
||||
|
||||
import com.softwarerat.MySQL.Ban;
|
||||
import com.softwarerat.MySQL.Login;
|
||||
import com.softwarerat.MySQL.Report;
|
||||
import com.softwarerat.MySQL.SQLHandler;
|
||||
import lombok.Getter;
|
||||
import com.softwarerat.MySQL.Mute;
|
||||
@Getter
|
||||
public class Bansystem {
|
||||
Ban ban;
|
||||
Report report;
|
||||
Mute mute;
|
||||
SQLHandler sqlHandler;
|
||||
Login login;
|
||||
public void enableAPI(String user,String pw,String host,String db){
|
||||
login = new Login();
|
||||
sqlHandler = new SQLHandler(host,user, db, pw);
|
||||
ban = new Ban(sqlHandler);
|
||||
report = new Report(sqlHandler);
|
||||
mute = new Mute(sqlHandler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.softwarerat.MySQL;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
// Class containing all SQL things for the Ban Topic
|
||||
public class Ban {
|
||||
SQLHandler sqlHandler;
|
||||
|
||||
public Ban(SQLHandler sqlHandler) {
|
||||
this.sqlHandler = sqlHandler;
|
||||
}
|
||||
|
||||
public void addPunishment(String uuid, String Reason ,String punisher,long time) {
|
||||
|
||||
System.out.println("Neuer Datenabruf");
|
||||
String BanID = UUID.randomUUID().toString();
|
||||
System.out.println("INSERT INTO Ban (UUID, BanID ,Name , Reason, Time) VALUES ('"+uuid+"','"+BanID+"','"+punisher+"','"+Reason+"','"+time+"');");
|
||||
try {
|
||||
sqlHandler.executeUpdate("INSERT INTO Ban (UUID, BanID ,Name , Reason, Time) VALUES ('"+uuid+"','"+BanID+"','"+punisher+"','"+Reason+"','"+time+"');");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Long getBanTime(String uuid){
|
||||
ResultSet resultSet = null;
|
||||
System.out.println("Neuer Datenabruf");
|
||||
try {
|
||||
System.out.println("SELECT * FROM Ban WHERE UUID = '"+uuid+"';");
|
||||
resultSet = sqlHandler.executeQuery("SELECT * FROM Ban WHERE UUID = '"+uuid+"';");
|
||||
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.next();
|
||||
return resultSet.getLong("Time");
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getBanUUID(String UUID) {
|
||||
System.out.println("Loading Kit");
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
resultSet = sqlHandler.executeQuery("SELECT * FROM Ban WHERE UUID = '"+UUID+"';");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.next();
|
||||
return resultSet.getString("UUID");
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
System.out.println("Loaded Kit");
|
||||
return null;
|
||||
}
|
||||
public void deletePunishment(String uuid) {
|
||||
|
||||
System.out.println("Neuer Datenabruf");
|
||||
try {
|
||||
sqlHandler.executeUpdate("DELETE FROM Ban WHERE UUID = '"+ uuid + "';");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.softwarerat.MySQL;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class Login {
|
||||
String hostname = "127.0.0.1";
|
||||
String database = "Ban";
|
||||
String username = "BanSystem";
|
||||
String password = "GGoders0";
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.softwarerat.MySQL;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
// Class containing all SQL things for the Ban Topic
|
||||
public class Mute {
|
||||
|
||||
SQLHandler sqlHandler;
|
||||
|
||||
|
||||
public Mute(SQLHandler sqlHandler) {
|
||||
this.sqlHandler = sqlHandler;
|
||||
}
|
||||
|
||||
public void addPunishment(String uuid, String Reason , String punisher, long time) {
|
||||
|
||||
System.out.println("Neuer Datenabruf");
|
||||
String BanID = UUID.randomUUID().toString();
|
||||
System.out.println("INSERT INTO Mute (UUID, MuteID ,Name , Reason, Time) VALUES ('"+uuid+"','"+BanID+"','"+punisher+"','"+Reason+"','"+time+"');");
|
||||
try {
|
||||
sqlHandler.executeUpdate("INSERT INTO Mute (UUID, MuteID ,Name , Reason, Time) VALUES ('"+uuid+"','"+BanID+"','"+punisher+"','"+Reason+"','"+time+"');");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Long getMuteTime(String uuid){
|
||||
ResultSet resultSet = null;
|
||||
System.out.println("Neuer Datenabruf");
|
||||
try {
|
||||
System.out.println("SELECT * FROM Mute WHERE UUID = '"+uuid+"';");
|
||||
resultSet = sqlHandler.executeQuery("SELECT * FROM Mute WHERE UUID = '"+uuid+"';");
|
||||
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.next();
|
||||
return resultSet.getLong("Time");
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMuteUUID(String UUID) {
|
||||
System.out.println("Loading Kit");
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
resultSet = sqlHandler.executeQuery("SELECT * FROM Mute WHERE UUID = '"+UUID+"';");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.next();
|
||||
return resultSet.getString("UUID");
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
System.out.println("Loaded Kit");
|
||||
return null;
|
||||
}
|
||||
public void deletePunishment(String uuid) {
|
||||
|
||||
System.out.println("Neuer Datenabruf");
|
||||
try {
|
||||
sqlHandler.executeUpdate("DELETE FROM Mute WHERE UUID = '"+ uuid + "';");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.softwarerat.MySQL;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class Report {
|
||||
|
||||
SQLHandler sqlHandler;
|
||||
|
||||
public Report(SQLHandler sqlHandler) {
|
||||
this.sqlHandler = sqlHandler;
|
||||
}
|
||||
|
||||
public void addReport(String uuid, String Reason , String reporter) {
|
||||
|
||||
System.out.println("Neuer Datenabruf");
|
||||
String BanID = UUID.randomUUID().toString();
|
||||
System.out.println("INSERT INTO Report (UUID, ReportID ,Name , Reason) VALUES ('"+uuid+"','"+BanID+"','"+reporter+"','"+Reason+"');");
|
||||
try {
|
||||
sqlHandler.executeUpdate("INSERT INTO Report (UUID, ReportID ,Name , Reason) VALUES ('"+uuid+"','"+BanID+"','"+reporter+"','"+Reason+"');");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<String> getReports() {
|
||||
List<String> reportIDs = new ArrayList<>();
|
||||
System.out.println("Loading Kit");
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
resultSet = sqlHandler.executeQuery("SELECT * FROM Report;");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
while (resultSet.next()){
|
||||
reportIDs.add(resultSet.getString("ReportID"));
|
||||
}
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
System.out.println("Loaded Kit");
|
||||
return null;
|
||||
}
|
||||
public void deleteReport(String uuid) {
|
||||
|
||||
System.out.println("Neuer Datenabruf");
|
||||
try {
|
||||
sqlHandler.executeUpdate("DELETE FROM Report WHERE ReportID = '"+ uuid + "';");
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.softwarerat.MySQL;
|
||||
|
||||
import de.mint.asyncmysqlpoolhandler.configservice.ConfigBuilder;
|
||||
import de.mint.asyncmysqlpoolhandler.configservice.ConfigPoolFramework;
|
||||
import de.mint.asyncmysqlpoolhandler.enumservice.EnumPoolFramework;
|
||||
import de.mint.asyncmysqlpoolhandler.mainservice.AsyncMySQLPoolHandler;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class SQLHandler {
|
||||
|
||||
private final AsyncMySQLPoolHandler MySQLPoolHandler;
|
||||
private final ConfigPoolFramework configPoolFramework = ConfigBuilder.getConfigBuilder().build();
|
||||
|
||||
public SQLHandler(String hostname, String user, String pw, String DB) {
|
||||
this.MySQLPoolHandler = new AsyncMySQLPoolHandler(hostname, user, pw, DB, EnumPoolFramework.HIKARICP, configPoolFramework);
|
||||
this.openConnection();
|
||||
}
|
||||
|
||||
private void openConnection() {
|
||||
this.MySQLPoolHandler.openPool();
|
||||
}
|
||||
|
||||
// Basic SQL Things
|
||||
protected ResultSet executeQuery(String sql) throws ExecutionException, InterruptedException {
|
||||
return this.MySQLPoolHandler.executeQueryAsync(sql).get();
|
||||
}
|
||||
|
||||
protected void executeUpdate(String sql) throws ExecutionException, InterruptedException {
|
||||
this.MySQLPoolHandler.executeUpdateAsync(sql).get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.softwarerat.Netty;
|
||||
|
||||
|
||||
//because of Client Server communication to the discord bot, netty will be the easiest Client for that.
|
||||
public class SyncDiscord {
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user