Safely handle cancelled inventory open events on vaults by checking if inventory is null AFTER it's opened. Resolves #354
This commit is contained in:
@@ -78,7 +78,6 @@ public class VaultManager {
|
|||||||
inv = i;
|
inv = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerVaults.getInstance().getOpenInventories().put(info.toString(), inv);
|
|
||||||
|
|
||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,18 @@ public class VaultOperations {
|
|||||||
PlayerVaults.debug(String.format("Failed to open null vault %d for %s. This is weird.", number, player.getName()));
|
PlayerVaults.debug(String.format("Failed to open null vault %d for %s. This is weird.", number, player.getName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
|
|
||||||
|
// Check if the inventory was actually opened
|
||||||
|
if (player.getOpenInventory().getTopInventory() == null) {
|
||||||
|
PlayerVaults.debug(String.format("Cancelled opening vault %s for %s from an outside source.", arg, player.getName()));
|
||||||
|
return false; // inventory open event was cancelled.
|
||||||
|
}
|
||||||
|
|
||||||
|
VaultViewInfo info = new VaultViewInfo(player.getUniqueId(), number);
|
||||||
|
PlayerVaults.getInstance().getOpenInventories().put(info.toString(), inv);
|
||||||
|
|
||||||
player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_VAULT.toString().replace("%v", arg));
|
player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_VAULT.toString().replace("%v", arg));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user