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

Inventory - prevent opening a non-creatable inventory #7279

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/effects/EffOpenInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ protected void execute(final Event e) {
Object o = invi.getSingle(e);
if (o instanceof Inventory) {
i = (Inventory) o;
} else if (o instanceof InventoryType) {
i = Bukkit.createInventory(null, (InventoryType) o);
} else if (o instanceof InventoryType inventoryType && inventoryType.isCreatable()) {
i = Bukkit.createInventory(null, inventoryType);
} else {
return;
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/ch/njol/skript/expressions/ExprNamed.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ protected Object[] get(final Event e, final Object[] source) {
@Override
@Nullable
public Object get(Object obj) {
if (obj instanceof InventoryType)
return Bukkit.createInventory(null, (InventoryType) obj, name);
if (obj instanceof InventoryType inventoryType) {
if (!inventoryType.isCreatable())
return null;
return Bukkit.createInventory(null, inventoryType, name);
}
if (obj instanceof ItemStack) {
ItemStack stack = (ItemStack) obj;
stack = stack.clone();
Expand Down
Loading