mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2025-01-29 22:51:21 +01:00
Changed all timestamp values utilized by the API to long types
This commit is contained in:
parent
3c82dc337a
commit
40b52fa321
@ -157,13 +157,13 @@ public class CoreProtectAPI extends Queue {
|
||||
boolean match = false;
|
||||
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
int unixTimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int offsetTime = unixTimestamp - offset;
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
long offsetTime = timestamp - offset;
|
||||
List<String[]> check = blockLookup(block, time);
|
||||
|
||||
for (String[] value : check) {
|
||||
ParseResult result = parseResult(value);
|
||||
if (user.equalsIgnoreCase(result.getPlayer()) && result.getActionId() == 1 && result.getTime() <= offsetTime) {
|
||||
if (user.equalsIgnoreCase(result.getPlayer()) && result.getActionId() == 1 && result.getTimestamp() <= offsetTime) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
@ -178,13 +178,13 @@ public class CoreProtectAPI extends Queue {
|
||||
boolean match = false;
|
||||
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
int unixTimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int offsetTime = unixTimestamp - offset;
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
long offsetTime = timestamp - offset;
|
||||
List<String[]> check = blockLookup(block, time);
|
||||
|
||||
for (String[] value : check) {
|
||||
ParseResult result = parseResult(value);
|
||||
if (user.equalsIgnoreCase(result.getPlayer()) && result.getActionId() == 0 && result.getTime() <= offsetTime) {
|
||||
if (user.equalsIgnoreCase(result.getPlayer()) && result.getActionId() == 0 && result.getTimestamp() <= offsetTime) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
@ -202,9 +202,9 @@ public class CoreProtectAPI extends Queue {
|
||||
if (Config.getGlobal().API_ENABLED && player != null && Config.getConfig(player.getWorld()).PLAYER_MESSAGES) {
|
||||
if (message != null) {
|
||||
if (message.length() > 0 && !message.startsWith("/")) {
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
|
||||
Queue.queuePlayerChat(player, message, time);
|
||||
Queue.queuePlayerChat(player, message, timestamp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -217,9 +217,9 @@ public class CoreProtectAPI extends Queue {
|
||||
if (Config.getGlobal().API_ENABLED && player != null && Config.getConfig(player.getWorld()).PLAYER_COMMANDS) {
|
||||
if (command != null) {
|
||||
if (command.length() > 0 && command.startsWith("/")) {
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
|
||||
Queue.queuePlayerCommand(player, command, time);
|
||||
Queue.queuePlayerCommand(player, command, timestamp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -430,8 +430,8 @@ public class CoreProtectAPI extends Queue {
|
||||
restrictUsers.add("#global");
|
||||
}
|
||||
|
||||
int unixTimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
int timePeriod = unixTimestamp - time;
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
long timePeriod = timestamp - time;
|
||||
|
||||
if (radius < 1) {
|
||||
radius = -1;
|
||||
|
@ -306,20 +306,20 @@ public class Queue {
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||
}
|
||||
|
||||
protected static void queuePlayerChat(Player player, String message, int time) {
|
||||
protected static void queuePlayerChat(Player player, String message, long timestamp) {
|
||||
int currentConsumer = Consumer.currentConsumer;
|
||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_CHAT, null, 0, null, 0, time, null });
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_CHAT, null, 0, null, 0, 0, null });
|
||||
Consumer.consumerStrings.get(currentConsumer).put(consumerId, message);
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null }, player.getLocation().clone());
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null }, new Object[] { timestamp, player.getLocation().clone() });
|
||||
}
|
||||
|
||||
protected static void queuePlayerCommand(Player player, String message, int time) {
|
||||
protected static void queuePlayerCommand(Player player, String message, long timestamp) {
|
||||
int currentConsumer = Consumer.currentConsumer;
|
||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_COMMAND, null, 0, null, 0, time, null });
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_COMMAND, null, 0, null, 0, 0, null });
|
||||
Consumer.consumerStrings.get(currentConsumer).put(consumerId, message);
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null }, player.getLocation().clone());
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null }, new Object[] { timestamp, player.getLocation().clone() });
|
||||
}
|
||||
|
||||
protected static void queuePlayerInteraction(String user, BlockState block) {
|
||||
|
@ -10,13 +10,14 @@ import net.coreprotect.database.logger.ChatLogger;
|
||||
|
||||
class PlayerChatProcess {
|
||||
|
||||
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object, int time, String user) {
|
||||
if (object instanceof Location) {
|
||||
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object[] object, String user) {
|
||||
if (object.length == 2 && object[1] instanceof Location) {
|
||||
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
||||
if (strings.get(id) != null) {
|
||||
String message = strings.get(id);
|
||||
Location location = (Location) object;
|
||||
ChatLogger.log(preparedStmt, batchCount, time, location, user, message);
|
||||
Long timestamp = (Long) object[0];
|
||||
Location location = (Location) object[1];
|
||||
ChatLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
|
||||
strings.remove(id);
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,14 @@ import net.coreprotect.database.logger.CommandLogger;
|
||||
|
||||
class PlayerCommandProcess {
|
||||
|
||||
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object, int time, String user) {
|
||||
if (object instanceof Location) {
|
||||
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object[] object, String user) {
|
||||
if (object.length == 2 && object[1] instanceof Location) {
|
||||
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
||||
if (strings.get(id) != null) {
|
||||
String message = strings.get(id);
|
||||
Location location = (Location) object;
|
||||
CommandLogger.log(preparedStmt, batchCount, time, location, user, message);
|
||||
Long timestamp = (Long) object[0];
|
||||
Location location = (Location) object[1];
|
||||
CommandLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
|
||||
strings.remove(id);
|
||||
}
|
||||
}
|
||||
|
@ -141,13 +141,13 @@ public class Process {
|
||||
for (int i = 0; i < consumerDataSize; i++) {
|
||||
Object[] data = consumerData.get(i);
|
||||
if (data != null) {
|
||||
int id = (Integer) data[0];
|
||||
int action = (Integer) data[1];
|
||||
int id = (int) data[0];
|
||||
int action = (int) data[1];
|
||||
Material blockType = (Material) data[2];
|
||||
int blockData = (Integer) data[3];
|
||||
Material replace_type = (Material) data[4];
|
||||
int replaceData = (Integer) data[5];
|
||||
int forceData = (Integer) data[6];
|
||||
int blockData = (int) data[3];
|
||||
Material replaceType = (Material) data[4];
|
||||
int replaceData = (int) data[5];
|
||||
int forceData = (int) data[6];
|
||||
|
||||
if (users.get(id) != null && consumerObject.get(id) != null) {
|
||||
String user = users.get(id)[0];
|
||||
@ -156,10 +156,10 @@ public class Process {
|
||||
try {
|
||||
switch (action) {
|
||||
case Process.BLOCK_BREAK:
|
||||
BlockBreakProcess.process(preparedStmtBlocks, preparedStmtSkulls, i, processId, id, blockType, blockData, replace_type, forceData, user, object, (String) data[7]);
|
||||
BlockBreakProcess.process(preparedStmtBlocks, preparedStmtSkulls, i, processId, id, blockType, blockData, replaceType, forceData, user, object, (String) data[7]);
|
||||
break;
|
||||
case Process.BLOCK_PLACE:
|
||||
BlockPlaceProcess.process(preparedStmtBlocks, preparedStmtSkulls, i, blockType, blockData, replace_type, replaceData, forceData, user, object, (String) data[7], (String) data[8]);
|
||||
BlockPlaceProcess.process(preparedStmtBlocks, preparedStmtSkulls, i, blockType, blockData, replaceType, replaceData, forceData, user, object, (String) data[7], (String) data[8]);
|
||||
break;
|
||||
case Process.SIGN_TEXT:
|
||||
SignTextProcess.process(preparedStmtSigns, i, processId, id, forceData, user, object, replaceData, blockData);
|
||||
@ -195,10 +195,10 @@ public class Process {
|
||||
SkullUpdateProcess.process(statement, object, forceData);
|
||||
break;
|
||||
case Process.PLAYER_CHAT:
|
||||
PlayerChatProcess.process(preparedStmtChat, i, processId, id, object, forceData, user);
|
||||
PlayerChatProcess.process(preparedStmtChat, i, processId, id, (Object[]) object, user);
|
||||
break;
|
||||
case Process.PLAYER_COMMAND:
|
||||
PlayerCommandProcess.process(preparedStmtCommand, i, processId, id, object, forceData, user);
|
||||
PlayerCommandProcess.process(preparedStmtCommand, i, processId, id, (Object[]) object, user);
|
||||
break;
|
||||
case Process.PLAYER_LOGIN:
|
||||
PlayerLoginProcess.process(connection, preparedStmtSession, i, processId, id, object, blockData, replaceData, forceData, user);
|
||||
|
@ -99,7 +99,7 @@ public class Lookup extends Queue {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public static List<String[]> performLookup(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 List<String[]> performLookup(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) {
|
||||
List<String[]> newList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
@ -113,7 +113,7 @@ public class Lookup extends Queue {
|
||||
return newList;
|
||||
}
|
||||
|
||||
static List<Object[]> performLookupRaw(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, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
static List<Object[]> performLookupRaw(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, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
List<Object[]> list = new ArrayList<>();
|
||||
List<Integer> invalidRollbackActions = new ArrayList<>();
|
||||
invalidRollbackActions.add(2);
|
||||
@ -256,7 +256,7 @@ public class Lookup extends Queue {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<String[]> performPartialLookup(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, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
public static List<String[]> performPartialLookup(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, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
List<String[]> newList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
@ -270,7 +270,7 @@ public class Lookup extends Queue {
|
||||
return newList;
|
||||
}
|
||||
|
||||
private static ResultSet rawLookupResultSet(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, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup, boolean count) {
|
||||
private static ResultSet rawLookupResultSet(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, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup, boolean count) {
|
||||
ResultSet results = null;
|
||||
|
||||
try {
|
||||
|
@ -87,7 +87,7 @@ import net.coreprotect.utility.Util;
|
||||
|
||||
public class Rollback extends Queue {
|
||||
|
||||
public static List<String[]> performRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, int checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType, final int preview) {
|
||||
public static List<String[]> performRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType, final int preview) {
|
||||
List<String[]> list = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
@ -15,7 +15,7 @@ public class ChatLogger {
|
||||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, int time, Location location, String user, String message) {
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, long time, Location location, String user, String message) {
|
||||
try {
|
||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||
return;
|
||||
|
@ -15,7 +15,7 @@ public class CommandLogger {
|
||||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, int time, Location location, String user, String message) {
|
||||
public static void log(PreparedStatement preparedStmt, int batchCount, long time, Location location, String user, String message) {
|
||||
try {
|
||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||
return;
|
||||
|
@ -8,9 +8,9 @@ public class ChatStatement {
|
||||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int user, int wid, int x, int y, int z, String message) {
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, long time, int user, int wid, int x, int y, int z, String message) {
|
||||
try {
|
||||
preparedStmt.setInt(1, time);
|
||||
preparedStmt.setLong(1, time);
|
||||
preparedStmt.setInt(2, user);
|
||||
preparedStmt.setInt(3, wid);
|
||||
preparedStmt.setInt(4, x);
|
||||
|
@ -8,9 +8,9 @@ public class CommandStatement {
|
||||
throw new IllegalStateException("Database class");
|
||||
}
|
||||
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int user, int wid, int x, int y, int z, String message) {
|
||||
public static void insert(PreparedStatement preparedStmt, int batchCount, long time, int user, int wid, int x, int y, int z, String message) {
|
||||
try {
|
||||
preparedStmt.setInt(1, time);
|
||||
preparedStmt.setLong(1, time);
|
||||
preparedStmt.setInt(2, user);
|
||||
preparedStmt.setInt(3, wid);
|
||||
preparedStmt.setInt(4, x);
|
||||
|
@ -20,8 +20,8 @@ public final class PlayerChatListener extends Queue implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!message.startsWith("/") && Config.getConfig(player.getWorld()).PLAYER_MESSAGES) {
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
Queue.queuePlayerChat(player, message, time);
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
Queue.queuePlayerChat(player, message, timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ public final class PlayerCommandListener extends Queue implements Listener {
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (Config.getConfig(player.getWorld()).PLAYER_COMMANDS) {
|
||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||
Queue.queuePlayerCommand(player, event.getMessage(), time);
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
Queue.queuePlayerCommand(player, event.getMessage(), timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user