Fix deprecations
This commit is contained in:
@@ -126,7 +126,7 @@ public class CommandsExecutor {
|
||||
|
||||
private void addCommandInfo(String name, Class<? extends Command> commandClass) {
|
||||
try {
|
||||
levelCommandsCursor.getRight().add(commandClass.newInstance().getDescription());
|
||||
levelCommandsCursor.getRight().add(commandClass.getDeclaredConstructor().newInstance().getDescription());
|
||||
levelCommandsCursor.getLeft().add(name);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -161,14 +161,12 @@ public class CommandsExecutor {
|
||||
addCommandInfo(commandName, commandClass);
|
||||
|
||||
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);
|
||||
|
||||
registeredCommands.put(commandName, commandInstance);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to create command instance", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ import tools.PacketCreator;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/*
|
||||
*
|
||||
@@ -82,11 +81,9 @@ public final class ReportHandler extends AbstractPacketHandler {
|
||||
}
|
||||
|
||||
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();
|
||||
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(3, victimid);
|
||||
ps.setInt(4, reason);
|
||||
|
||||
Reference in New Issue
Block a user