Fix deprecations
This commit is contained in:
@@ -126,7 +126,7 @@ public class CommandsExecutor {
|
|||||||
|
|
||||||
private void addCommandInfo(String name, Class<? extends Command> commandClass) {
|
private void addCommandInfo(String name, Class<? extends Command> commandClass) {
|
||||||
try {
|
try {
|
||||||
levelCommandsCursor.getRight().add(commandClass.newInstance().getDescription());
|
levelCommandsCursor.getRight().add(commandClass.getDeclaredConstructor().newInstance().getDescription());
|
||||||
levelCommandsCursor.getLeft().add(name);
|
levelCommandsCursor.getLeft().add(name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -161,14 +161,12 @@ public class CommandsExecutor {
|
|||||||
addCommandInfo(commandName, commandClass);
|
addCommandInfo(commandName, commandClass);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Command commandInstance = commandClass.newInstance(); // thanks Halcyon for noticing commands getting reinstanced every call
|
Command commandInstance = commandClass.getDeclaredConstructor().newInstance(); // thanks Halcyon for noticing commands getting reinstanced every call
|
||||||
commandInstance.setRank(rank);
|
commandInstance.setRank(rank);
|
||||||
|
|
||||||
registeredCommands.put(commandName, commandInstance);
|
registeredCommands.put(commandName, commandInstance);
|
||||||
} catch (InstantiationException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.warn("Failed to create command instance", e);
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ import tools.PacketCreator;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.time.OffsetDateTime;
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@@ -82,11 +81,9 @@ public final class ReportHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addReport(int reporterid, int victimid, int reason, String description, String chatlog) {
|
public void addReport(int reporterid, int victimid, int reason, String description, String chatlog) {
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
Timestamp currentTimestamp = new java.sql.Timestamp(calendar.getTime().getTime());
|
|
||||||
try (Connection con = DatabaseConnection.getConnection();
|
try (Connection con = DatabaseConnection.getConnection();
|
||||||
PreparedStatement ps = con.prepareStatement("INSERT INTO reports (`reporttime`, `reporterid`, `victimid`, `reason`, `chatlog`, `description`) VALUES (?, ?, ?, ?, ?, ?)")) {
|
PreparedStatement ps = con.prepareStatement("INSERT INTO reports (`reporttime`, `reporterid`, `victimid`, `reason`, `chatlog`, `description`) VALUES (?, ?, ?, ?, ?, ?)")) {
|
||||||
ps.setString(1, currentTimestamp.toGMTString());
|
ps.setString(1, OffsetDateTime.now().toString());
|
||||||
ps.setInt(2, reporterid);
|
ps.setInt(2, reporterid);
|
||||||
ps.setInt(3, victimid);
|
ps.setInt(3, victimid);
|
||||||
ps.setInt(4, reason);
|
ps.setInt(4, reason);
|
||||||
|
|||||||
Reference in New Issue
Block a user