Split up utility class

This commit is contained in:
Intelli 2025-02-25 19:30:28 -07:00
parent 828af8443f
commit e2c2505b2b
97 changed files with 2369 additions and 2104 deletions

View file

@ -20,7 +20,7 @@ import net.coreprotect.database.Database;
import net.coreprotect.language.Phrase;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.VersionUtils;
public class Patch {
@ -36,7 +36,7 @@ public class Patch {
String result = "";
if (firstVersion != null) {
if ((firstVersion[0] + "." + firstVersion[1] + "." + firstVersion[2]).equals("0.0.0")) {
result = Util.getPluginVersion();
result = VersionUtils.getPluginVersion();
}
else {
result = firstVersion[1] + "." + firstVersion[2];
@ -105,7 +105,7 @@ public class Patch {
if (className.startsWith("net/coreprotect/patch/script/__") && className.endsWith(".class")) {
Class<?> patchClass = Class.forName(className.substring(0, className.length() - 6).replaceAll("/", "."));
String patchVersion = getClassVersion(patchClass.getName());
if (!Util.newVersion(Util.getInternalPluginVersion(), patchVersion)) {
if (!VersionUtils.newVersion(VersionUtils.getInternalPluginVersion(), patchVersion)) {
patches.add(patchVersion);
}
}
@ -114,10 +114,10 @@ public class Patch {
}
Collections.sort(patches, (o1, o2) -> {
if (Util.newVersion(o1, o2)) {
if (VersionUtils.newVersion(o1, o2)) {
return -1;
}
else if (Util.newVersion(o2, o1)) {
else if (VersionUtils.newVersion(o2, o1)) {
return 1;
}
return 0;
@ -171,7 +171,7 @@ public class Patch {
int patchRevision = Integer.parseInt(thePatch[2]);
Integer[] patchVersion = new Integer[] { patchMajor, patchMinor, patchRevision };
boolean performPatch = Util.newVersion(newVersion, patchVersion);
boolean performPatch = VersionUtils.newVersion(newVersion, patchVersion);
if (performPatch) {
boolean success = false;
try {
@ -231,14 +231,14 @@ public class Patch {
public static boolean versionCheck(Statement statement) {
try {
Integer[] currentVersion = Util.getInternalPluginVersion();
Integer[] currentVersion = VersionUtils.getInternalPluginVersion();
firstVersion = getDatabaseVersion(statement.getConnection(), false);
Integer[] lastVersion = getDatabaseVersion(statement.getConnection(), true);
boolean newVersion = Util.newVersion(lastVersion, currentVersion);
boolean newVersion = VersionUtils.newVersion(lastVersion, currentVersion);
if (newVersion && lastVersion[0] > 0 && !ConfigHandler.converterRunning) {
Integer[] minimumVersion = new Integer[] { 2, 0, 0 };
if (Util.newVersion(lastVersion, minimumVersion)) {
if (VersionUtils.newVersion(lastVersion, minimumVersion)) {
Chat.sendConsoleMessage("§c[CoreProtect] " + Phrase.build(Phrase.PATCH_OUTDATED_1, "v" + minimumVersion[0] + "." + minimumVersion[1] + "." + minimumVersion[2]));
Chat.sendConsoleMessage("§c[CoreProtect] " + Phrase.build(Phrase.PATCH_OUTDATED_2));
return false;
@ -312,7 +312,7 @@ public class Patch {
else {
currentVersion[2] = 0;
lastVersion[2] = 0;
if (Util.newVersion(currentVersion, lastVersion)) {
if (VersionUtils.newVersion(currentVersion, lastVersion)) {
Chat.sendConsoleMessage(Color.RED + "[CoreProtect] " + Phrase.build(Phrase.VERSION_REQUIRED, "CoreProtect", "v" + lastVersion[1] + "." + lastVersion[2]));
return false;
}

View file

@ -16,6 +16,8 @@ import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.Database;
import net.coreprotect.patch.Patch;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.BlockUtils;
import net.coreprotect.utility.MaterialUtils;
public class __2_18_0 {
@ -88,7 +90,7 @@ public class __2_18_0 {
}
Material material = Material.matchMaterial(materialName, legacy);
int newID = Util.getBlockId(material);
int newID = MaterialUtils.getBlockId(material);
preparedBlockStatement.setInt(1, oldID);
ResultSet blockResults = preparedBlockStatement.executeQuery();
@ -101,7 +103,7 @@ public class __2_18_0 {
int validatedID = newID;
if (validatedMaterial == Material.WHITE_WOOL) {
validatedMaterial = getWoolColor(blockData);
validatedID = Util.getBlockId(validatedMaterial);
validatedID = MaterialUtils.getBlockId(validatedMaterial);
}
if (blockBlockData == null && validatedMaterial.isBlock()) {
@ -123,7 +125,7 @@ public class __2_18_0 {
BlockFace newRotation = getLegacyRotation(blockData);
rotatable.setRotation(newRotation);
}
blockBlockData = Util.stringToByteData(newBlockData.getAsString(), validatedID);
blockBlockData = BlockUtils.stringToByteData(newBlockData.getAsString(), validatedID);
}
}

View file

@ -16,6 +16,7 @@ import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.patch.Patch;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.MaterialUtils;
import net.coreprotect.utility.Util;
public class __2_19_0 {
@ -118,7 +119,7 @@ public class __2_19_0 {
List<Integer> signList = new ArrayList<>();
for (Material material : Tag.SIGNS.getValues()) {
int id = Util.getBlockId(material.name(), false);
int id = MaterialUtils.getBlockId(material.name(), false);
if (id > -1) {
signList.add(id);
}

View file

@ -13,6 +13,7 @@ import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.patch.Patch;
import net.coreprotect.utility.Chat;
import net.coreprotect.utility.EntityUtils;
import net.coreprotect.utility.Util;
public class __2_20_0 {
@ -90,7 +91,7 @@ public class __2_20_0 {
break;
}
preparedStatementUpdate.setInt(1, Util.getSpawnerType(entityType));
preparedStatementUpdate.setInt(1, EntityUtils.getSpawnerType(entityType));
preparedStatementUpdate.setInt(2, resultSet.getInt("rowid"));
preparedStatementUpdate.executeUpdate();
}