1.5.2
This commit is contained in:
parent
329cf2c96f
commit
da48cc9d9e
25 changed files with 265 additions and 83 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,2 +1,2 @@
|
|||
#Mon Mar 31 19:21:45 TRT 2025
|
||||
#Wed Jul 15 23:48:01 TRT 2026
|
||||
gradle.version=8.8
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GLogTabCompleter implements TabCompleter {
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("self_stats", "other_stats", "self_titles", "other_titles", "world", "leaderboard", "commands", "chunk");
|
||||
|
|
@ -44,6 +45,18 @@ public class GLogTabCompleter implements TabCompleter {
|
|||
}
|
||||
}
|
||||
|
||||
for (org.bukkit.OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
|
||||
if (offlinePlayer.hasPlayedBefore() &&
|
||||
offlinePlayer.getName() != null &&
|
||||
offlinePlayer.getName().toLowerCase().startsWith(partialPlayer) &&
|
||||
!playerSuggestions.contains(offlinePlayer.getName())) {
|
||||
UUID uuid = offlinePlayer.getUniqueId();
|
||||
if (org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata.getOfflinePlayerMetadata(uuid) != null) {
|
||||
playerSuggestions.add(offlinePlayer.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return playerSuggestions;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GLogCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class LogPlayerStats {
|
||||
public LogPlayerStats() {
|
||||
}
|
||||
|
|
@ -17,26 +20,36 @@ public class LogPlayerStats {
|
|||
return false;
|
||||
} else {
|
||||
Player tplayer = GrimmsServer.instance.getServer().getPlayer(args[1]);
|
||||
if (tplayer == null) {
|
||||
player.sendMessage("Player not found.");
|
||||
return false;
|
||||
PlayerStats stats;
|
||||
String displayName;
|
||||
|
||||
if (tplayer != null) {
|
||||
stats = PlayerStats.getPlayerStats(tplayer);
|
||||
displayName = tplayer.getDisplayName();
|
||||
} else {
|
||||
PlayerStats stats = PlayerStats.getPlayerStats(tplayer);
|
||||
player.sendMessage("__" + tplayer.getDisplayName() + "'s stats:");
|
||||
|
||||
for (String stat : PlayerStats.StatOrder) {
|
||||
Object value = stats.getStat(stat, Object.class);
|
||||
if (value instanceof Double) {
|
||||
String var10001 = PlayerStats.StatNames.get(stat);
|
||||
player.sendMessage("|" + var10001 + ": " + Shared.formatNumber((Double) value));
|
||||
} else {
|
||||
String var7 = PlayerStats.StatNames.get(stat);
|
||||
player.sendMessage("|" + var7 + ": " + value.toString());
|
||||
}
|
||||
UUID uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
||||
stats = PlayerStats.getOfflinePlayerStats(uuid);
|
||||
if (stats == null) {
|
||||
player.sendMessage("Player not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
displayName = args[1];
|
||||
}
|
||||
|
||||
player.sendMessage("__" + displayName + "'s stats:");
|
||||
|
||||
for (String stat : PlayerStats.StatOrder) {
|
||||
Object value = stats.getStat(stat, Object.class);
|
||||
if (value instanceof Double) {
|
||||
String var10001 = PlayerStats.StatNames.get(stat);
|
||||
player.sendMessage("|" + var10001 + ": " + Shared.formatNumber((Double) value));
|
||||
} else {
|
||||
String var7 = PlayerStats.StatNames.get(stat);
|
||||
player.sendMessage("|" + var7 + ": " + value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GLogCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class LogPlayerTitles {
|
||||
public LogPlayerTitles() {
|
||||
}
|
||||
|
|
@ -15,19 +18,29 @@ public class LogPlayerTitles {
|
|||
return false;
|
||||
} else {
|
||||
Player tplayer = GrimmsServer.instance.getServer().getPlayer(args[1]);
|
||||
if (tplayer == null) {
|
||||
player.sendMessage("Player not found.");
|
||||
return false;
|
||||
PlayerTitles playerTitles;
|
||||
String displayName;
|
||||
|
||||
if (tplayer != null) {
|
||||
playerTitles = PlayerTitles.getPlayerTitles(tplayer);
|
||||
displayName = tplayer.getDisplayName();
|
||||
} else {
|
||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(tplayer);
|
||||
player.sendMessage("__Your Titles:");
|
||||
|
||||
for (String title : playerTitles.getTitles()) {
|
||||
player.sendMessage("|" + title + ": " + PlayerTitles.titles.get(title));
|
||||
UUID uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
||||
playerTitles = PlayerTitles.getOfflinePlayerTitles(uuid);
|
||||
if (playerTitles == null) {
|
||||
player.sendMessage("Player not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
displayName = args[1];
|
||||
}
|
||||
|
||||
player.sendMessage("__" + displayName + "'s Titles:");
|
||||
|
||||
for (String title : playerTitles.getTitles()) {
|
||||
player.sendMessage("|" + title + ": " + PlayerTitles.titles.get(title));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GStatsTabCompleter implements TabCompleter {
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("self_history", "others_history", "commands");
|
||||
private static final List<String> TIME_RANGES = Arrays.asList("hour", "day", "week", "month", "all");
|
||||
private static final List<String> GRAPH_OPTIONS = Arrays.asList("largegraph");
|
||||
|
||||
public GStatsTabCompleter() {
|
||||
}
|
||||
|
|
@ -45,6 +47,18 @@ public class GStatsTabCompleter implements TabCompleter {
|
|||
}
|
||||
}
|
||||
|
||||
for (org.bukkit.OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
|
||||
if (offlinePlayer.hasPlayedBefore() &&
|
||||
offlinePlayer.getName() != null &&
|
||||
offlinePlayer.getName().toLowerCase().startsWith(partialPlayer) &&
|
||||
!playerSuggestions.contains(offlinePlayer.getName())) {
|
||||
UUID uuid = offlinePlayer.getUniqueId();
|
||||
if (org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata.getOfflinePlayerMetadata(uuid) != null) {
|
||||
playerSuggestions.add(offlinePlayer.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return playerSuggestions;
|
||||
} else if (subcommand.equals("self_history")) {
|
||||
String partialTime = args[1].toLowerCase();
|
||||
|
|
@ -97,6 +111,23 @@ public class GStatsTabCompleter implements TabCompleter {
|
|||
|
||||
return statSuggestions;
|
||||
}
|
||||
} else if (args.length == 4 || args.length == 5) {
|
||||
String subcommand = args[0].toLowerCase();
|
||||
if (subcommand.equals("self_history") || subcommand.equals("others_history")) {
|
||||
int argIndex = subcommand.equals("self_history") ? 3 : 4;
|
||||
if (args.length > argIndex) {
|
||||
String partialGraph = args[argIndex].toLowerCase();
|
||||
List<String> graphSuggestions = new ArrayList();
|
||||
|
||||
for (String graphOption : GRAPH_OPTIONS) {
|
||||
if (graphOption.startsWith(partialGraph)) {
|
||||
graphSuggestions.add(graphOption);
|
||||
}
|
||||
}
|
||||
|
||||
return graphSuggestions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return List.of();
|
||||
|
|
|
|||
|
|
@ -47,12 +47,26 @@ public class OthersHistory {
|
|||
|
||||
String timeRange = "all";
|
||||
String specificStat = null;
|
||||
boolean largeGraph = false;
|
||||
|
||||
if (args.length >= 3) {
|
||||
timeRange = args[2].toLowerCase();
|
||||
}
|
||||
if (args.length >= 4) {
|
||||
specificStat = args[3].toLowerCase();
|
||||
String arg = args[3].toLowerCase();
|
||||
if (arg.equals("largegraph")) {
|
||||
largeGraph = true;
|
||||
} else {
|
||||
specificStat = arg;
|
||||
}
|
||||
}
|
||||
if (args.length >= 5) {
|
||||
String arg = args[4].toLowerCase();
|
||||
if (arg.equals("largegraph")) {
|
||||
largeGraph = true;
|
||||
} else if (specificStat == null) {
|
||||
specificStat = arg;
|
||||
}
|
||||
}
|
||||
|
||||
List<HistoricalStatsSnapshot> snapshots = SelfHistory.filterSnapshotsByTime(historicalStats.allTimeSnapshots, timeRange);
|
||||
|
|
@ -65,9 +79,9 @@ public class OthersHistory {
|
|||
player.sendMessage(ChatColor.GOLD + "=== " + targetPlayerName + "'s Stats History ===");
|
||||
|
||||
if (specificStat != null && PlayerStats.Stats.get(specificStat) != null) {
|
||||
SelfHistory.displaySingleStatGraph(player, snapshots, specificStat, timeRange);
|
||||
SelfHistory.displaySingleStatGraph(player, snapshots, specificStat, timeRange, largeGraph);
|
||||
} else {
|
||||
SelfHistory.displayAllStatsGraph(player, snapshots, timeRange);
|
||||
SelfHistory.displayAllStatsGraph(player, snapshots, timeRange, largeGraph);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -32,12 +32,26 @@ public class SelfHistory {
|
|||
|
||||
String timeRange = "all";
|
||||
String specificStat = null;
|
||||
boolean largeGraph = false;
|
||||
|
||||
if (args.length >= 2) {
|
||||
timeRange = args[1].toLowerCase();
|
||||
}
|
||||
if (args.length >= 3) {
|
||||
specificStat = args[2].toLowerCase();
|
||||
String arg = args[2].toLowerCase();
|
||||
if (arg.equals("largegraph")) {
|
||||
largeGraph = true;
|
||||
} else {
|
||||
specificStat = arg;
|
||||
}
|
||||
}
|
||||
if (args.length >= 4) {
|
||||
String arg = args[3].toLowerCase();
|
||||
if (arg.equals("largegraph")) {
|
||||
largeGraph = true;
|
||||
} else if (specificStat == null) {
|
||||
specificStat = arg;
|
||||
}
|
||||
}
|
||||
|
||||
List<HistoricalStatsSnapshot> snapshots = filterSnapshotsByTime(historicalStats.allTimeSnapshots, timeRange);
|
||||
|
|
@ -47,10 +61,10 @@ public class SelfHistory {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (specificStat != null && !PlayerStats.Stats.get(specificStat).equals(null)) {
|
||||
displaySingleStatGraph(player, snapshots, specificStat, timeRange);
|
||||
if (specificStat != null && PlayerStats.Stats.get(specificStat) != null) {
|
||||
displaySingleStatGraph(player, snapshots, specificStat, timeRange, largeGraph);
|
||||
} else {
|
||||
displayAllStatsGraph(player, snapshots, timeRange);
|
||||
displayAllStatsGraph(player, snapshots, timeRange, largeGraph);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -91,7 +105,7 @@ public class SelfHistory {
|
|||
return filtered;
|
||||
}
|
||||
|
||||
public static void displaySingleStatGraph(Player player, List<HistoricalStatsSnapshot> snapshots, String statName, String timeRange) {
|
||||
public static void displaySingleStatGraph(Player player, List<HistoricalStatsSnapshot> snapshots, String statName, String timeRange, boolean largeGraph) {
|
||||
ArrayList<String> messages = new ArrayList<>();
|
||||
String displayName = PlayerStats.StatNames.get(statName);
|
||||
|
||||
|
|
@ -122,8 +136,8 @@ public class SelfHistory {
|
|||
maxValue += 1;
|
||||
}
|
||||
|
||||
int graphHeight = 10;
|
||||
int graphWidth = Math.min(snapshots.size(), 40);
|
||||
int graphHeight = largeGraph ? 15 : 6;
|
||||
int graphWidth = largeGraph ? Math.min(snapshots.size(), 60) : Math.min(snapshots.size(), 25);
|
||||
|
||||
messages.add(ChatColor.GRAY + "Min: " + ChatColor.AQUA + formatStatValue(statName, minValue) +
|
||||
ChatColor.GRAY + " | Max: " + ChatColor.AQUA + formatStatValue(statName, maxValue));
|
||||
|
|
@ -156,12 +170,15 @@ public class SelfHistory {
|
|||
GeneralChatHandler.sendArray(player, messages.toArray(new String[0]));
|
||||
}
|
||||
|
||||
public static void displayAllStatsGraph(Player player, List<HistoricalStatsSnapshot> snapshots, String timeRange) {
|
||||
public static void displayAllStatsGraph(Player player, List<HistoricalStatsSnapshot> snapshots, String timeRange, boolean largeGraph) {
|
||||
ArrayList<String> messages = new ArrayList<>();
|
||||
|
||||
messages.add(ChatColor.GOLD + "=== All Stats History (" + timeRange + ") ===");
|
||||
messages.add(ChatColor.GRAY + "Showing " + snapshots.size() + " data points");
|
||||
messages.add(ChatColor.YELLOW + "Use /gStats self_history " + timeRange + " <stat> for detailed graph");
|
||||
if (largeGraph) {
|
||||
messages.add(ChatColor.YELLOW + "Add 'largegraph' for larger graph display");
|
||||
}
|
||||
|
||||
HistoricalStatsSnapshot first = snapshots.get(0);
|
||||
HistoricalStatsSnapshot last = snapshots.get(snapshots.size() - 1);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package org.gsdistance.grimmsServer.Config;
|
||||
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public enum ConfigKey {
|
||||
CONFIG_VERSION("config_version", GrimmsServer.instance.getDescription().getVersion()),
|
||||
MODULE_JOBS("module_Jobs", true),
|
||||
MODULE_FACTIONS("module_Factions", true),
|
||||
MODULE_MARKET("module_Market", true),
|
||||
|
|
@ -18,8 +21,8 @@ public enum ConfigKey {
|
|||
MODULE_RANKS("module_Ranks", true),
|
||||
JOIN_MESSAGE("joinMessage", true),
|
||||
MODULE_DIMENSIONS("module_Dimensions", true),
|
||||
DISABLED_DIMENSIONS("disabledDimensions", new ArrayList()),
|
||||
BANNED_WORDS("bannedWords", new ArrayList()),
|
||||
DISABLED_DIMENSIONS("disabledDimensions", new ArrayList<>()),
|
||||
BANNED_WORDS("bannedWords", new ArrayList<>()),
|
||||
FORCE_DISABLE_BC("forceDisableBroadcasts", false),
|
||||
FORCE_AUTH("forceAuth", false),
|
||||
MARKET_GUI_ENABLED("market_gui_enabled", true),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ConfigLoader {
|
||||
private static FileConfiguration config;
|
||||
|
|
@ -17,12 +18,25 @@ public class ConfigLoader {
|
|||
public static void initialize(JavaPlugin plugin) {
|
||||
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
plugin.saveDefaultConfig();
|
||||
generateDefaultConfig(configFile);
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
private static void generateDefaultConfig(File configFile) {
|
||||
YamlConfiguration yamlConfig = new YamlConfiguration();
|
||||
for (ConfigKey key : ConfigKey.values()) {
|
||||
yamlConfig.set(key.getKey(), key.getDefaultValue());
|
||||
}
|
||||
try {
|
||||
yamlConfig.save(configFile);
|
||||
GrimmsServer.logger.info("Generated default config.yml from ConfigKey enum");
|
||||
} catch (IOException e) {
|
||||
GrimmsServer.logger.severe("Failed to generate default config.yml: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadConfigFromFile() {
|
||||
Stopwatch sw = Stopwatch.createStarted();
|
||||
GrimmsServer.logger.info("Loading GrimmsServer config...");
|
||||
|
|
|
|||
|
|
@ -57,8 +57,10 @@ public class PlayerLevelHandler {
|
|||
this.playerStats.setStat("xp_required", this.getXpToLevel());
|
||||
if (lvlups > 0) {
|
||||
this.playerStats.setStat("money", this.playerStats.getStat("money", Double.class) + tMoney);
|
||||
double prestige = Math.max(1, this.playerStats.getStat("prestige", Integer.class));
|
||||
double level = this.playerStats.getStat("level", Integer.class);
|
||||
this.playerStats.setStat("maximum_balance", Math.floor(Math.pow(level, 1.5) * Math.pow(prestige, 2) * 10000 * Math.log(level) / Math.log(7)) );
|
||||
EventRegistry.callEvent(new PlayerLevelUpRegister(this.player, lvlups, tMoney));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,10 @@ public class PlayerTickEvent {
|
|||
if (jobTitleId != null && !jobTitleId.isEmpty()) {
|
||||
double multiplier = (double) 1.0F + Math.pow((double) playerStats.getStat("level", Integer.class), 2.0F) * Math.pow(playerStats.getStat("prestige", Integer.class) + 1,2) / (double) 100.0F;
|
||||
double payCheck = Math.ceil(JobTitlesBaseValues.jobTitleBaseValues.getOrDefault(jobTitleId, null).paycheckSize() * multiplier);
|
||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) + payCheck);
|
||||
double money = playerStats.getStat("money", Double.class);
|
||||
if(playerStats.getStat("maximum_balance", Double.class) < money + payCheck){
|
||||
playerStats.setStat("money", money + payCheck);
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + "You have received your paycheck: " + ChatColor.GOLD + Shared.formatNumber(payCheck));
|
||||
lastPaycheckTimes.put(playerId, currentTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PlayerStats {
|
||||
public static final Dictionary<String, PersistentDataType<?, ?>> Stats = new Hashtable<>();
|
||||
|
|
@ -16,10 +17,14 @@ public class PlayerStats {
|
|||
public static final Map<String, ?> StatDefaultValues;
|
||||
private final JavaPlugin plugin;
|
||||
private final PersistentDataContainer dataContainer;
|
||||
private final Map<String, Object> offlineStats;
|
||||
private final boolean isOffline;
|
||||
|
||||
public PlayerStats(JavaPlugin plugin, Player player) {
|
||||
this.plugin = plugin;
|
||||
this.dataContainer = player.getPersistentDataContainer();
|
||||
this.offlineStats = null;
|
||||
this.isOffline = false;
|
||||
|
||||
for (String stat : StatOrder) {
|
||||
if (!this.hasExactStat(stat)) {
|
||||
|
|
@ -29,15 +34,54 @@ public class PlayerStats {
|
|||
|
||||
}
|
||||
|
||||
public PlayerStats(Map<String, Object> offlineStatsData) {
|
||||
this.plugin = GrimmsServer.instance;
|
||||
this.dataContainer = null;
|
||||
this.offlineStats = new ConcurrentHashMap<>(offlineStatsData);
|
||||
this.isOffline = true;
|
||||
|
||||
for (String stat : StatOrder) {
|
||||
if (!this.offlineStats.containsKey(stat)) {
|
||||
this.offlineStats.put(stat, StatDefaultValues.get(stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerStats getPlayerStats(Player player) {
|
||||
return new PlayerStats(GrimmsServer.instance, player);
|
||||
}
|
||||
|
||||
public static PlayerStats getOfflinePlayerStats(UUID uuid) {
|
||||
org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata metadata =
|
||||
org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata.getOfflinePlayerMetadata(uuid);
|
||||
if (metadata == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, Object> statsData = new ConcurrentHashMap<>();
|
||||
for (String stat : StatOrder) {
|
||||
Object defaultValue = StatDefaultValues.get(stat);
|
||||
statsData.put(stat, defaultValue);
|
||||
}
|
||||
|
||||
return new PlayerStats(statsData);
|
||||
}
|
||||
|
||||
public void resetStat(String stat) {
|
||||
this.setStat(stat, StatDefaultValues.get(stat));
|
||||
}
|
||||
|
||||
public <T> T getStat(String stat, Class<T> ignoredType) {
|
||||
if (this.isOffline) {
|
||||
Object value = this.offlineStats.get(stat);
|
||||
if (value == null) {
|
||||
T defaultValue = (T) StatDefaultValues.get(stat);
|
||||
this.offlineStats.put(stat, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
PersistentDataType type = Stats.get(stat);
|
||||
if (!this.hasExactStat(stat)) {
|
||||
GrimmsServer.logger.warning("Stat " + stat + " does not have a value.");
|
||||
|
|
@ -54,10 +98,18 @@ public class PlayerStats {
|
|||
}
|
||||
|
||||
public boolean hasExactStat(String stat) {
|
||||
if (this.isOffline) {
|
||||
return this.offlineStats.containsKey(stat);
|
||||
}
|
||||
return this.dataContainer.has(new NamespacedKey(this.plugin, stat), (PersistentDataType) Stats.get(stat));
|
||||
}
|
||||
|
||||
public void setStat(String stat, Object value) {
|
||||
if (this.isOffline) {
|
||||
this.offlineStats.put(stat, value);
|
||||
return;
|
||||
}
|
||||
|
||||
PersistentDataType type = Stats.get(stat);
|
||||
if (type == null) {
|
||||
GrimmsServer.logger.warning("Stat " + stat + " does not exist.");
|
||||
|
|
@ -100,6 +152,7 @@ public class PlayerStats {
|
|||
static {
|
||||
Stats.put("death_count", PersistentDataType.INTEGER);
|
||||
Stats.put("money", PersistentDataType.DOUBLE);
|
||||
Stats.put("maximum_balance", PersistentDataType.DOUBLE);
|
||||
Stats.put("total_kill_count", PersistentDataType.INTEGER);
|
||||
Stats.put("join_count", PersistentDataType.INTEGER);
|
||||
Stats.put("tPoint", PersistentDataType.DOUBLE);
|
||||
|
|
@ -117,6 +170,7 @@ public class PlayerStats {
|
|||
StatNames = new Hashtable<>();
|
||||
StatNames.put("death_count", "Death Count");
|
||||
StatNames.put("money", "Money");
|
||||
StatNames.put("maximum_balance", "Maximum Balance");
|
||||
StatNames.put("total_kill_count", "Total Kill Count");
|
||||
StatNames.put("join_count", "Join Count");
|
||||
StatNames.put("tPoint", "Total Points");
|
||||
|
|
@ -131,7 +185,7 @@ public class PlayerStats {
|
|||
StatNames.put("autologin", "Login Automatically");
|
||||
StatNames.put("prestige", "Prestige");
|
||||
StatNames.put("prestigePoints", "Prestige Points");
|
||||
StatOrder = List.of("death_count", "money", "total_kill_count", "join_count", "tPoint", "block_break_count", "sent_messages", "level", "xp", "xp_required", "intelligence", "jobTitle", "prestige", "prestigePoints");
|
||||
StatDefaultValues = Map.ofEntries(Map.entry("death_count", 0), Map.entry("money", (double) 0.0F), Map.entry("total_kill_count", 0), Map.entry("join_count", 0), Map.entry("tPoint", (double) 0.0F), Map.entry("block_break_count", 0L), Map.entry("level", 1), Map.entry("xp", (double) 0.0F), Map.entry("xp_required", (double) 100.0F), Map.entry("sent_messages", 0L), Map.entry("intelligence", (new Random()).nextInt(0, 100)), Map.entry("jobTitle", ""), Map.entry("pass", ""), Map.entry("autologin", false), Map.entry("prestige", 0), Map.entry("prestigePoints", 0L));
|
||||
StatOrder = List.of("death_count", "money", "maximum_balance", "total_kill_count", "join_count", "tPoint", "block_break_count", "sent_messages", "level", "xp", "xp_required", "intelligence", "jobTitle", "prestige", "prestigePoints");
|
||||
StatDefaultValues = Map.ofEntries(Map.entry("death_count", 0), Map.entry("money", (double) 0.0F), Map.entry("maximum_balance", (double) 1000.0F), Map.entry("total_kill_count", 0), Map.entry("join_count", 0), Map.entry("tPoint", (double) 0.0F), Map.entry("block_break_count", 0L), Map.entry("level", 1), Map.entry("xp", (double) 0.0F), Map.entry("xp_required", (double) 100.0F), Map.entry("sent_messages", 0L), Map.entry("intelligence", (new Random()).nextInt(0, 100)), Map.entry("jobTitle", ""), Map.entry("pass", ""), Map.entry("autologin", false), Map.entry("prestige", 0), Map.entry("prestigePoints", 0L));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import org.gsdistance.grimmsServer.Data.Player.PlayerTitleChecker;
|
|||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerTitles {
|
||||
public static final Map<String, String> titles = Map.ofEntries(Map.entry("Dictator", "The title of a dictator, not to be messed with."), Map.entry("Executioner", "The title and power of execution."), Map.entry("Murderer", "Someone whose crimes follow him till death."), Map.entry("Victim", "Got murdered, unfortunate."), Map.entry("DragonSlayer", "The fabled warrior to defeat the fabled dragon or something like that."), Map.entry("Newbie", "Wowie! Joining the game gives a title!"), Map.entry("Richie", "Money talks, well at least that's what I've been told!"), Map.entry("Millionaire", "Wow, that's quite a lot ya' know!"), Map.entry("Billionaire", "Capitalism at it's finest."), Map.entry("Trillionaire", "Literally insane, no comment."), Map.entry("Quadrillionaire", "Why?"), Map.entry("Miner", "Minin' to the earths core."), Map.entry("Anti-block", "DEMOLISH 10000 blocks"), Map.entry("UltimateMiner", "Mine 100000 blocks"), Map.entry("Titlemaxxer", "Get more than 5 titles"), Map.entry("KillingMachine", "Kill 100 things(?)."), Map.entry("ProGamer", "Kill 1000 things(?)."), Map.entry("Hitman", "Professional killerguy."), Map.entry("Leader", "You got on the leaderboard."), Map.entry("Null", "Not a title bro."), Map.entry("BugSlayer", "Reported a bug."), Map.entry("ExploitDestroyer","Reported an exploit."), Map.entry("Disgrace.", "Abused an exploit."));
|
||||
|
|
@ -19,6 +20,14 @@ public class PlayerTitles {
|
|||
return new PlayerTitles(player);
|
||||
}
|
||||
|
||||
public static PlayerTitles getOfflinePlayerTitles(UUID uuid) {
|
||||
PlayerMetadata metadata = PlayerMetadata.getOfflinePlayerMetadata(uuid);
|
||||
if (metadata == null) {
|
||||
return null;
|
||||
}
|
||||
return new OfflinePlayerTitles(metadata);
|
||||
}
|
||||
|
||||
public String[] getTitles() {
|
||||
return PlayerMetadata.getPlayerMetadata(this.player).titles;
|
||||
}
|
||||
|
|
@ -68,4 +77,28 @@ public class PlayerTitles {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class OfflinePlayerTitles extends PlayerTitles {
|
||||
private final PlayerMetadata metadata;
|
||||
|
||||
public OfflinePlayerTitles(PlayerMetadata metadata) {
|
||||
super(null);
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTitles() {
|
||||
return this.metadata.titles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTitle(String title) {
|
||||
for (String playerTitle : this.metadata.titles) {
|
||||
if (playerTitle.equals(title)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
module_Jobs: true
|
||||
module_Factions: true
|
||||
module_Market: true
|
||||
module_Leaderboard: true
|
||||
disabledCommands: [ ]
|
||||
module_Chat: true
|
||||
module_Homes: true
|
||||
module_Leveling: true
|
||||
module_Titles: true
|
||||
module_Relics: true
|
||||
module_Events: true
|
||||
module_Utils: true
|
||||
module_Ranks: true
|
||||
joinMessage: true
|
||||
module_Dimensions: true
|
||||
disabledDimensions: [ ]
|
||||
forceDisableBroadcasts: false
|
||||
bannedWords: [ ]
|
||||
enforceAuth: false
|
||||
market_gui_enabled: true
|
||||
market_ripoff_multiplier: 10.0
|
||||
market_min_price: 0.25
|
||||
market_price_refresh_interval: 300
|
||||
log_level: Info
|
||||
prestige_capability_autosell_price: 4
|
||||
prestige_capability_magnet_price: 2
|
||||
prestige_capability_veinminer_price: 3
|
||||
prestige_capability_saturation_perk_price: 4
|
||||
Loading…
Add table
Add a link
Reference in a new issue