Data -> FileData

This commit is contained in:
Oth3r 2024-07-23 12:27:01 -05:00
commit 7d06735b3c
9 changed files with 26 additions and 26 deletions

View file

@ -7,7 +7,7 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import one.oth3r.sit.file.Data;
import one.oth3r.sit.file.FileData;
import one.oth3r.sit.file.SittingConfig;
import one.oth3r.sit.file.HandSetting;
import org.jetbrains.annotations.Nullable;
@ -18,7 +18,7 @@ public class Logic {
if (player.isSneaking()) return false;
// if sitting on a stair and sit while seated off, false
if (Data.getSitEntity(player) != null && !Data.getServerConfig().isSitWhileSeated()) return false;
if (FileData.getSitEntity(player) != null && !FileData.getServerConfig().isSitWhileSeated()) return false;
// if hit result isnt null (check the hands of the player) & the player hand checker returns false (can't sit with the items in the hand), quit
if (hitResult != null) {
@ -46,7 +46,7 @@ public class Logic {
* checks the hands of the player and the items in each hand and sees if the player can sit down
*/
public static boolean checkHands(ServerPlayerEntity player) {
SittingConfig sittingConfig = Data.getPlayerSetting(player);
SittingConfig sittingConfig = FileData.getPlayerSetting(player);
// if can't sit with hand, false
if (!sittingConfig.canSitWithHand()) return false;
@ -71,7 +71,7 @@ public class Logic {
* removes the entity from the game, using the player
*/
public static void removeEntity(ServerPlayerEntity player) {
DisplayEntity.TextDisplayEntity entity = Data.getSitEntity(player);
DisplayEntity.TextDisplayEntity entity = FileData.getSitEntity(player);
// make sure the player has a sit entity bounded to them
if (entity == null) return;
@ -83,7 +83,7 @@ public class Logic {
* checks if the player should still be sitting, e.g. the block was destroyed ect.
*/
public static void checkSittingValidity(ServerPlayerEntity player) {
DisplayEntity.TextDisplayEntity entity = Data.getSitEntity(player);
DisplayEntity.TextDisplayEntity entity = FileData.getSitEntity(player);
// make sure the player has a sit entity bounded to them
if (entity == null) return;
@ -114,7 +114,7 @@ public class Logic {
* reloads the config files
*/
public static void reload() {
Data.loadFiles(false);
FileData.loadFiles(false);
}
}

View file

@ -4,7 +4,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.DisplayEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import one.oth3r.sit.Sit;
import one.oth3r.sit.file.Data;
import one.oth3r.sit.file.FileData;
import java.util.HashMap;
@ -18,7 +18,7 @@ public class LoopManager {
time = 0;
// check all sit entities to make sure their still valid
HashMap<ServerPlayerEntity, DisplayEntity.TextDisplayEntity> entities = Data.getSitEntities();
HashMap<ServerPlayerEntity, DisplayEntity.TextDisplayEntity> entities = FileData.getSitEntities();
for (ServerPlayerEntity player : entities.keySet()) {
DisplayEntity.TextDisplayEntity entity = entities.get(player);
@ -31,23 +31,23 @@ public class LoopManager {
// get the player's sit entity when they join
// todo make it so it updates the sitting height and pos based on the block so if it changed while offline it still works (or if stair changes shape)
HashMap<ServerPlayerEntity, Integer> checkPlayers = Data.getCheckPlayers();
HashMap<ServerPlayerEntity, Integer> checkPlayers = FileData.getCheckPlayers();
for (ServerPlayerEntity player : checkPlayers.keySet()) {
Integer time = checkPlayers.get(player);
// tick down or remove the player if at the end
time -= 1;
if (time <= 0) Data.removeCheckPlayer(player);
else Data.setCheckPlayer(player, time);
if (time <= 0) FileData.removeCheckPlayer(player);
else FileData.setCheckPlayer(player, time);
if (player.getVehicle() != null) {
Entity entity = player.getVehicle();
if (entity instanceof DisplayEntity.TextDisplayEntity tde && entity.getName().getString().equals(Sit.ENTITY_NAME)) {
// bind the entity to the player
Data.addSitEntity(player, tde);
FileData.addSitEntity(player, tde);
// check if the player is still allowed to sit
Logic.checkSittingValidity(player);
// remove the player from the check
Data.removeCheckPlayer(player);
FileData.removeCheckPlayer(player);
}
}
}

View file

@ -150,7 +150,7 @@ public class Utl {
* @return null if not a valid block
*/
public static Double getSittingHeight(BlockState blockState, ServerPlayerEntity player, BlockPos blockPos, @Nullable BlockHitResult hit) {
ServerConfig config = Data.getServerConfig();
ServerConfig config = FileData.getServerConfig();
Block block = blockState.getBlock();
// only if custom is enabled
@ -254,7 +254,7 @@ public class Utl {
// remove the entity
entity.setRemoved(net.minecraft.entity.Entity.RemovalReason.DISCARDED);
// remove the entity from the data set if exists
Data.removeSitEntity(entity);
FileData.removeSitEntity(entity);
}
/**
@ -264,7 +264,7 @@ public class Utl {
player.getServerWorld().spawnEntity(entity);
player.startRiding(entity);
// add the entity to the list
Data.addSitEntity(player, entity);
FileData.addSitEntity(player, entity);
}
/**