TCheckpoint
This commit is contained in:
parent
2845cc512f
commit
c5b686aeb5
55 changed files with 453 additions and 213 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.
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -59,14 +59,10 @@ commands:
|
|||
description: Removes a title from a player.
|
||||
usage: /removeTitle <player> <title>
|
||||
permission: grimmsserver.removeTitle
|
||||
faction:
|
||||
gFaction:
|
||||
description: Faction commands
|
||||
usage: /faction <command> <args>
|
||||
usage: /gFaction <command> <args>
|
||||
permission: grimmsserver.faction
|
||||
reloadGrimmsConfig:
|
||||
description: Reloads the GrimmsServer configuration.
|
||||
usage: /reloadGrimmsConfig
|
||||
permission: grimmsserver.reloadConfig
|
||||
home:
|
||||
description: Home commands
|
||||
usage: /home <command> <args>
|
||||
|
|
@ -91,6 +87,10 @@ commands:
|
|||
description: Utility commands.
|
||||
usage: /gUtil <command> [args]
|
||||
permission: grimmsserver.util
|
||||
gConfig:
|
||||
description: Configuration commands.
|
||||
usage: /gConfig <command> [args]
|
||||
permission: grimmsserver.config
|
||||
permissions:
|
||||
grimmsserver.sendMoney:
|
||||
description: Allows a player to send money to another player
|
||||
|
|
@ -140,9 +140,6 @@ permissions:
|
|||
grimmsserver.factionAdmin:
|
||||
description: Allows a player to use faction admin commands
|
||||
default: op
|
||||
grimmsserver.reloadConfig:
|
||||
description: Allows a player to reload the GrimmsServer configuration
|
||||
default: op
|
||||
grimmsserver.nick:
|
||||
description: Allows a player to change their own nickname
|
||||
default: true
|
||||
|
|
@ -182,3 +179,6 @@ permissions:
|
|||
grimmsserver.util:
|
||||
description: Allows a player to use utility commands
|
||||
default: op
|
||||
grimmsserver.config:
|
||||
description: Allows a player to use configuration commands
|
||||
default: op
|
||||
Binary file not shown.
|
|
@ -0,0 +1,16 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GConfigCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Config.ConfigKey;
|
||||
|
||||
import static org.gsdistance.grimmsServer.Config.ActiveConfig.getConfigValue;
|
||||
|
||||
public class Dump {
|
||||
public static boolean subCommand(Player player) {
|
||||
player.sendMessage("Config Dump:");
|
||||
for (ConfigKey key : ConfigKey.values()) {
|
||||
player.sendMessage("|" + key.getKey() + ":" + getConfigValue(key, String.class));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GConfigCommand;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GConfigBaseCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length < 1) {
|
||||
return false;
|
||||
}
|
||||
return switch (args[0].toLowerCase()) {
|
||||
case "dump" -> Dump.subCommand((Player) sender);
|
||||
case "reload" -> Reload.subCommand();
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GConfigCommand;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GConfigTabCompleter implements TabCompleter {
|
||||
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("dump", "reload");
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
String partial = args[0].toLowerCase();
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
for (String subcommand : SUBCOMMANDS) {
|
||||
if (subcommand.startsWith(partial)) {
|
||||
suggestions.add(subcommand);
|
||||
}
|
||||
}
|
||||
return suggestions;
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GConfigCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Config.ConfigLoader;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Reload {
|
||||
public static boolean subCommand() {
|
||||
Shared.Broadcast("Reloading config...",null);
|
||||
ConfigLoader.loadConfigFromFile();
|
||||
GrimmsServer.logger.log(Level.INFO, "Config reloaded.");
|
||||
Shared.Broadcast("Config reloaded successfully.", null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ public class Delete {
|
|||
}
|
||||
|
||||
GrimmsServer.instance.getServer().unloadWorld(worldName, true);
|
||||
GrimmsServer.pds.deleteData(worldName, "worldConstructors");
|
||||
GrimmsServer.pds.deleteData(worldName + ".json", "worldConstructors");
|
||||
player.sendMessage("World '" + worldName + "' has been deleted.");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ public class GDimBaseCommand implements CommandExecutor {
|
|||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
String sub = args[0].toLowerCase();
|
||||
return switch (sub) {
|
||||
return switch (args[0].toLowerCase()) {
|
||||
case "create" -> Create.subCommand(player, args);
|
||||
case "delete" -> Delete.subCommand(player, args);
|
||||
case "tp" -> Tp.subCommand(player, args);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Action {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GFactionBaseCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)){
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
return switch (args[0].toLowerCase()) {
|
||||
case "invite" -> Invite.subCommand(player, args);
|
||||
case "modify" -> Modify.subCommand(player, args);
|
||||
case "join" -> Join.subCommand(player, args);
|
||||
case "leave" -> Leave.subCommand(player, args);
|
||||
case "kick" -> Kick.subCommand(player, args);
|
||||
case "info" -> Info.subCommand(player, args);
|
||||
case "new" -> New.subCommand(player, args);
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GFactionTabCompleter implements TabCompleter {
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Info {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Invite {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Join {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Kick {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Leave {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Modify {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class New {
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ public class LogLeaderboard {
|
|||
leaderBoard.checkPlayer(player);
|
||||
player.sendMessage("__Leaderboard:");
|
||||
for (String stat : leaderBoard.leaderboard.keySet()) {
|
||||
player.sendMessage("|Leader of stat " + PlayerStats.StatNames.get(stat) + " is " + leaderBoard.leaderboard.get(stat).getPlayerName() + " with " + leaderBoard.leaderboard.get(stat).getStatValue());
|
||||
player.sendMessage("|Leader of stat " + PlayerStats.StatNames.get(stat) + " is " + leaderBoard.leaderboard.get(stat).playerName() + " with " + leaderBoard.leaderboard.get(stat).statValue());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.gsdistance.grimmsServer.Config.ConfigLoader;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ReloadConfig implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
sender.sendMessage("Reloading config...");
|
||||
ConfigLoader.loadConfigFromFile();
|
||||
GrimmsServer.logger.log(Level.INFO, "Config reloaded.");
|
||||
sender.sendMessage("Config reloaded successfully.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,89 +2,29 @@ package org.gsdistance.grimmsServer.Config;
|
|||
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.List;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ActiveConfig {
|
||||
public static boolean module_Jobs = true;
|
||||
public static boolean module_Factions = true;
|
||||
public static boolean module_Market = true;
|
||||
public static boolean module_Leaderboard = true;
|
||||
public static String[] disabledCommands = new String[]{};
|
||||
public static boolean module_Chat = true;
|
||||
public static boolean module_Homes = true;
|
||||
public static boolean module_Leveling = true;
|
||||
public static boolean module_Titles = true;
|
||||
public static boolean module_Relics = true;
|
||||
public static boolean module_Events = true;
|
||||
public static boolean module_Utils = true;
|
||||
public static boolean module_Ranks = true;
|
||||
public static boolean joinMessage = true;
|
||||
public static boolean module_Dimensions = true;
|
||||
private static final Map<ConfigKey, Object> configValues = new HashMap<>();
|
||||
|
||||
public static void updateConfig(boolean module_Jobs, boolean module_Factions, boolean module_Market, boolean module_Leaderboard, List<String> disabledCommands, boolean module_Chat, boolean module_Homes, boolean module_Leveling, boolean module_Titles, boolean module_Relics, boolean module_Events, boolean module_Utils, boolean module_Ranks, boolean joinMessage, boolean module_Dimensions) {
|
||||
ActiveConfig.module_Jobs = module_Jobs;
|
||||
ActiveConfig.module_Factions = module_Factions;
|
||||
ActiveConfig.module_Market = module_Market;
|
||||
ActiveConfig.module_Leaderboard = module_Leaderboard;
|
||||
ActiveConfig.disabledCommands = disabledCommands.toArray(new String[0]);
|
||||
ActiveConfig.module_Chat = module_Chat;
|
||||
ActiveConfig.module_Homes = module_Homes;
|
||||
ActiveConfig.module_Leveling = module_Leveling;
|
||||
ActiveConfig.module_Titles = module_Titles;
|
||||
ActiveConfig.module_Relics = module_Relics;
|
||||
ActiveConfig.module_Events = module_Events;
|
||||
ActiveConfig.module_Utils = module_Utils;
|
||||
ActiveConfig.module_Ranks = module_Ranks;
|
||||
ActiveConfig.joinMessage = joinMessage;
|
||||
ActiveConfig.module_Dimensions = module_Dimensions;
|
||||
public static void setConfigValue(ConfigKey key, Object value) {
|
||||
configValues.put(key, value);
|
||||
}
|
||||
|
||||
// Log the status of each module
|
||||
if (!module_Jobs) {
|
||||
GrimmsServer.logger.info("Jobs module is disabled by config.");
|
||||
}
|
||||
if (!module_Factions) {
|
||||
GrimmsServer.logger.info("Factions module is disabled by config.");
|
||||
}
|
||||
if (!module_Market) {
|
||||
GrimmsServer.logger.info("Market module is disabled by config.");
|
||||
}
|
||||
if (!module_Leaderboard) {
|
||||
GrimmsServer.logger.info("Leaderboard module is disabled by config.");
|
||||
}
|
||||
if (!module_Chat) {
|
||||
GrimmsServer.logger.info("Chat module is disabled by config.");
|
||||
}
|
||||
if (!module_Homes) {
|
||||
GrimmsServer.logger.info("Homes module is disabled by config.");
|
||||
}
|
||||
if (!module_Leveling) {
|
||||
GrimmsServer.logger.info("Leveling module is disabled by config.");
|
||||
}
|
||||
if (!module_Titles) {
|
||||
GrimmsServer.logger.info("Titles module is disabled by config.");
|
||||
}
|
||||
if (!module_Relics) {
|
||||
GrimmsServer.logger.info("Relics module is disabled by config.");
|
||||
}
|
||||
if (!module_Events) {
|
||||
GrimmsServer.logger.info("Events module is disabled by config.");
|
||||
}
|
||||
if (!module_Utils) {
|
||||
GrimmsServer.logger.info("Utils module is disabled by config.");
|
||||
}
|
||||
if (disabledCommands.isEmpty()) {
|
||||
GrimmsServer.logger.info("No commands are disabled by config.");
|
||||
} else {
|
||||
GrimmsServer.logger.info("Disabled commands: " + String.join(", ", disabledCommands));
|
||||
}
|
||||
if (!module_Ranks) {
|
||||
GrimmsServer.logger.info("Ranks module is disabled by config.");
|
||||
}
|
||||
if (!joinMessage) {
|
||||
GrimmsServer.logger.info("Join message is disabled by config.");
|
||||
}
|
||||
if (!module_Dimensions) {
|
||||
GrimmsServer.logger.info("Dimensions module is disabled by config.");
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getConfigValue(ConfigKey key, Class<T> ignoredType) {
|
||||
try {
|
||||
return (T) configValues.getOrDefault(key, key.getDefaultValue());
|
||||
} catch (ClassCastException e) {
|
||||
GrimmsServer.logger.warning("Config value for " + key.getKey() + " is not of type " + ignoredType.getSimpleName() + ". Message: " + e.getMessage());
|
||||
try {
|
||||
return ignoredType.getDeclaredConstructor().newInstance();
|
||||
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException | InstantiationException ex) {
|
||||
GrimmsServer.logger.warning("Failed to instantiate default value for " + key.getKey() + ". Message: " + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package org.gsdistance.grimmsServer.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum ConfigKey {
|
||||
MODULE_JOBS("module_Jobs", true),
|
||||
MODULE_FACTIONS("module_Factions", true),
|
||||
MODULE_MARKET("module_Market", true),
|
||||
MODULE_LEADERBOARD("module_Leaderboard", true),
|
||||
DISABLED_COMMANDS("disabledCommands", new ArrayList<String>()),
|
||||
MODULE_CHAT("module_Chat", true),
|
||||
MODULE_HOMES("module_Homes", true),
|
||||
MODULE_LEVELING("module_Leveling", true),
|
||||
MODULE_TITLES("module_Titles", true),
|
||||
MODULE_RELICS("module_Relics", true),
|
||||
MODULE_EVENTS("module_Events", true),
|
||||
MODULE_UTILS("module_Utils", true),
|
||||
MODULE_RANKS("module_Ranks", true),
|
||||
JOIN_MESSAGE("joinMessage", true),
|
||||
MODULE_DIMENSIONS("module_Dimensions", true),
|
||||
DISABLED_DIMENSIONS("disabledDimensions", new ArrayList<String>()),
|
||||
FORCE_DISABLE_BC("forceDisableBroadcasts", false);
|
||||
|
||||
private final String key;
|
||||
private final Object defaultValue;
|
||||
|
||||
ConfigKey(String key, Object defaultValue) {
|
||||
this.key = key;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Object getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package org.gsdistance.grimmsServer.Config;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigLoader {
|
||||
private static FileConfiguration config;
|
||||
|
|
@ -20,28 +20,18 @@ public class ConfigLoader {
|
|||
}
|
||||
|
||||
public static void loadConfigFromFile() {
|
||||
Stopwatch sw = Stopwatch.createStarted();
|
||||
GrimmsServer.logger.info("Loading GrimmsServer config...");
|
||||
if (config == null) {
|
||||
GrimmsServer.logger.warning("Config somehow not initialized.");
|
||||
GrimmsServer.logger.warning("Config somehow not initialized. (" + sw.stop() + ")");
|
||||
return;
|
||||
}
|
||||
ActiveConfig.updateConfig(
|
||||
config.getBoolean("module_Jobs", true),
|
||||
config.getBoolean("module_Factions", true),
|
||||
config.getBoolean("module_Market", true),
|
||||
config.getBoolean("module_Leaderboard", true),
|
||||
config.getStringList("disabledCommands"),
|
||||
config.getBoolean("module_Chat", true),
|
||||
config.getBoolean("module_Homes", true),
|
||||
config.getBoolean("module_Leveling", true),
|
||||
config.getBoolean("module_Titles", true),
|
||||
config.getBoolean("module_Relics", true),
|
||||
config.getBoolean("module_Events", true),
|
||||
config.getBoolean("module_Utils", true),
|
||||
config.getBoolean("module_Ranks", true),
|
||||
config.getBoolean("joinMessage", true),
|
||||
config.getBoolean("module_Dimensions", true)
|
||||
);
|
||||
GrimmsServer.logger.info("GrimmsServer config loaded successfully.");
|
||||
|
||||
for (ConfigKey key : ConfigKey.values()) {
|
||||
Object value = config.get(key.getKey(), key.getDefaultValue());
|
||||
ActiveConfig.setConfigValue(key, value);
|
||||
}
|
||||
|
||||
GrimmsServer.logger.info("GrimmsServer config loaded successfully. (" + sw.stop() + ")");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package org.gsdistance.grimmsServer.Constructable;
|
||||
|
||||
public class Data<T1, T2> {
|
||||
public T1 data1;
|
||||
public T2 data2;
|
||||
|
||||
public Data(T1 data1, T2 data2) {
|
||||
this.data1 = data1;
|
||||
this.data2 = data2;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,24 @@
|
|||
package org.gsdistance.grimmsServer.Constructable;
|
||||
|
||||
public class Faction {
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.gsdistance.grimmsServer.Data.FactionRank;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Faction {
|
||||
public String name;
|
||||
public final String id;
|
||||
public final UUID uuid = UUID.randomUUID();
|
||||
public final List<Data<UUID, FactionRank>> members;
|
||||
public Faction(String id, List<Data<UUID, FactionRank>> members) {
|
||||
this.id = id;
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
public Faction loadFromFile(){
|
||||
return GrimmsServer.pds.retrieveData("","", Faction.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ public class ItemLevelHandler {
|
|||
public void changeLevel(double levelDelta) {
|
||||
double currentLevel = getLevel();
|
||||
dataHandler.setItemNBTData(LEVEL_KEY, currentLevel + levelDelta);
|
||||
dataHandler.setItemLoreData(List.of("Level: " + (currentLevel + levelDelta), "XP: " + Math.round(getXp()) + "/" + Math.round(getXpToLevel())));
|
||||
}
|
||||
|
||||
public void addXp(double xp) {
|
||||
|
|
@ -65,6 +64,7 @@ public class ItemLevelHandler {
|
|||
}
|
||||
|
||||
setXp(totalXp);
|
||||
dataHandler.setItemLoreData(List.of("Level: " + (getLevel()), "XP: " + Math.round(getXp()) + "/" + Math.round(getXpToLevel())));
|
||||
|
||||
if (levelUps > 0) {
|
||||
player.sendMessage("Your " + item.getType().name().toLowerCase() + " has leveled up to " + getLevel() + "!");
|
||||
|
|
|
|||
|
|
@ -1,27 +1,3 @@
|
|||
package org.gsdistance.grimmsServer.Constructable;
|
||||
|
||||
public class LeaderboardEntry {
|
||||
private String playerName;
|
||||
private Number statValue;
|
||||
|
||||
public LeaderboardEntry(String playerName, Number statValue) {
|
||||
this.playerName = playerName;
|
||||
this.statValue = statValue;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public void setPlayerName(String playerName) {
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public Number getStatValue() {
|
||||
return statValue;
|
||||
}
|
||||
|
||||
public void setStatValue(Number statValue) {
|
||||
this.statValue = statValue;
|
||||
}
|
||||
}
|
||||
public record LeaderboardEntry(String playerName, Number statValue) { }
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class PlayerMetadata {
|
|||
if (PerSessionDataStorage.dataStore.containsKey("metadata-" + player.getUniqueId())) {
|
||||
return (PlayerMetadata) PerSessionDataStorage.dataStore.get("metadata-" + player.getUniqueId()).keySet().toArray()[0];
|
||||
}
|
||||
PlayerMetadata metadata = (PlayerMetadata) GrimmsServer.pds.retrieveData(player.getUniqueId() + ".json", PlayerMetadata.class, "playerMetadata");
|
||||
PlayerMetadata metadata = GrimmsServer.pds.retrieveData(player.getUniqueId() + ".json", "playerMetadata", PlayerMetadata.class);
|
||||
if (metadata == null) {
|
||||
metadata = new PlayerMetadata(player);
|
||||
GrimmsServer.logger.info("Created new PlayerMetadata for " + player.getName());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package org.gsdistance.grimmsServer.Constructable;
|
||||
|
||||
public class RelicHandler {
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import javax.annotation.Nullable;
|
|||
public record WorldConstructor(String name, String type, boolean generateStructures, String worldType) {
|
||||
|
||||
public static WorldConstructor getWorldConstructor(String name) {
|
||||
return (WorldConstructor) GrimmsServer.pds.retrieveData(name + ".json", WorldConstructor.class, "worldConstructors");
|
||||
return GrimmsServer.pds.retrieveData(name + ".json", "worldConstructors", WorldConstructor.class);
|
||||
}
|
||||
|
||||
public static WorldConstructor[] getAllWorldConstructors() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -7,14 +7,16 @@ import org.gsdistance.grimmsServer.Data.PluginDataStorage;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ChunkLoadEvent {
|
||||
public static void Event(org.bukkit.event.world.ChunkLoadEvent event) {
|
||||
PluginDataStorage pluginDataStorage = new PluginDataStorage(GrimmsServer.instance);
|
||||
String name = event.getChunk().getWorld().getName() + "_" + event.getChunk().getX() + "_" + event.getChunk().getZ() + ".json";
|
||||
String name = event.getChunk().getX() + "_" + event.getChunk().getZ() + ".json";
|
||||
|
||||
if (!pluginDataStorage.exists(name, "chunkMetadata")) {
|
||||
if (!pluginDataStorage.exists(name, "chunkMetadata" + File.separatorChar + event.getWorld().getName())) {
|
||||
Player player = Shared.getClosestPlayer(new Location(event.getWorld(),event.getChunk().getX(), 0, event.getChunk().getZ()), event.getWorld().getPlayers());
|
||||
pluginDataStorage.saveData(new ChunkMetadata(event.getChunk(), null, player), ChunkMetadata.class, name, "chunkMetadata");
|
||||
pluginDataStorage.saveData(new ChunkMetadata(event.getChunk(), null, player), ChunkMetadata.class, name, "chunkMetadata" + File.separatorChar + event.getWorld().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Events;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.gsdistance.grimmsServer.Constructable.PlayerMetadata;
|
||||
|
|
@ -20,6 +21,7 @@ public class OnWorldSaveEvent {
|
|||
}
|
||||
|
||||
public static void saveData(){
|
||||
Stopwatch sw = Stopwatch.createStarted();
|
||||
// Save all temporary data
|
||||
GrimmsServer.logger.info("Saving temporary data...");
|
||||
for (Map<Object, Type> data : PerSessionDataStorage.dataStore.values()) {
|
||||
|
|
@ -28,6 +30,6 @@ public class OnWorldSaveEvent {
|
|||
((PlayerMetadata) data.keySet().iterator().next()).saveToPDS();
|
||||
}
|
||||
}
|
||||
GrimmsServer.logger.info("Done");
|
||||
GrimmsServer.logger.info("Done (" + sw.stop() + ")");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Events;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Indexers.DynamicDimensionGen;
|
||||
|
|
@ -10,16 +11,19 @@ import java.util.logging.Level;
|
|||
public class ServerStartupEvent {
|
||||
|
||||
public static void Event() {
|
||||
Stopwatch sw = Stopwatch.createStarted();
|
||||
CommandRegistry.registerCommands();
|
||||
GrimmsServer.instance.getServer().getScheduler().scheduleSyncRepeatingTask(GrimmsServer.instance, ServerTickEvent::Event, 100L, 1L);
|
||||
Bukkit.getScheduler().runTask(GrimmsServer.instance, () -> {
|
||||
Stopwatch swLoad = Stopwatch.createStarted();
|
||||
try {
|
||||
DynamicDimensionGen.loadWorlds();
|
||||
GrimmsServer.logger.log(Level.INFO, "Worlds loaded successfully.");
|
||||
GrimmsServer.logger.log(Level.INFO, "Worlds loaded successfully. (" + swLoad.stop() + ")");
|
||||
} catch (Exception e) {
|
||||
GrimmsServer.logger.severe("Failed to load worlds: " + e.getMessage());
|
||||
GrimmsServer.logger.severe("Failed to load worlds: " + e.getMessage() + "(" + swLoad.stop() + ")");
|
||||
}
|
||||
DynamicDimensionGen.unLoadWorlds();
|
||||
});
|
||||
GrimmsServer.logger.log(Level.INFO, "GrimmsServer has started successfully.");
|
||||
GrimmsServer.logger.log(Level.INFO, "GrimmsServer has started successfully. (" + sw.stop() + ")");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class ServerTickEvent {
|
|||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
String jobTitleId = (String) playerStats.getStat("jobTitle");
|
||||
if (jobTitleId != null && !jobTitleId.isEmpty()) {
|
||||
double payCheck = Math.ceil(JobTitlesBaseValues.jobTitleBaseValues.getOrDefault(jobTitleId, null).paycheckSize() * (1 + (Math.pow((double) playerStats.getStat("level"),2))/100));
|
||||
double payCheck = Math.ceil(JobTitlesBaseValues.jobTitleBaseValues.getOrDefault(jobTitleId, null).paycheckSize() * (1 + (Math.pow((Double) playerStats.getStat("level"),2))/100));
|
||||
playerStats.setStat("money", (Double) playerStats.getStat("money") + payCheck);
|
||||
player.sendMessage("You have received your paycheck: " + payCheck);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
package org.gsdistance.grimmsServer.Indexers;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.gsdistance.grimmsServer.Config.ConfigKey;
|
||||
import org.gsdistance.grimmsServer.Constructable.WorldConstructor;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.gsdistance.grimmsServer.Config.ActiveConfig.getConfigValue;
|
||||
|
||||
public class DynamicDimensionGen {
|
||||
public static void newDimension(WorldConstructor worldConstructor) {
|
||||
GrimmsServer.logger.info("Creating new world: " + worldConstructor.name() + " with type: " + worldConstructor.type());
|
||||
|
|
@ -47,4 +53,19 @@ public class DynamicDimensionGen {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void unLoadWorlds(){
|
||||
Stopwatch sw = Stopwatch.createStarted();
|
||||
GrimmsServer.logger.info("Unloading worlds...");
|
||||
for (String worldName : (List<String>)getConfigValue(ConfigKey.DISABLED_DIMENSIONS, List.class)){
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world != null) {
|
||||
GrimmsServer.logger.info("Unloading world: " + worldName);
|
||||
Bukkit.unloadWorld(world, false);
|
||||
} else {
|
||||
GrimmsServer.logger.warning("World with name '" + worldName + "' does not exist or is already unloaded.");
|
||||
}
|
||||
}
|
||||
GrimmsServer.logger.info("Unloaded worlds (" + sw.stop() + ")");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
package org.gsdistance.grimmsServer.Manage;
|
||||
|
||||
import org.gsdistance.grimmsServer.Commands.*;
|
||||
import org.gsdistance.grimmsServer.Commands.GConfigCommand.GConfigBaseCommand;
|
||||
import org.gsdistance.grimmsServer.Commands.GConfigCommand.GConfigTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.GFactionCommand.GFactionBaseCommand;
|
||||
import org.gsdistance.grimmsServer.Commands.GFactionCommand.GFactionTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.GDimensionCommand.GDimBaseCommand;
|
||||
import org.gsdistance.grimmsServer.Commands.GDimensionCommand.GDimTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.GLogCommand.GLogBaseCommand;
|
||||
|
|
@ -13,10 +17,14 @@ import org.gsdistance.grimmsServer.Commands.MarketComand.MarketBaseCommand;
|
|||
import org.gsdistance.grimmsServer.Commands.MarketComand.MarketTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.RequestCommand.AcceptRequest;
|
||||
import org.gsdistance.grimmsServer.Commands.RequestCommand.RequestTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Config.ActiveConfig;
|
||||
import org.gsdistance.grimmsServer.Config.ConfigKey;
|
||||
import org.gsdistance.grimmsServer.Data.ConfigRequirements;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.gsdistance.grimmsServer.Config.ActiveConfig.getConfigValue;
|
||||
|
||||
public class CommandRegistry {
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
public static void registerCommands() {
|
||||
|
|
@ -35,7 +43,6 @@ public class CommandRegistry {
|
|||
GrimmsServer.instance.getCommand("acceptRequest").setExecutor(new AcceptRequest());
|
||||
GrimmsServer.instance.getCommand("acceptRequest").setTabCompleter(new RequestTabCompleter());
|
||||
GrimmsServer.instance.getCommand("removeTitle").setExecutor(new RemoveTitle());
|
||||
GrimmsServer.instance.getCommand("reloadGrimmsConfig").setExecutor(new ReloadConfig());
|
||||
GrimmsServer.instance.getCommand("home").setExecutor(new HomeBaseCommand());
|
||||
GrimmsServer.instance.getCommand("home").setTabCompleter(new HomeTabCompleter());
|
||||
GrimmsServer.instance.getCommand("nick").setExecutor(new Nick());
|
||||
|
|
@ -47,15 +54,23 @@ public class CommandRegistry {
|
|||
GrimmsServer.instance.getCommand("gLog").setTabCompleter(new GLogTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gDim").setExecutor(new GDimBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gDim").setTabCompleter(new GDimTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gFaction").setExecutor(new GFactionBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gFaction").setTabCompleter(new GFactionTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gConfig").setExecutor(new GConfigBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gConfig").setTabCompleter(new GConfigTabCompleter());
|
||||
}
|
||||
|
||||
public static boolean CanExecute(String command) {
|
||||
if (command == null || command.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (String disabledCommand : ActiveConfig.disabledCommands) {
|
||||
if (disabledCommand.equalsIgnoreCase(command)) {
|
||||
return false;
|
||||
// Retrieve the disabled commands as a List
|
||||
List<String> disabledCommands = getConfigValue(ConfigKey.DISABLED_COMMANDS, List.class);
|
||||
if (disabledCommands != null) {
|
||||
for (String disabledCommand : disabledCommands) {
|
||||
if (disabledCommand.equalsIgnoreCase(command)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConfigRequirements.isCommandEnabled(command);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package org.gsdistance.grimmsServer.Manage;
|
||||
|
||||
public class GeneralChatHandler {
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package org.gsdistance.grimmsServer;
|
|||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Config.ConfigKey;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
|
|
@ -9,11 +10,16 @@ import java.util.List;
|
|||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static org.gsdistance.grimmsServer.Config.ActiveConfig.getConfigValue;
|
||||
import static org.gsdistance.grimmsServer.GrimmsServer.logger;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class Shared {
|
||||
public static void Broadcast(String message, @Nullable String prefix) {
|
||||
if(getConfigValue(ConfigKey.FORCE_DISABLE_BC, Boolean.class)) {
|
||||
logger.info("Broadcast is disabled by configuration.");
|
||||
return;
|
||||
}
|
||||
GrimmsServer.instance.getServer().broadcastMessage(("[" + GrimmsServer.instance.getDescription().getPrefix() + "-BC]: ") + (prefix == null ? "" : prefix) + message);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.google.gson.Gson;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.LeaderboardEntry;
|
||||
import org.gsdistance.grimmsServer.Data.PlayerTitleChecker;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -53,9 +52,9 @@ public class PlayerStatLeaderBoard {
|
|||
List<String> overtakes = new ArrayList<>();
|
||||
for (String stat : leaderboard.keySet()) {
|
||||
Number playerStatValue = (Number) playerStats.getStat(stat);
|
||||
Number leaderboardStatValue = leaderboard.get(stat).getStatValue();
|
||||
Number leaderboardStatValue = leaderboard.get(stat).statValue();
|
||||
if (playerStatValue != null && playerStatValue.doubleValue() > leaderboardStatValue.doubleValue()) {
|
||||
if (!player.getName().equalsIgnoreCase(leaderboard.get(stat).getPlayerName())) {
|
||||
if (!player.getName().equalsIgnoreCase(leaderboard.get(stat).playerName())) {
|
||||
overtakes.add(stat);
|
||||
}
|
||||
leaderboard.put(stat, new LeaderboardEntry(player.getName(), playerStatValue.intValue()));
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ public class ServerStats {
|
|||
|
||||
private void loadStats() {
|
||||
//noinspection unchecked
|
||||
stats = (Map<String, Object>) GrimmsServer.pds.retrieveData("server_stats.json", new TypeToken<Map<String, Object>>() {
|
||||
}.getType(), "");
|
||||
stats = (Map<String, Object>) GrimmsServer.pds.retrieveData("server_stats.json", "", Map.class);
|
||||
if (stats == null) {
|
||||
stats = new Hashtable<>();
|
||||
stats.put("market", new Gson().toJson(new Market())); // Initialize market stat
|
||||
|
|
|
|||
|
|
@ -14,3 +14,5 @@ module_Utils: true
|
|||
module_Ranks: true
|
||||
joinMessage: true
|
||||
module_Dimensions: true
|
||||
disabledDimensions: []
|
||||
forceDisableBroadcasts: false
|
||||
|
|
@ -59,14 +59,10 @@ commands:
|
|||
description: Removes a title from a player.
|
||||
usage: /removeTitle <player> <title>
|
||||
permission: grimmsserver.removeTitle
|
||||
faction:
|
||||
gFaction:
|
||||
description: Faction commands
|
||||
usage: /faction <command> <args>
|
||||
usage: /gFaction <command> <args>
|
||||
permission: grimmsserver.faction
|
||||
reloadGrimmsConfig:
|
||||
description: Reloads the GrimmsServer configuration.
|
||||
usage: /reloadGrimmsConfig
|
||||
permission: grimmsserver.reloadConfig
|
||||
home:
|
||||
description: Home commands
|
||||
usage: /home <command> <args>
|
||||
|
|
@ -91,6 +87,10 @@ commands:
|
|||
description: Utility commands.
|
||||
usage: /gUtil <command> [args]
|
||||
permission: grimmsserver.util
|
||||
gConfig:
|
||||
description: Configuration commands.
|
||||
usage: /gConfig <command> [args]
|
||||
permission: grimmsserver.config
|
||||
permissions:
|
||||
grimmsserver.sendMoney:
|
||||
description: Allows a player to send money to another player
|
||||
|
|
@ -140,9 +140,6 @@ permissions:
|
|||
grimmsserver.factionAdmin:
|
||||
description: Allows a player to use faction admin commands
|
||||
default: op
|
||||
grimmsserver.reloadConfig:
|
||||
description: Allows a player to reload the GrimmsServer configuration
|
||||
default: op
|
||||
grimmsserver.nick:
|
||||
description: Allows a player to change their own nickname
|
||||
default: true
|
||||
|
|
@ -182,3 +179,6 @@ permissions:
|
|||
grimmsserver.util:
|
||||
description: Allows a player to use utility commands
|
||||
default: op
|
||||
grimmsserver.config:
|
||||
description: Allows a player to use configuration commands
|
||||
default: op
|
||||
Loading…
Add table
Add a link
Reference in a new issue