Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

关于团队公用箱子 #1

Closed
xiaohuihui1022 opened this issue Jan 15, 2023 · 2 comments
Closed

关于团队公用箱子 #1

xiaohuihui1022 opened this issue Jan 15, 2023 · 2 comments

Comments

@xiaohuihui1022
Copy link

xiaohuihui1022 commented Jan 15, 2023

我想的是能不能在主类里新建两个inventory,并设置成public static。

// Main.java
public static Inventory team1 = Bukkit.createInventory(null, 54, "team1");
public static Inventory team2 = Bukkit.createInventory(null, 54, "team2");

然后再在玩家按下组合键打开GUI的时候直接给玩家显示主类里那个inventory

player.openInventory(Main.team1);

这样一个team里的玩家就能打开同一个inventory。
并且可以还原视频里的效果qwq

@FoliageOwO
Copy link
Owner

不行,我试过了。

首先,这个 Inventory 就不能进行存储操作,也就是只能读不能写,否则物品会直接消失。

其次,玩家 1Inventory 进行的操作(拿取)不会同步到 玩家 2,即使是同一个 Inventory 对象。

所以这个需求没有想象中的那么简单。

@xiaohuihui1022
Copy link
Author

emmmm,但是我中午的时候写了个插件试了试,本地双开mc,然后玩家1和2都打开team1的inventory,然后玩家1往里面放了一组草方块,玩家2也会被同步,玩家2也可以把他拿出来,或者他们都关掉gui,下次打开的时候草方块还在

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants