Skip to content

Commit

Permalink
Merge from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Dec 24, 2024
2 parents 6cc2b49 + 2017d3d commit 1932f89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ public SlimefunUniversalBlockData createUniversalBlock(Location l, String sfId)

uniData.setIsDataLoaded(true);

uniData.initLastPresent();

loadedUniversalData.put(uuid, uniData);

UniversalMenuPreset preset = UniversalMenuPreset.getPreset(sfId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils;
import io.github.bakedlibs.dough.blocks.BlockPosition;
import java.util.UUID;
import java.util.logging.Level;

import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import org.bukkit.Location;

public class SlimefunUniversalBlockData extends SlimefunUniversalData {
Expand All @@ -20,13 +17,16 @@ public SlimefunUniversalBlockData(UUID uuid, String sfId, BlockPosition present)
super(uuid, sfId);

this.lastPresent = present;
setTraitData(UniversalDataTrait.BLOCK, LocationUtils.locationToString(lastPresent.toLocation()));
}

public SlimefunUniversalBlockData(UUID uuid, String sfId, Location present) {
this(uuid, sfId, new BlockPosition(present));
}

public void initLastPresent() {
setTraitData(UniversalDataTrait.BLOCK, LocationUtils.locationToString(lastPresent.toLocation()));
}

public void setLastPresent(BlockPosition lastPresent) {
setTraitData(UniversalDataTrait.BLOCK, LocationUtils.locationToString(lastPresent.toLocation()));
this.lastPresent = lastPresent;
Expand All @@ -37,14 +37,17 @@ public void setLastPresent(Location l) {
}

public BlockPosition getLastPresent() {
String data = getData(UniversalDataTrait.BLOCK.getReservedKey());

if (lastPresent != null) {
if (data == null) {
setTraitData(UniversalDataTrait.BLOCK, LocationUtils.locationToString(lastPresent.toLocation()));
}

return lastPresent;
}

String data = getData("location");

if (data == null) {
Slimefun.logger().log(Level.WARNING.WARNING, "UniversalBlockData [" + getUUID() + "] missing location data");
return null;
}

Expand Down

0 comments on commit 1932f89

Please sign in to comment.