mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixed #3664
This commit is contained in:
parent
ea029439ce
commit
497a4af1c5
@ -57,6 +57,7 @@
|
||||
* Fixed an issue related to "Bee Wings"
|
||||
* Fixed #3573
|
||||
* Fixed "round-robin" mode for cargo networks being very unreliable
|
||||
* Fixed #3664
|
||||
|
||||
## Release Candidate 32 (26 Jun 2022)
|
||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#32
|
||||
|
@ -1,10 +1,13 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -132,6 +135,20 @@ public class PlayerBackpack {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This will close the {@link Inventory} of this backpack for every {@link Player}
|
||||
* that has opened it.
|
||||
*/
|
||||
public void closeForAll() {
|
||||
Slimefun.runSync(() -> {
|
||||
Iterator<HumanEntity> iterator = new ArrayList<>(inventory.getViewers()).iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next().closeInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This will change the current size of this Backpack to the specified size.
|
||||
*
|
||||
|
@ -123,7 +123,11 @@ abstract class AbstractCraftingTable extends MultiBlockMachine {
|
||||
|
||||
PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> {
|
||||
Optional<PlayerBackpack> optional = profile.getBackpack(Integer.parseInt(idSplit[1]));
|
||||
optional.ifPresent(playerBackpack -> playerBackpack.setSize(size));
|
||||
optional.ifPresent(playerBackpack -> {
|
||||
// Safety feature for Issue #3664
|
||||
playerBackpack.closeForAll();
|
||||
playerBackpack.setSize(size);
|
||||
});
|
||||
});
|
||||
|
||||
return Optional.of(id);
|
||||
|
@ -96,6 +96,7 @@ public class BackpackListener implements Listener {
|
||||
|
||||
if (backpack instanceof SlimefunBackpack slimefunBackpack) {
|
||||
if (e.getClick() == ClickType.NUMBER_KEY) {
|
||||
// Prevent disallowed items from being moved using number keys.
|
||||
if (e.getClickedInventory().getType() != InventoryType.PLAYER) {
|
||||
ItemStack hotbarItem = e.getWhoClicked().getInventory().getItem(e.getHotbarButton());
|
||||
|
||||
@ -103,12 +104,19 @@ public class BackpackListener implements Listener {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (e.getClick() == ClickType.SWAP_OFFHAND && e.getClickedInventory().getType() != InventoryType.PLAYER) {
|
||||
// Fixes #3265
|
||||
ItemStack offHandItem = e.getWhoClicked().getInventory().getItemInOffHand();
|
||||
} else if (e.getClick() == ClickType.SWAP_OFFHAND) {
|
||||
if (e.getClickedInventory().getType() != InventoryType.PLAYER) {
|
||||
// Fixes #3265 - Don't move disallowed items using the off hand.
|
||||
ItemStack offHandItem = e.getWhoClicked().getInventory().getItemInOffHand();
|
||||
|
||||
if (!isAllowed(slimefunBackpack, offHandItem)) {
|
||||
e.setCancelled(true);
|
||||
if (!isAllowed(slimefunBackpack, offHandItem)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
// Fixes #3664 - Do not swap the backpack to your off hand.
|
||||
if (e.getCurrentItem() != null && e.getCurrentItem().isSimilar(item)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (!isAllowed(slimefunBackpack, e.getCurrentItem())) {
|
||||
e.setCancelled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user