File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed
module/bukkit/ui/src/main/java/crypticlib/ui/menu
platform/bukkit/src/main/java/crypticlib/util Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 11java.sourceCompatibility = JavaVersion .VERSION_1_8
22java.targetCompatibility = JavaVersion .VERSION_1_8
33rootProject.group = " com.crypticlib"
4- rootProject.version = " 1.13.6 .0"
4+ rootProject.version = " 1.13.7 .0"
55// 全项目重构时更新大版本号
66// 添加模块或有较大更改时更新次版本号
77// 有API变动(新增/删除/更改声明)时更新修订号
Original file line number Diff line number Diff line change @@ -172,7 +172,10 @@ public void onLayoutUpdated() {}
172172 */
173173 public void updateMenuIcons () {
174174 if (inventoryCache != null ) {
175- inventoryCache .clear ();
175+ //只把有按钮的槽位清空
176+ slotMap .forEach ((slot , icon ) -> {
177+ inventoryCache .setItem (slot , new ItemStack (Material .AIR ));
178+ });
176179 draw (inventoryCache );
177180 }
178181 }
Original file line number Diff line number Diff line change 1+ package crypticlib .util ;
2+
3+ import org .bukkit .Location ;
4+ import org .bukkit .inventory .Inventory ;
5+ import org .bukkit .inventory .ItemStack ;
6+
7+ import java .util .HashMap ;
8+
9+ public class InventoryHelper {
10+
11+ /**
12+ * 将一堆物品放入某个容器中,如果容器放不下则丢在地上
13+ * @param inventory 要添加物品的容器
14+ * @param items 要添加的物品
15+ */
16+ public static void addItemOrDrop (Inventory inventory , ItemStack ... items ) {
17+ HashMap <Integer , ItemStack > failed = inventory .addItem (items );
18+ Location location = inventory .getLocation ();
19+ if (location == null ) {
20+ //如果一个容器没有坐标,那么其大概率为虚拟容器,此时直接不再处理添加失败的物品
21+ return ;
22+ }
23+ failed .forEach ((_slot , item ) -> {
24+ location .getWorld ().dropItem (location , item );
25+ });
26+ }
27+
28+ }
You can’t perform that action at this time.
0 commit comments