Push
This commit is contained in:
parent
79098e3e24
commit
e0914b029b
54 changed files with 688 additions and 221 deletions
|
|
@ -0,0 +1,56 @@
|
|||
package org.gsdistance.grimmsServer.Data;
|
||||
|
||||
import org.gsdistance.grimmsServer.Config.ActiveConfig;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigRequirements {
|
||||
public static final Map<String, String> CommandRequirements = Map.ofEntries(
|
||||
Map.entry("sellItem", "market"),
|
||||
Map.entry("buyItem", "market"),
|
||||
Map.entry("getMarketStock", "market"),
|
||||
Map.entry("getMarket", "market"),
|
||||
Map.entry("logLeaderboard", "leaderboard"),
|
||||
Map.entry("sendMoney", "market"),
|
||||
Map.entry("buyRipoff", "market"),
|
||||
Map.entry("makeItemLevelable", "leveling"),
|
||||
Map.entry("setPlayerStat", "stats"),
|
||||
Map.entry("logPlayerStats", "stats"),
|
||||
Map.entry("logSelfStats", "stats"),
|
||||
Map.entry("logWorldStats", "stats"),
|
||||
Map.entry("buyEnchantment", "market"),
|
||||
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"),
|
||||
Map.entry("grimmsServerCommands", "default"),
|
||||
Map.entry("withdrawMoney", "market"),
|
||||
Map.entry("depositMoney", "market"),
|
||||
Map.entry("acceptRequest", "default"),
|
||||
Map.entry("buyTp", "market"),
|
||||
Map.entry("reloadGrimmsConfig", "default"),
|
||||
Map.entry("home", "homes")
|
||||
);
|
||||
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 "default" -> true; // Default commands are always enabled
|
||||
default -> true; // Unknown command category
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ModuleRequirements {
|
||||
public static final Map<String, String> CommandRequirements;
|
||||
static {
|
||||
CommandRequirements = Map.ofEntries(
|
||||
Map.entry("","job")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package org.gsdistance.grimmsServer.Data;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Location;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerMetadata {
|
||||
public Map<String, Location> homes;
|
||||
public String nickname;
|
||||
public String lastKnownName;
|
||||
public UUID uuid;
|
||||
public Location exitLocation;
|
||||
public String[] titles;
|
||||
public PlayerMetadata(Player player) {
|
||||
this.nickname = player.getDisplayName();
|
||||
this.lastKnownName = player.getName();
|
||||
this.uuid = player.getUniqueId();
|
||||
this.exitLocation = new Location(player.getLocation());
|
||||
homes = new HashMap<>();
|
||||
titles = new String[0];
|
||||
}
|
||||
|
||||
public void softSave() {
|
||||
PerSessionDataStorage.dataStore.put("metadata-" + uuid, Map.of(this, PlayerMetadata.class));
|
||||
}
|
||||
|
||||
public void saveToPDS() {
|
||||
softSave();
|
||||
GrimmsServer.pds.saveData(this, PlayerMetadata.class, uuid.toString() + ".json", "playerMetadata");
|
||||
}
|
||||
|
||||
public static PlayerMetadata getPlayerMetadata(Player player) {
|
||||
if (PerSessionDataStorage.dataStore.containsKey("metadata-" + player.getUniqueId())) {
|
||||
return (PlayerMetadata) PerSessionDataStorage.dataStore.get("metadata-" + player.getUniqueId()).keySet().toArray()[0];
|
||||
}
|
||||
else if (GrimmsServer.pds.exists(player.getUniqueId().toString() + ".json", "playerMetadata")) {
|
||||
PlayerMetadata metadata = (PlayerMetadata) GrimmsServer.pds.retrieveData(player.getUniqueId().toString() + ".json", PlayerMetadata.class, "playerMetadata");
|
||||
if (metadata == null) {
|
||||
metadata = new PlayerMetadata(player);
|
||||
}
|
||||
PerSessionDataStorage.dataStore.put("metadata-" + player.getUniqueId(), Map.of(metadata, PlayerMetadata.class));
|
||||
return metadata;
|
||||
}
|
||||
else {
|
||||
PlayerMetadata metadata = new PlayerMetadata(player);
|
||||
PerSessionDataStorage.dataStore.put("metadata-" + player.getUniqueId(), Map.of(metadata, PlayerMetadata.class));
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,9 +33,6 @@ public class PlayerTitleManager {
|
|||
}
|
||||
|
||||
public static void checkForMoney(Player player) {
|
||||
if(!PlayerStats.getPlayerStats(player).hasExactStat("money")){
|
||||
return;
|
||||
}
|
||||
double money = (double) PlayerStats.getPlayerStats(player).getStat("money");
|
||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
||||
if (money > 100000.0) {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import java.lang.reflect.Type;
|
|||
import java.util.logging.Level;
|
||||
|
||||
public class PluginDataStorage {
|
||||
private JavaPlugin plugin;
|
||||
private Gson jsonParser;
|
||||
private final JavaPlugin plugin;
|
||||
private final Gson jsonParser;
|
||||
|
||||
public PluginDataStorage(JavaPlugin plugin) {
|
||||
jsonParser = new Gson();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue