mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2025-03-02 04:01:25 +01:00
Changed additional timestamp values to long types
This commit is contained in:
parent
08aeb5d5aa
commit
d7ee5257dd
@ -11,14 +11,13 @@ import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class ApplyCommand {
|
||||
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
||||
try {
|
||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||
int time = (Integer) list.get(0);
|
||||
long time = (Long) list.get(0);
|
||||
args = (String[]) list.get(1);
|
||||
Location location = (Location) list.get(2);
|
||||
boolean valid = false;
|
||||
|
@ -11,14 +11,13 @@ import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class CancelCommand {
|
||||
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
||||
try {
|
||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||
int time = (Integer) list.get(0);
|
||||
long time = (Long) list.get(0);
|
||||
args = (String[]) list.get(1);
|
||||
Location location = (Location) list.get(2);
|
||||
boolean valid = false;
|
||||
|
@ -691,9 +691,9 @@ public class CommandHandler implements CommandExecutor {
|
||||
return restricted;
|
||||
}
|
||||
|
||||
protected static int parseTime(String[] inputArguments) {
|
||||
protected static long parseTime(String[] inputArguments) {
|
||||
String[] argumentArray = inputArguments.clone();
|
||||
int time = 0;
|
||||
long time = 0;
|
||||
int count = 0;
|
||||
int next = 0;
|
||||
double w = 0;
|
||||
@ -754,7 +754,7 @@ public class CommandHandler implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
double rs = ((w * 7 * 24 * 60 * 60) + (d * 24 * 60 * 60) + (h * 60 * 60) + (m * 60) + s);
|
||||
time = (int) rs;
|
||||
time = (long) rs;
|
||||
next = 0;
|
||||
}
|
||||
else {
|
||||
@ -763,6 +763,7 @@ public class CommandHandler implements CommandExecutor {
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class InspectCommand {
|
||||
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
||||
|
@ -51,7 +51,7 @@ public class LookupCommand {
|
||||
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
|
||||
String ts = CommandHandler.parseTimeString(args);
|
||||
int rbseconds = CommandHandler.parseTime(args);
|
||||
long rbseconds = CommandHandler.parseTime(args);
|
||||
int argWid = CommandHandler.parseWorld(args, true, true);
|
||||
int parseRows = CommandHandler.parseRows(args);
|
||||
boolean count = CommandHandler.parseCount(args);
|
||||
@ -554,7 +554,7 @@ public class LookupCommand {
|
||||
c++;
|
||||
}
|
||||
|
||||
int cs = -1;
|
||||
long cs = -1;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
@ -567,7 +567,7 @@ public class LookupCommand {
|
||||
y = Integer.parseInt(data[1]);
|
||||
z = Integer.parseInt(data[2]);
|
||||
wid = Integer.parseInt(data[3]);
|
||||
cs = Integer.parseInt(data[4]);
|
||||
cs = Long.parseLong(data[4]);
|
||||
// arg_radius = Integer.parseInt(data[5]);
|
||||
argNoisy = Integer.parseInt(data[5]);
|
||||
argExcluded = Integer.parseInt(data[6]);
|
||||
@ -640,7 +640,7 @@ public class LookupCommand {
|
||||
}
|
||||
|
||||
final List<String> rollbackusers2 = rollbackusers;
|
||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
long unixtimestamp = (System.currentTimeMillis() / 1000L);
|
||||
if (cs == -1) {
|
||||
if (rbseconds <= 0) {
|
||||
cs = 0;
|
||||
@ -649,7 +649,7 @@ public class LookupCommand {
|
||||
cs = unixtimestamp - rbseconds;
|
||||
}
|
||||
}
|
||||
final int stime = cs;
|
||||
final long stime = cs;
|
||||
final Integer[] radius = argRadius;
|
||||
|
||||
try {
|
||||
|
@ -1,7 +1,10 @@
|
||||
package net.coreprotect.command;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -28,7 +31,7 @@ public class PurgeCommand extends Consumer {
|
||||
int resultc = args.length;
|
||||
Location location = CommandHandler.parseLocation(player, args);
|
||||
final Integer[] argRadius = CommandHandler.parseRadius(args, player, location);
|
||||
final int seconds = CommandHandler.parseTime(args);
|
||||
final long seconds = CommandHandler.parseTime(args);
|
||||
final int argWid = CommandHandler.parseWorld(args, false, false);
|
||||
final List<Integer> argAction = CommandHandler.parseAction(args);
|
||||
final List<Integer> supportedActions = Arrays.asList();
|
||||
@ -92,8 +95,8 @@ public class PurgeCommand extends Consumer {
|
||||
@Override
|
||||
public void run() {
|
||||
try (Connection connection = Database.getConnection(false, 500)) {
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int ptime = timestamp - seconds;
|
||||
long timestamp = (System.currentTimeMillis() / 1000L);
|
||||
long ptime = timestamp - seconds;
|
||||
long removed = 0;
|
||||
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
|
@ -31,7 +31,7 @@ import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class RollbackRestoreCommand {
|
||||
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args, Location argLocation, int forceSeconds) {
|
||||
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args, Location argLocation, long forceSeconds) {
|
||||
Location lo = (argLocation != null ? argLocation : CommandHandler.parseLocation(player, args));
|
||||
List<String> argUuids = new ArrayList<>();
|
||||
List<String> argUsers = CommandHandler.parseUsers(args);
|
||||
@ -42,7 +42,7 @@ public class RollbackRestoreCommand {
|
||||
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
|
||||
String ts = CommandHandler.parseTimeString(args);
|
||||
int rbSeconds = CommandHandler.parseTime(args);
|
||||
long rbSeconds = CommandHandler.parseTime(args);
|
||||
int argWid = CommandHandler.parseWorld(args, true, true);
|
||||
boolean count = CommandHandler.parseCount(args);
|
||||
boolean worldedit = CommandHandler.parseWorldEdit(args);
|
||||
@ -284,12 +284,12 @@ public class RollbackRestoreCommand {
|
||||
|
||||
final List<String> rollbackusers2 = rollbackusers;
|
||||
if (rbSeconds > 0) {
|
||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int seconds = unixtimestamp - rbSeconds;
|
||||
long unixtimestamp = (System.currentTimeMillis() / 1000L);
|
||||
long seconds = unixtimestamp - rbSeconds;
|
||||
if (forceSeconds > 0) {
|
||||
seconds = forceSeconds;
|
||||
}
|
||||
final int stime = seconds;
|
||||
final long stime = seconds;
|
||||
final Integer[] radius = argRadius;
|
||||
try {
|
||||
final CommandSender player2 = player;
|
||||
|
@ -11,14 +11,13 @@ import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class UndoCommand {
|
||||
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
||||
try {
|
||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||
int time = (Integer) list.get(0);
|
||||
long time = (Long) list.get(0);
|
||||
args = (String[]) list.get(1);
|
||||
Location location = (Location) list.get(2);
|
||||
for (String arg : args) {
|
||||
|
@ -14,8 +14,6 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -23,8 +21,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.consumer.Consumer;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.Database;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
@ -207,7 +207,8 @@ public class ConfigHandler extends Queue {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setJdbcUrl("jdbc:mysql://" + ConfigHandler.host + ":" + ConfigHandler.port + "/" + ConfigHandler.database);
|
||||
config.setUsername(ConfigHandler.username);
|
||||
@ -395,7 +396,8 @@ public class ConfigHandler extends Queue {
|
||||
ConfigHandler.loadConfig(); // Load (or create) the configuration file.
|
||||
ConfigHandler.loadDatabase(); // Initialize MySQL and create tables if necessary.
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package net.coreprotect.consumer.process;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
@ -24,7 +24,7 @@ import net.coreprotect.utility.Util;
|
||||
|
||||
public class ContainerRollback extends Queue {
|
||||
|
||||
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, int checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
|
||||
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class Lookup extends Queue {
|
||||
return newList;
|
||||
}
|
||||
|
||||
public static int countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, int checkTime, boolean restrictWorld, boolean lookup) {
|
||||
public static int countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup) {
|
||||
int rows = 0;
|
||||
|
||||
try {
|
||||
|
@ -12,7 +12,6 @@ import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
@ -45,9 +44,9 @@ public class BlockLookup {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
long time = (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||
int checkTime = 0;
|
||||
long checkTime = 0;
|
||||
int count = 0;
|
||||
int rowMax = page * limit;
|
||||
int page_start = rowMax - limit;
|
||||
@ -75,7 +74,7 @@ public class BlockLookup {
|
||||
int resultAction = results.getInt("action");
|
||||
int resultType = results.getInt("type");
|
||||
int resultData = results.getInt("data");
|
||||
int resultTime = results.getInt("time");
|
||||
long resultTime = results.getLong("time");
|
||||
int resultRolledBack = results.getInt("rolled_back");
|
||||
|
||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||
|
@ -12,7 +12,6 @@ import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
@ -48,7 +47,7 @@ public class ChestTransactionLookup {
|
||||
int x2 = (int) Math.ceil(l.getX());
|
||||
int y2 = (int) Math.ceil(l.getY());
|
||||
int z2 = (int) Math.ceil(l.getZ());
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
long time = (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(l.getWorld().getName());
|
||||
int count = 0;
|
||||
int rowMax = page * limit;
|
||||
@ -79,7 +78,7 @@ public class ChestTransactionLookup {
|
||||
int resultAction = results.getInt("action");
|
||||
int resultType = results.getInt("type");
|
||||
int resultData = results.getInt("data");
|
||||
int resultTime = results.getInt("time");
|
||||
long resultTime = results.getLong("time");
|
||||
int resultAmount = results.getInt("amount");
|
||||
int resultRolledBack = results.getInt("rolled_back");
|
||||
|
||||
|
@ -12,7 +12,6 @@ import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.database.statement.UserStatement;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.language.Selector;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
@ -73,7 +72,7 @@ public class InteractionLookup {
|
||||
int resultAction = results.getInt("action");
|
||||
int resultType = results.getInt("type");
|
||||
int resultData = results.getInt("data");
|
||||
int resultTime = results.getInt("time");
|
||||
long resultTime = results.getLong("time");
|
||||
int resultRolledBack = results.getInt("rolled_back");
|
||||
|
||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||
|
@ -44,7 +44,7 @@ public class SignMessageLookup {
|
||||
int x = l.getBlockX();
|
||||
int y = l.getBlockY();
|
||||
int z = l.getBlockZ();
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
long time = (System.currentTimeMillis() / 1000L);
|
||||
int worldId = Util.getWorldId(l.getWorld().getName());
|
||||
int count = 0;
|
||||
int rowMax = page * limit;
|
||||
@ -64,7 +64,7 @@ public class SignMessageLookup {
|
||||
results = statement.executeQuery(query);
|
||||
|
||||
while (results.next()) {
|
||||
int resultTime = results.getInt("time");
|
||||
long resultTime = results.getLong("time");
|
||||
int resultUserId = results.getInt("user");
|
||||
String line1 = results.getString("line_1");
|
||||
String line2 = results.getString("line_2");
|
||||
|
@ -196,9 +196,9 @@ public class Util extends Queue {
|
||||
return message.append(Color.WHITE + backArrow + Phrase.build(Phrase.LOOKUP_PAGE, page + "/" + totalPages) + nextArrow).toString();
|
||||
}
|
||||
|
||||
public static String getTimeSince(int logTime, int currentTime, boolean component) {
|
||||
public static String getTimeSince(long resultTime, long currentTime, boolean component) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
double timeSince = currentTime - (logTime + 0.00);
|
||||
double timeSince = currentTime - (resultTime + 0.00);
|
||||
|
||||
// minutes
|
||||
timeSince = timeSince / 60;
|
||||
@ -221,7 +221,7 @@ public class Util extends Queue {
|
||||
}
|
||||
|
||||
if (component) {
|
||||
Date logDate = new Date(logTime * 1000L);
|
||||
Date logDate = new Date(resultTime * 1000L);
|
||||
String formattedTimestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").format(logDate);
|
||||
|
||||
return Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP + "|" + Color.GREY + formattedTimestamp + "|" + Color.GREY + message.toString() + Chat.COMPONENT_TAG_CLOSE;
|
||||
|
Loading…
Reference in New Issue
Block a user