Skip to content

Commit

Permalink
chore: use more friendly warning in user side
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Jan 14, 2025
1 parent c071894 commit 089e3e5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,15 @@ private void scheduleBlockInvUpdate(ScopeKey scopeKey, RecordKey reqKey, String
if (item == null) {
scheduleDeleteTask(scopeKey, reqKey, true);
} else {
var data = new RecordSet();
data.put(FieldKey.LOCATION, lKey);
data.put(FieldKey.INVENTORY_SLOT, slot + "");
data.put(FieldKey.INVENTORY_ITEM, item);
scheduleWriteTask(scopeKey, reqKey, data, true);
try {
var data = new RecordSet();
data.put(FieldKey.LOCATION, lKey);
data.put(FieldKey.INVENTORY_SLOT, slot + "");
data.put(FieldKey.INVENTORY_ITEM, item);
scheduleWriteTask(scopeKey, reqKey, data, true);
} catch (IllegalArgumentException e) {
Slimefun.logger().log(Level.WARNING, e.getMessage());
}
}
}

Expand Down Expand Up @@ -1132,11 +1136,15 @@ private void scheduleUniversalInvUpdate(ScopeKey scopeKey, RecordKey reqKey, UUI
if (item == null) {
scheduleDeleteTask(scopeKey, reqKey, true);
} else {
var data = new RecordSet();
data.put(FieldKey.UNIVERSAL_UUID, uuid.toString());
data.put(FieldKey.INVENTORY_SLOT, slot + "");
data.put(FieldKey.INVENTORY_ITEM, item);
scheduleWriteTask(scopeKey, reqKey, data, true);
try {
var data = new RecordSet();
data.put(FieldKey.UNIVERSAL_UUID, uuid.toString());
data.put(FieldKey.INVENTORY_SLOT, slot + "");
data.put(FieldKey.INVENTORY_ITEM, item);
scheduleWriteTask(scopeKey, reqKey, data, true);
} catch (IllegalArgumentException e) {
Slimefun.logger().log(Level.WARNING, e.getMessage());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -275,11 +277,15 @@ public void saveBackpackInventory(PlayerBackpack bp, Set<Integer> slots) {
if (is == null) {
scheduleDeleteTask(new UUIDKey(DataScope.NONE, bp.getOwner().getUniqueId()), key, false);
} else {
var data = new RecordSet();
data.put(FieldKey.BACKPACK_ID, id);
data.put(FieldKey.INVENTORY_SLOT, slot + "");
data.put(FieldKey.INVENTORY_ITEM, is);
scheduleWriteTask(new UUIDKey(DataScope.NONE, bp.getOwner().getUniqueId()), key, data, false);
try {
var data = new RecordSet();
data.put(FieldKey.BACKPACK_ID, id);
data.put(FieldKey.INVENTORY_SLOT, slot + "");
data.put(FieldKey.INVENTORY_ITEM, is);
scheduleWriteTask(new UUIDKey(DataScope.NONE, bp.getOwner().getUniqueId()), key, data, false);
} catch (IllegalArgumentException e) {
Slimefun.logger().log(Level.WARNING, e.getMessage());
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class DataUtils {
public static String itemStack2String(ItemStack itemStack) {
Debug.log(TestCase.BACKPACK, "Serializing itemstack: " + itemStack);

if (itemStack == null) {
return "";
}

var stream = new ByteArrayOutputStream();
try (var bs = new BukkitObjectOutputStream(stream)) {
bs.writeObject(itemStack);
Expand Down

0 comments on commit 089e3e5

Please sign in to comment.