More fixes for the kit editor losing your items.

This commit is contained in:
Brianna 2020-03-24 10:58:55 -04:00
parent 9f1eadced7
commit 84e3f947fb

View File

@ -52,9 +52,8 @@ public class KitEditorGui extends DoubleGui {
setInvItems(); setInvItems();
setOnClose((event) -> { setOnClose((event) -> {
this.saveKit(player, inventory, false);
if (!isInInventory)
restoreItemsInstance(); restoreItemsInstance();
this.saveKit(player, inventory, false);
CompatibleSound.ENTITY_VILLAGER_YES.play(player); CompatibleSound.ENTITY_VILLAGER_YES.play(player);
}); });
@ -72,7 +71,7 @@ public class KitEditorGui extends DoubleGui {
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR), setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
plugin.getLocale().getMessage("interface.button.exit").getMessage()), plugin.getLocale().getMessage("interface.button.exit").getMessage()),
ClickType.LEFT, ClickType.LEFT,
event -> exit()); event -> player.closeInventory());
// back button // back button
if (parent != null) if (parent != null)
@ -197,6 +196,8 @@ public class KitEditorGui extends DoubleGui {
} }
private void restoreItemsInstance() { private void restoreItemsInstance() {
if (!isInInventory)
player.getInventory().clear();
setPlayerUnlockedRange(0, 0, 3, 8); setPlayerUnlockedRange(0, 0, 3, 8);
if (stash != null) if (stash != null)
player.getInventory().setContents(stash); player.getInventory().setContents(stash);