1
0

fuck me components are ugly

This commit is contained in:
Lee
2024-03-27 01:27:23 +00:00
parent 8f5ec71cc2
commit c80d1318d6
4 changed files with 47 additions and 32 deletions

View File

@ -4,13 +4,17 @@ import cc.fascinated.Aetheria;
import cc.fascinated.playercolor.PlayerColor;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.UUID;
@Getter
@Getter @Log4j2
public class Account {
/**
@ -44,6 +48,7 @@ public class Account {
private final PlayerColor playerColorProfile;
public Account(UUID uuid) {
log.info("Loading account for " + uuid);
boolean newAccount = false;
this.uuid = uuid;
@ -64,15 +69,17 @@ public class Account {
if (newAccount) {
this.firstJoin = System.currentTimeMillis();
this.lastLogin = System.currentTimeMillis();
save(false); // Save default values
this.save(false); // Save default values
log.info("Created new account for " + this.uuid);
}
this.firstJoin = config.getLong("firstJoin");
this.lastLogin = config.getLong("lastLogin");
// Load profiles
this.playerColorProfile = config.contains("playerColor") ?
new PlayerColor(this, config.getConfigurationSection("playerColor")) : new PlayerColor(this);
this.playerColorProfile = new PlayerColor(this, this.getProfileSection("playerColor"));
log.info("Loaded account for " + this.uuid);
}
/**
@ -81,7 +88,7 @@ public class Account {
* @return the name
*/
public String getName() {
return getPlayer().getName();
return this.getPlayer().getName();
}
/**
@ -90,7 +97,7 @@ public class Account {
* @return the player
*/
public Player getPlayer() {
return org.bukkit.Bukkit.getPlayer(uuid);
return Bukkit.getPlayer(uuid);
}
/**
@ -102,6 +109,15 @@ public class Account {
getPlayer().sendPlainMessage(message);
}
/**
* Send a message to the player.
*
* @param component the message to send
*/
public void sendMessage(Component component) {
getPlayer().sendMessage(component);
}
/**
* Save a profile to the configuration.
*
@ -109,10 +125,18 @@ public class Account {
* @param key the key to save the profile under
*/
private void saveProfile(Profile profile, String key) {
key += "Profile"; // append "Profile" to the key to signify it's a profile
key = this.getProfileId(key); // append "Profile" to the key to signify it's a profile
profile.save(config.getConfigurationSection(key) == null ? config.createSection(key) : config.getConfigurationSection(key));
}
private ConfigurationSection getProfileSection(String key) {
return this.config.getConfigurationSection(this.getProfileId(key));
}
private String getProfileId(String key) {
return key + "Profile"; // append "Profile" to the key to signify it's a profile
}
@SneakyThrows
public void save(boolean saveProfiles) {
this.config.set("firstJoin", this.firstJoin);