Spawn Management System Updates

This commit is contained in:
Trixkz 2023-10-25 19:40:49 -04:00
parent 9ff8cad8fd
commit 24d2c9cb36
4 changed files with 14 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package com.loganmagnan.eventcore.commands;
import com.loganmagnan.eventcore.EventCore;
import com.loganmagnan.eventcore.utils.ColorUtils;
import com.loganmagnan.eventcore.utils.Constants;
import com.loganmagnan.eventcore.utils.CustomLocation;
import com.loganmagnan.eventcore.utils.command.BaseCommand;
import com.loganmagnan.eventcore.utils.command.Command;
@ -23,15 +24,15 @@ public class SetSpawnCommand extends BaseCommand {
if (args.length == 0) {
this.main.getSpawnManager().setSpawnLocation(CustomLocation.fromBukkitLocation(player.getLocation()));
this.saveLocation(player, "spawn.location");
this.saveLocation(player, "SPAWN.LOCATION");
player.sendMessage(ColorUtils.getMessageType("&aSet the spawn location"));
player.sendMessage(ColorUtils.getMessageType(Constants.COMMAND_MESSAGES.get("set-spawn.spawn-set").get(0)));
}
}
public void saveLocation(Player player, String location) {
FileConfiguration config = this.main.getMainConfig().getConfig();
config.set(location, CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
FileConfiguration fileConfiguration = this.main.getMainConfig().getConfig();
fileConfiguration.set(location, CustomLocation.locationToString(CustomLocation.fromBukkitLocation(player.getLocation())));
this.main.getMainConfig().save();
}

View File

@ -23,17 +23,17 @@ public class SpawnManager {
}
private void loadConfig() {
if (this.config.contains("spawn.location")) {
if (this.config.contains("SPAWN.LOCATION")) {
try {
this.spawnLocation = CustomLocation.stringToLocation(this.config.getString("spawn.location"));
this.spawnLocation = CustomLocation.stringToLocation(this.config.getString("SPAWN.LOCATION"));
} catch (NullPointerException exception) {
Bukkit.getConsoleSender().sendMessage(ColorUtils.getMessageType("&cSpawn location not found"));
this.main.getServer().getConsoleSender().sendMessage(ColorUtils.getMessageType("&cSpawn location not found"));
}
}
}
public void saveConfig() {
this.config.set("spawn.location", CustomLocation.locationToString(this.spawnLocation));
this.config.set("SPAWN.LOCATION", CustomLocation.locationToString(this.spawnLocation));
this.main.getMainConfig().save();
}
}

View File

@ -21,6 +21,9 @@ public class Constants {
COMMAND_MESSAGES.put("chat.slow.invalid-argument", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.CHAT.SLOW.INVALID-ARGUMENT")));
COMMAND_MESSAGES.put("chat.slow.invalid-amount", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.CHAT.SLOW.INVALID-AMOUNT")));
// /setspawn
COMMAND_MESSAGES.put("set-spawn.spawn-set", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.SET-SPAWN.SPAWN-SET")));
// AsyncPlayerChatEvent
LISTENER_MESSAGES.put("chat-muted", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.LISTENERS.CHAT-MUTED")));
LISTENER_MESSAGES.put("chat-cooldown", this.main.getMessagesConfig().getConfig().getStringList("MESSAGES.LISTENERS.CHAT-COOLDOWN"));

View File

@ -14,6 +14,8 @@ MESSAGES:
SLOW:
INVALID-ARGUMENT: "&cEnter an amount of time to slow the chat for"
INVALID-AMOUNT: "&cEnter a valid amount of time to slow the chat for"
SET-SPAWN: # Permission Node - eventcore.command.setspawn
SPAWN-SET: "&aSet the spawn location"
LISTENERS:
CHAT-MUTED: "&cChat is muted"
CHAT-COOLDOWN: