1
0

fix logs and first join message

This commit is contained in:
Lee
2024-03-30 09:57:01 +00:00
parent 641e40b35d
commit e3bd0b7c15
5 changed files with 37 additions and 23 deletions

View File

@ -11,6 +11,7 @@ import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -52,13 +53,13 @@ public class Account {
*/
private final PlayerColor playerColorProfile;
public Account(UUID uuid) {
public Account(Player player) {
//log.info("Loading account for " + uuid);
boolean newAccount = false;
this.uuid = uuid;
this.uuid = player.getUniqueId();
File file = new File(Aetheria.INSTANCE.getDataFolder(), "accounts/" + this.uuid.toString() + ".yml");
File file = new File(Aetheria.INSTANCE.getDataFolder(), "accounts/" + this.uuid + ".yml");
this.file = file;
if (!file.exists()) {
newAccount = true;
@ -79,7 +80,7 @@ public class Account {
log.info("Created new account for " + this.uuid);
Bukkit.broadcast(Style.getMiniMessage().deserialize(Lang.FIRST_JOIN_MESSAGE.getAsString()
.replace("%player%", this.getName())
.replace("%player%", player.getName())
));
Aetheria.EXECUTOR.execute(() -> {
@ -87,7 +88,7 @@ public class Account {
DiscordWebhook discordWebhook = new DiscordWebhook(Config.DISCORD_LOG_WEBHOOK.getAsString());
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject();
embed.setTitle("New Player Joined");
embed.addField("Name", Bukkit.getOfflinePlayer(uuid).getName(), true);
embed.addField("Name", player.getName(), true);
embed.addField("UUID", uuid.toString(), true);
discordWebhook.addEmbed(embed);
@ -128,6 +129,15 @@ public class Account {
return Bukkit.getPlayer(uuid);
}
/**
* Get the offline player for this account.
*
* @return the offline player
*/
public OfflinePlayer getOfflinePlayer() {
return Bukkit.getOfflinePlayer(uuid);
}
/**
* Send a message to the player.
*