Skip to content

Commit 4b036e7

Browse files
committed
チェストのやつ
1 parent 630adc6 commit 4b036e7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/java/com/github/elic0de/hungergames/chest/DeathChest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ private void restoreChest() {
3939
}
4040
}
4141

42+
public void updateChestContents(Block block, ItemStack[] contents) {
43+
if (chestLocations.containsKey(block)) chestLocations.put(block, contents);
44+
}
45+
4246
public boolean containsDeathChest(Block block) {
4347
return chestLocations.containsKey(block);
4448
}

src/main/java/com/github/elic0de/hungergames/menu/DeathChestMenu.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
import de.themoep.inventorygui.GuiStorageElement;
55
import de.themoep.inventorygui.InventoryGui;
66
import org.bukkit.Bukkit;
7+
import org.bukkit.block.Block;
78
import org.bukkit.entity.Player;
89
import org.bukkit.inventory.Inventory;
910
import org.bukkit.inventory.ItemStack;
1011

12+
import java.util.Optional;
13+
1114
public class DeathChestMenu {
1215

1316
private final InventoryGui menu;
@@ -28,8 +31,13 @@ public DeathChestMenu(ItemStack[] contents, Player player) {
2831
Inventory inv = Bukkit.createInventory(null, 54);
2932
inv.setContents(contents);
3033
menu.addElement(new GuiStorageElement('p', inv));
31-
menu.setCloseAction(close -> false);
32-
34+
menu.setCloseAction(close -> {
35+
Block block = inv.getLocation().getBlock();
36+
if (block != null) {
37+
HungerGames.getInstance().getGame().getDeathChest().updateChestContents(block, inv.getContents());
38+
}
39+
return false;
40+
});
3341
}
3442

3543
public void show() {

0 commit comments

Comments
 (0)