TCheckpoint

This commit is contained in:
tyuXX 2025-06-29 12:12:35 +03:00
parent 2845cc512f
commit c5b686aeb5
55 changed files with 453 additions and 213 deletions

View file

@ -1,23 +1,20 @@
package org.gsdistance.grimmsServer.Data;
import org.gsdistance.grimmsServer.Config.ActiveConfig;
import org.gsdistance.grimmsServer.Config.ConfigKey;
import java.util.Map;
import static org.gsdistance.grimmsServer.Config.ActiveConfig.getConfigValue;
public class ConfigRequirements {
public static final Map<String, String> CommandRequirements = Map.ofEntries(
Map.entry("logLeaderboard", "leaderboard"),
Map.entry("sendMoney", "market"),
Map.entry("makeItemLevelable", "leveling"),
Map.entry("setPlayerStat", "stats"),
Map.entry("logPlayerStats", "stats"),
Map.entry("logSelfStats", "stats"),
Map.entry("logWorldStats", "stats"),
Map.entry("logEnchantmentCosts", "market"),
Map.entry("logJobs", "job"),
Map.entry("takeJob", "job"),
Map.entry("logSelfTitles", "titles"),
Map.entry("logPlayerTitles", "titles"),
Map.entry("addTitle", "titles"),
Map.entry("removeTitle", "titles"),
Map.entry("executePlayer", "titles"),
@ -31,19 +28,19 @@ public class ConfigRequirements {
public static boolean isCommandEnabled(String command) {
return switch (CommandRequirements.getOrDefault(command, "default")) {
case "market" -> ActiveConfig.module_Market;
case "leaderboard" -> ActiveConfig.module_Leaderboard;
case "job" -> ActiveConfig.module_Jobs;
case "stats" -> ActiveConfig.module_Leveling;
case "titles" -> ActiveConfig.module_Titles;
case "chat" -> ActiveConfig.module_Chat;
case "homes" -> ActiveConfig.module_Homes;
case "utils" -> ActiveConfig.module_Utils;
case "ranks" -> ActiveConfig.module_Ranks;
case "factions" -> ActiveConfig.module_Factions;
case "relics" -> ActiveConfig.module_Relics;
case "events" -> ActiveConfig.module_Events;
case "dimensions" -> ActiveConfig.module_Dimensions;
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);
case "titles" -> getConfigValue(ConfigKey.MODULE_TITLES, Boolean.class);
case "chat" -> getConfigValue(ConfigKey.MODULE_CHAT, Boolean.class);
case "homes" -> getConfigValue(ConfigKey.MODULE_HOMES, Boolean.class);
case "utils" -> getConfigValue(ConfigKey.MODULE_UTILS, Boolean.class);
case "ranks" -> getConfigValue(ConfigKey.MODULE_RANKS, Boolean.class);
case "factions" -> getConfigValue(ConfigKey.MODULE_FACTIONS, Boolean.class);
case "relics" -> getConfigValue(ConfigKey.MODULE_RELICS, Boolean.class);
case "events" -> getConfigValue(ConfigKey.MODULE_EVENTS, Boolean.class);
case "dimensions" -> getConfigValue(ConfigKey.MODULE_DIMENSIONS, Boolean.class);
case "default" -> true; // Default commands are always enabled
default -> true; // Unknown command category
};

View file

@ -0,0 +1,23 @@
package org.gsdistance.grimmsServer.Data;
public enum FactionRank {
LEADER("Leader"),
OFFICER("Officer"),
MEMBER("Member"),
RECRUIT("Recruit");
private final String displayName;
FactionRank(String displayName) {
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
@Override
public String toString() {
return displayName;
}
}

View file

@ -48,14 +48,14 @@ public class PluginDataStorage {
}
}
public Object retrieveData(String fileName, Type objectType, String addedPath) {
public <T> T retrieveData(String fileName, String addedPath, Class<T> ignoredType) {
File readFolder = new File(plugin.getDataFolder().getPath() + File.separatorChar + addedPath);
File readFile = new File(readFolder.getPath() + File.separatorChar + fileName);
if (!readFile.exists()) {
return null;
}
try (FileReader reader = new FileReader(readFile)) {
return jsonParser.fromJson(reader, objectType);
return jsonParser.fromJson(reader, ignoredType);
} catch (IOException e) {
GrimmsServer.logger.log(Level.WARNING, "Failed to retrieve data from " + readFile.getPath(), e);
return null;