TCheckpoint

This commit is contained in:
tyuXX 2025-06-29 14:43:19 +03:00
parent c5b686aeb5
commit 9ae9bf64e7
54 changed files with 252 additions and 118 deletions

View file

@ -28,7 +28,7 @@ public class ConfigRequirements {
public static boolean isCommandEnabled(String command) {
return switch (CommandRequirements.getOrDefault(command, "default")) {
case "market" -> getConfigValue(ConfigKey.MODULE_MARKET,Boolean.class);
case "market" -> getConfigValue(ConfigKey.MODULE_MARKET, Boolean.class);
case "leaderboard" -> getConfigValue(ConfigKey.MODULE_LEADERBOARD, Boolean.class);
case "job" -> getConfigValue(ConfigKey.MODULE_JOBS, Boolean.class);
case "stats" -> getConfigValue(ConfigKey.MODULE_LEVELING, Boolean.class);

View file

@ -4,7 +4,8 @@ public enum FactionRank {
LEADER("Leader"),
OFFICER("Officer"),
MEMBER("Member"),
RECRUIT("Recruit");
RECRUIT("Recruit"),
NONE("Not a member");
private final String displayName;

View file

@ -0,0 +1,13 @@
package org.gsdistance.grimmsServer.Data;
public enum PlayerRank {
DEFAULT("Default"),
VIP("Vip"),
MVP("MVP"),
MODERATOR("Moderator"),
ADMIN("Admin"),
OWNER("Owner"),;
PlayerRank(String name) {}
}

View file

@ -26,7 +26,8 @@ public class PluginDataStorage {
return readFile.exists();
}
public void saveData(Object object, Type objectType, String fileName, String addedPath) {
@SuppressWarnings("ResultOfMethodCallIgnored")
public <T> void saveData(T object, Class<T> objectType, String fileName, String addedPath) {
File writeFolder = new File(plugin.getDataFolder().getPath() + File.separatorChar + addedPath);
File writeFile = new File(writeFolder.getPath() + File.separatorChar + fileName);
if (!writeFolder.exists()) {
@ -62,17 +63,19 @@ public class PluginDataStorage {
}
}
public Object[] retrieveAllData(Type objectType, String addedPath) {
@SuppressWarnings("unchecked")
public <T> T[] retrieveAllData(Class<T> objectType, String addedPath) {
File readFolder = new File(plugin.getDataFolder().getPath() + File.separatorChar + addedPath);
if (!readFolder.exists()) {
return null;
}
File[] files = readFolder.listFiles();
if (files == null || files.length == 0) {
return new Object[0];
return (T[]) java.lang.reflect.Array.newInstance(objectType, 0);
}
Object[] dataObjects = new Object[files.length];
T[] dataObjects = (T[]) java.lang.reflect.Array.newInstance(objectType, files.length);
for (int i = 0; i < files.length; i++) {
try (FileReader reader = new FileReader(files[i])) {
dataObjects[i] = jsonParser.fromJson(reader, objectType);