* Add IslandTop command with refresh cooldown

The "IslandTop" command has been added. This provides a sorted list of top-performing islands. A configuration for refresh cooldown was also added. The sorted island list is updated once the specified minutes in the configuration have passed to improve performance. The ranking display for the player's island is highlighted in green text.

* Update IslandTop command

On plugin startup the IslandData is now loaded in. IslandData was moved to its own file and gets updated when a new island is created or when one levels up. The IslandData gets deleted when the owner leaves the island, destroying it.

* Update island name formatting in IslandData

The method which formats island name in IslandData class has been updated. If the island name is null, it now defaults to "Unnamed Island". This adjustment makes the information clearer when the island name is not defined.

* Set default name for islands during creation

Ensured that the 'owner' method in the 'Island' class set's the island name when an owner is set/changed. This will only happen if the island name is either null or blank. This is done to ensure island's always have a name when created.
This commit is contained in:
Stijn 2024-02-20 03:50:21 +01:00 committed by GitHub
parent 4b2cadb419
commit b78736fcc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -134,6 +134,10 @@ public class Island extends YamlConfiguration {
public void owner(UUID uuid) {
set("island.owner", uuid.toString());
String islandName = islandName();
if ((islandName == null || islandName.isBlank()) && !uuid.equals(NILL_UUID)) {
islandName(Bukkit.getOfflinePlayer(uuid).getName() + "'s island");
}
save();
}

View File

@ -74,6 +74,6 @@ public record IslandData(int islandId, String name, int level) {
}
public String format() {
return name + " - " + level;
return name == null ? "Unnamed Island" : name + " - " + level;
}
}