Skip to content

Commit

Permalink
Fix englandish and some small changes to UUID in PlayerProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev committed Dec 20, 2023
1 parent 5c14b5f commit b13392a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/adr/0001-storage-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ new storage backends (such as binary storage, SQL, etc.) for things like
[PlayerProfile](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java), [BlockStorage](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java), etc.

We also want to be generally more efficient in the way we save and load data.
Today, we can to load way more than is required.
Today, we load way more than is required.
We can improve memory usage by only loading what we need, when we need it.

We will do this incrementally and at first, in an experimental context.
Expand Down Expand Up @@ -66,7 +66,7 @@ e.g. SQL may not support [`BlockStorage`](https://github.com/Slimefun/Slimefun4/

## Addons

The goal is that Addons will be able to use implement new storage backends
The goal is that Addons will be able to use and implement new storage backends
if they wish and also be extended so they can load/save things as they wish.

The first few iterations will not focus on Addon support. We want to ensure
Expand All @@ -87,7 +87,7 @@ The current plan looks like this:
* We want to load player data using the new storage layer with the current
data system.
* We'll want to monitor for any possible issues and generally refine
how this system and should look
how this system should look
* Phase 2 - Implement new experimental binary backend for [`PlayerProfile`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java).
* Create a new backend for binary storage
* Implement in an experimental capacity and allow users to opt-in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package io.github.thebusybiscuit.slimefun4.api.player;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
Expand Down Expand Up @@ -56,7 +54,7 @@
*/
public class PlayerProfile {

private final UUID uuid;
private final UUID ownerId;
private final String name;

private final Config configFile;
Expand All @@ -71,11 +69,11 @@ public class PlayerProfile {
private final PlayerData data;

protected PlayerProfile(@Nonnull OfflinePlayer p, PlayerData data) {
this.uuid = p.getUniqueId();
this.ownerId = p.getUniqueId();
this.name = p.getName();
this.data = data;

configFile = new Config("data-storage/Slimefun/Players/" + uuid.toString() + ".yml");
configFile = new Config("data-storage/Slimefun/Players/" + ownerId.toString() + ".yml");
}

/**
Expand Down Expand Up @@ -104,7 +102,7 @@ protected PlayerProfile(@Nonnull OfflinePlayer p, PlayerData data) {
* @return The {@link UUID} of our {@link PlayerProfile}
*/
public @Nonnull UUID getUUID() {
return uuid;
return ownerId;
}

/**
Expand All @@ -130,6 +128,7 @@ public boolean isDirty() {
* This method will save the Player's Researches and Backpacks to the hard drive
*/
public void save() {
Slimefun.getPlayerStorage().savePlayerData(this.ownerId, this.data);
dirty = false;
}

Expand Down Expand Up @@ -247,7 +246,7 @@ public final void markDirty() {
IntStream stream = IntStream.iterate(0, i -> i + 1).filter(i -> !configFile.contains("backpacks." + i + ".size"));
int id = stream.findFirst().getAsInt();

PlayerBackpack backpack = PlayerBackpack.newBackpack(this.uuid, id, size);
PlayerBackpack backpack = PlayerBackpack.newBackpack(this.ownerId, id, size);
this.data.addBackpack(backpack);

return backpack;
Expand Down Expand Up @@ -479,17 +478,17 @@ public PlayerData getPlayerData() {

@Override
public int hashCode() {
return uuid.hashCode();
return ownerId.hashCode();
}

@Override
public boolean equals(Object obj) {
return obj instanceof PlayerProfile profile && uuid.equals(profile.uuid);
return obj instanceof PlayerProfile profile && ownerId.equals(profile.ownerId);
}

@Override
public String toString() {
return "PlayerProfile {" + uuid + "}";
return "PlayerProfile {" + ownerId + "}";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import javax.annotation.Nonnull;

import java.io.IOException;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -30,7 +28,7 @@ public class LegacyStorage implements Storage {
@Override
public PlayerData loadPlayerData(@Nonnull UUID uuid) {
Config playerFile = new Config("data-storage/Slimefun/Players/" + uuid + ".yml");
// Not too sure why this is it's own file
// Not too sure why this is its own file
Config waypointsFile = new Config("data-storage/Slimefun/waypoints/" + uuid + ".yml");

// Load research
Expand Down Expand Up @@ -81,7 +79,7 @@ public PlayerData loadPlayerData(@Nonnull UUID uuid) {
@Override
public void savePlayerData(@Nonnull UUID uuid, @Nonnull PlayerData data) {
Config playerFile = new Config("data-storage/Slimefun/Players/" + uuid + ".yml");
// Not too sure why this is it's own file
// Not too sure why this is its own file
Config waypointsFile = new Config("data-storage/Slimefun/waypoints/" + uuid + ".yml");

// Save research
Expand Down

0 comments on commit b13392a

Please sign in to comment.