Skip to content

Commit

Permalink
make saving and loading data async
Browse files Browse the repository at this point in the history
  • Loading branch information
Inf1nityy committed Aug 21, 2024
1 parent 7977015 commit 96980fd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.stats.Stats;

import java.util.Objects;
import java.util.concurrent.CompletableFuture;

import static com.nexia.discord.NexiaDiscord.jda;

Expand All @@ -31,7 +32,7 @@ public void registerListener() {

//setJoinMessage(player, playerJoinEvent);

PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.addPlayerData(player));
CompletableFuture.runAsync(() -> PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.addPlayerData(player)));

LobbyUtil.returnToLobby(player, true);
checkBooster(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.nexia.nexus.api.event.player.PlayerDisconnectEvent;
import net.kyori.adventure.text.Component;

import java.util.concurrent.CompletableFuture;

public class PlayerLeaveListener {
public void registerListener() {
PlayerDisconnectEvent.BACKEND.register(playerDisconnectEvent -> {
Expand All @@ -15,7 +17,7 @@ public void registerListener() {
//setLeaveMessage(player, playerDisconnectEvent);

if (playerDisconnectEvent.getPlayer().hasTag("bot")) return;
PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.removePlayerData(player));
CompletableFuture.runAsync(() -> PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.removePlayerData(player)));
});
}

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/nexia/core/mixin/player/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemCooldowns;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -38,8 +37,6 @@ public abstract class PlayerMixin extends LivingEntity {

@Shadow @Final public Inventory inventory;

@Shadow public abstract ItemCooldowns getCooldowns();

protected PlayerMixin(EntityType<? extends LivingEntity> entityType, Level level) {
super(entityType, level);
}
Expand Down

0 comments on commit 96980fd

Please sign in to comment.