Skip to content

Commit

Permalink
feat: 补充适配
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Sep 8, 2024
1 parent 1da39f0 commit a2e58d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package io.github.sefiraat.networks.integrations;

import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.schntgaispock.slimehud.SlimeHUD;
import io.github.schntgaispock.slimehud.util.HudBuilder;
import io.github.schntgaispock.slimehud.waila.HudController;
import io.github.sefiraat.networks.network.stackcaches.QuantumCache;
import io.github.sefiraat.networks.slimefun.network.NetworkGreedyBlock;
import io.github.sefiraat.networks.slimefun.network.NetworkQuantumStorage;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class HudCallbacks {

private static final String EMPTY = "&7| 空";

public static void setup() {
HudController controller = SlimeHUD.getHudController();

Expand All @@ -30,7 +32,7 @@ public static void setup() {

controller.registerCustomHandler(NetworkGreedyBlock.class, request -> {
Location location = request.getLocation();
BlockMenu menu = BlockStorage.getInventory(location);
BlockMenu menu = StorageCacheUtils.getMenu(location);
if (menu == null) {
return EMPTY;
}
Expand All @@ -51,8 +53,8 @@ private static String format(ItemStack itemStack, int amount, int limit) {
String amountStr = HudBuilder.getAbbreviatedNumber(amount);
String limitStr = HudBuilder.getAbbreviatedNumber(limit);
String itemName = meta != null && meta.hasDisplayName()
? meta.getDisplayName()
: ChatUtils.humanize(itemStack.getType().name());
? meta.getDisplayName()
: ChatUtils.humanize(itemStack.getType().name());

return "&7| &f" + itemName + " &7| " + amountStr + "/" + limitStr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void prePlace(@Nonnull PlayerRightClickEvent event) {

for (BlockFace checkFace : CHECK_FACES) {
Block checkBlock = target.getRelative(checkFace);
SlimefunItem slimefunItem = BlockStorage.check(checkBlock);
SlimefunItem slimefunItem = StorageCacheUtils.getSfItem(checkBlock.getLocation());

// For directly adjacent controllers
if (slimefunItem instanceof NetworkController) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,4 @@ public static void setBlueprint(ItemStack blueprint, ItemStack[] recipe, ItemSta

blueprint.setItemMeta(itemMeta);
}

@Override
public boolean canStack(ItemMeta meta1, ItemMeta meta2) {
return meta1.getPersistentDataContainer().equals(meta2.getPersistentDataContainer());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.sefiraat.networks.slimefun.tools;

import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.sefiraat.networks.slimefun.network.AdminDebuggable;
import io.github.sefiraat.networks.utils.Theme;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
Expand All @@ -8,7 +9,6 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -36,9 +36,9 @@ protected void onUse(PlayerRightClickEvent e) {
if (optional.isPresent()) {
final Block block = optional.get();
final Player player = e.getPlayer();
final SlimefunItem slimefunItem = BlockStorage.check(block);
final SlimefunItem slimefunItem = StorageCacheUtils.getSfItem(block.getLocation());
if (!player.isOp()) {
player.sendMessage(Theme.ERROR + "该物品只能由OP玩家使用。");
player.sendMessage(Theme.ERROR + "该物品只能由 OP 玩家使用。");
return;
}
if (slimefunItem instanceof AdminDebuggable debuggable) {
Expand Down

0 comments on commit a2e58d2

Please sign in to comment.