Skip to content

Commit

Permalink
Merge branch 'dev' into feat/universal-inventory
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
  • Loading branch information
StarWishsama committed Nov 9, 2024
2 parents 385137d + 78328f1 commit 711d351
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xzavier0722.mc.plugin.slimefun4.storage.util;

import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType;
import io.github.thebusybiscuit.slimefun4.core.debug.Debug;
import io.github.thebusybiscuit.slimefun4.core.debug.TestCase;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
Expand All @@ -21,7 +22,14 @@ public static String itemStack2String(ItemStack itemStack) {
var stream = new ByteArrayOutputStream();
try (var bs = new BukkitObjectOutputStream(stream)) {
bs.writeObject(itemStack);
return Base64Coder.encodeLines(stream.toByteArray());
var itemStr = Base64Coder.encodeLines(stream.toByteArray());

if (Slimefun.getDatabaseManager().getBlockDataStorageType() != StorageType.SQLITE
&& itemStr.length() > 65535) {
throw new IllegalArgumentException("ItemStack too large");
}

return itemStr;
} catch (IOException e) {
e.printStackTrace();
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ public void openScript(Player p, SlimefunUniversalBlockData uniData, String sour
String[] script = CommonPatterns.DASH.split(sourceCode);

for (int i = 1; i < script.length; i++) {

int index = i;

if (i == script.length - 1) {
Expand Down Expand Up @@ -1030,6 +1029,16 @@ protected void move(Block from, BlockFace face, Block to) {

Slimefun.getTickerTask().disableTicker(from.getLocation());

// Bro encountered a ghost 💀
if (StorageCacheUtils.hasBlock(to.getLocation())) {
var data = StorageCacheUtils.getBlock(to.getLocation());
if (data != null && !data.isPendingRemove()) {
// Since it's a ghost, we just hunt it.
Slimefun.getDatabaseManager().getBlockDataController().removeBlock(to.getLocation());
}
return;
}

to.setBlockData(Material.PLAYER_HEAD.createBlockData(data -> {
if (data instanceof Rotatable rotatable) {
rotatable.setRotation(face.getOppositeFace());
Expand Down

0 comments on commit 711d351

Please sign in to comment.