com.github.DeadSilenceIV
diff --git a/src/main/java/net/coreprotect/CoreProtectAPI.java b/src/main/java/net/coreprotect/CoreProtectAPI.java
index c6c212b..1013e89 100755
--- a/src/main/java/net/coreprotect/CoreProtectAPI.java
+++ b/src/main/java/net/coreprotect/CoreProtectAPI.java
@@ -5,7 +5,6 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import org.bukkit.Bukkit;
@@ -21,6 +20,7 @@ import org.bukkit.entity.Player;
import net.coreprotect.api.BlockAPI;
import net.coreprotect.api.QueueLookup;
import net.coreprotect.api.SessionLookup;
+import net.coreprotect.api.result.ParseResult;
import net.coreprotect.config.Config;
import net.coreprotect.consumer.Queue;
import net.coreprotect.database.Database;
@@ -29,129 +29,28 @@ import net.coreprotect.database.rollback.Rollback;
import net.coreprotect.language.Phrase;
import net.coreprotect.listener.player.InventoryChangeListener;
import net.coreprotect.utility.Chat;
-import net.coreprotect.utility.EntityUtils;
import net.coreprotect.utility.MaterialUtils;
-import net.coreprotect.utility.StringUtils;
-import net.coreprotect.utility.WorldUtils;
+/**
+ * The main API class for CoreProtect.
+ *
+ * This class provides methods for interacting with the CoreProtect database,
+ * including lookups, rollbacks, and logging operations.
+ */
public class CoreProtectAPI extends Queue {
- public class ParseResult {
- String[] parse;
-
- public ParseResult(String[] data) {
- parse = data;
- }
-
- public int getActionId() {
- return Integer.parseInt(parse[7]);
- }
-
- public String getActionString() {
- int actionID = Integer.parseInt(parse[7]);
- if (parse.length < 13 && Integer.parseInt(parse[6]) == SessionLookup.ID) {
- switch (actionID) {
- case 0:
- return "logout";
- case 1:
- return "login";
- default:
- return "unknown";
- }
- }
-
- String result = "unknown";
- if (actionID == 0) {
- result = "break";
- }
- else if (actionID == 1) {
- result = "place";
- }
- else if (actionID == 2) {
- result = "click";
- }
- else if (actionID == 3) {
- result = "kill";
- }
-
- return result;
- }
-
- @Deprecated
- public int getData() {
- return Integer.parseInt(parse[6]);
- }
-
- public String getPlayer() {
- return parse[1];
- }
-
- @Deprecated
- public int getTime() {
- return Integer.parseInt(parse[0]);
- }
-
- public long getTimestamp() {
- return Long.parseLong(parse[0]) * 1000L;
- }
-
- public Material getType() {
- if (parse.length < 13) {
- return null;
- }
-
- int actionID = this.getActionId();
- int type = Integer.parseInt(parse[5]);
- String typeName;
-
- if (actionID == 3) {
- typeName = EntityUtils.getEntityType(type).name();
- }
- else {
- typeName = MaterialUtils.getType(type).name().toLowerCase(Locale.ROOT);
- typeName = StringUtils.nameFilter(typeName, this.getData());
- }
-
- return MaterialUtils.getType(typeName);
- }
-
- public BlockData getBlockData() {
- if (parse.length < 13) {
- return null;
- }
-
- String blockData = parse[12];
- if (blockData == null || blockData.length() == 0) {
- return getType().createBlockData();
- }
- return Bukkit.getServer().createBlockData(blockData);
- }
-
- public int getX() {
- return Integer.parseInt(parse[2]);
- }
-
- public int getY() {
- return Integer.parseInt(parse[3]);
- }
-
- public int getZ() {
- return Integer.parseInt(parse[4]);
- }
-
- public boolean isRolledBack() {
- if (parse.length < 13) {
- return false;
- }
-
- return (Integer.parseInt(parse[8]) == 1 || Integer.parseInt(parse[8]) == 3);
- }
-
- public String worldName() {
- return WorldUtils.getWorldName(Integer.parseInt(parse.length < 13 ? parse[5] : parse[9]));
- }
- }
+ /**
+ * Current version of the API
+ */
+ private static final int API_VERSION = 10;
+ /**
+ * Converts a list of objects to a map for internal processing
+ *
+ * @param list
+ * List of objects to convert
+ * @return Map with objects as keys and Boolean false as values
+ */
private static Map