Adding CheckedSchematic - DBIntegration
Dieser Commit ist enthalten in:
Ursprung
a0528444eb
Commit
c3704ce6e8
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
target
|
@ -15,8 +15,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class SchematicSystem extends JavaPlugin {
|
public class SchematicSystem extends JavaPlugin {
|
||||||
|
|
||||||
public static String SCHEM_DIR = "/home/netuser/schematics/";
|
public static final String SCHEM_DIR = "/home/netuser/schematics/";
|
||||||
public static String PREFIX = "§8[§3Schematic§8] §7";
|
public static final String PREFIX = "§6Schematic§8» §7";
|
||||||
|
|
||||||
private static SchematicSystem instance;
|
private static SchematicSystem instance;
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ public class PlayerJoinListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < files.length; i++) {
|
for(int i = 0; i < files.length; i++) {
|
||||||
if(!schematicNames.contains(files[i].getName().substring(0, files[i].getName().lastIndexOf(".")))) {
|
if(!schematicNames.contains(files[i].getName().substring(0, files[i].getName().lastIndexOf('.')))) {
|
||||||
String fileName = files[i].getName();
|
String fileName = files[i].getName();
|
||||||
Schematic schematic = new Schematic(fileName.substring(0, fileName.lastIndexOf(".")), player.getUniqueId(), "", SchematicType.normal);
|
new Schematic(fileName.substring(0, fileName.lastIndexOf('.')), player.getUniqueId(), "", SchematicType.normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
99
src/de/warking/schematicsystem/utils/CheckedSchematic.java
Normale Datei
99
src/de/warking/schematicsystem/utils/CheckedSchematic.java
Normale Datei
@ -0,0 +1,99 @@
|
|||||||
|
package de.warking.schematicsystem.utils;
|
||||||
|
|
||||||
|
import de.warking.hunjy.MySQL.MySQL;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static de.warking.hunjy.Core.sql;
|
||||||
|
|
||||||
|
public class CheckedSchematic {
|
||||||
|
|
||||||
|
private final String SchemName;
|
||||||
|
private final int SchemOwner;
|
||||||
|
private final int Validator;
|
||||||
|
private final Timestamp StartTime;
|
||||||
|
private final Timestamp EndTime;
|
||||||
|
private final String DeclineReason;
|
||||||
|
|
||||||
|
private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){
|
||||||
|
SchemName = MySQL.disarmString(schemName);
|
||||||
|
SchemOwner = schemOwner;
|
||||||
|
Validator = validator;
|
||||||
|
StartTime = startTime;
|
||||||
|
EndTime = endTime;
|
||||||
|
DeclineReason = MySQL.disarmString(declineReason);
|
||||||
|
if(insertDB)
|
||||||
|
insertDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
|
||||||
|
this(schemName, schemOwner, validator, startTime, endTime, declineReason, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckedSchematic(String schemName, int schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
|
||||||
|
this(schemName, schemOwner, WarkingUser.get(validator).getId(), startTime, endTime, declineReason, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckedSchematic(String schemName, UUID schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
|
||||||
|
this(schemName, WarkingUser.get(schemOwner).getId(), WarkingUser.get(validator).getId(), startTime, endTime, declineReason, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertDB(){
|
||||||
|
sql.update("INSERT INTO CheckedSchematic" +
|
||||||
|
" (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason)" +
|
||||||
|
" VALUES" +
|
||||||
|
" ('"+ SchemName + "', '" + SchemOwner + "', '" + Validator + "', '" + StartTime.toString() + "', '" + EndTime.toString() + "', '" + DeclineReason + "')");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){
|
||||||
|
return getLastDelined(WarkingUser.get(schemOwner).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<CheckedSchematic> getLastDelined(int schemOwner){
|
||||||
|
List<CheckedSchematic> lastDeclined = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
ResultSet lastRS = sql.select("SELECT * FROM CheckedSchematic WHERE SchemOwner = '" + schemOwner + "' AND DeclineReason != '' ORDER BY EndTime DESC");
|
||||||
|
while(lastRS.next()){
|
||||||
|
String schemName = lastRS.getString("SchemName");
|
||||||
|
int validator = lastRS.getInt("Validator");
|
||||||
|
Timestamp startTime = lastRS.getTimestamp("StartTime");
|
||||||
|
Timestamp endTime = lastRS.getTimestamp("EndTime");
|
||||||
|
String declineReason = lastRS.getString("DeclineReason");
|
||||||
|
lastDeclined.add(new CheckedSchematic(schemName, schemOwner, validator, startTime, endTime, declineReason, false));
|
||||||
|
}
|
||||||
|
}catch(SQLException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return lastDeclined;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSchemName() {
|
||||||
|
return SchemName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSchemOwner() {
|
||||||
|
return SchemOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValidator() {
|
||||||
|
return Validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getStartTime() {
|
||||||
|
return StartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getEndTime() {
|
||||||
|
return EndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeclineReason() {
|
||||||
|
return DeclineReason;
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren