Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复BlockMenu的save方法 将delete标记为过时 #854

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package me.mrCookieSlime.Slimefun.api.inventory;

import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.bakedlibs.dough.config.Config;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.logging.Level;
import org.bukkit.Location;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -77,18 +76,8 @@ public void save(Location l) {
return;
}

// To force CS-CoreLib to build the Inventory
this.getContents();

File file = new File("data-storage/Slimefun/stored-inventories/" + serializeLocation(l) + ".sfi");
Config cfg = new Config(file);
cfg.setValue("preset", preset.getID());

for (int slot : preset.getInventorySlots()) {
cfg.setValue(String.valueOf(slot), getItemInSlot(slot));
}

cfg.save();
SlimefunBlockData blockData = StorageCacheUtils.getBlock(location);
JWJUN233233 marked this conversation as resolved.
Show resolved Hide resolved
Slimefun.getDatabaseManager().getBlockDataController().saveBlockInventory(blockData);

changes = 0;
}
Expand Down Expand Up @@ -128,15 +117,11 @@ public void dropItems(Location l, int... slots) {
}
}

@Deprecated
public void delete(Location l) {
File file = new File("data-storage/Slimefun/stored-inventories/" + serializeLocation(l) + ".sfi");

if (file.exists()) {
try {
Files.delete(file.toPath());
} catch (IOException e) {
Slimefun.logger().log(Level.WARNING, e, () -> "Could not delete file \"" + file.getName() + '"');
}
}
Slimefun.logger()
.log(
Level.WARNING,
() -> "BlockMenu#delete(Location l) is not supported anymore. l is " + serializeLocation(l));
}
}
Loading