Make storage command check owner sooner.

This commit is contained in:
Jesse Prescott 2018-06-04 14:00:04 +01:00
parent ff3c3e3888
commit a54386c98d

View File

@ -82,6 +82,23 @@ public final class StorageCommand implements Command {
Itemcase itemcase =
ItemCaseCore.instance.getItemcaseManager().getItemcase(target);
// Get owner.
OfflinePlayer owner = itemcase.getOwner();
// Check if this player owns this itemcase.
if(!owner.equals(player)) {
// Check if player is allowed to modify other peoples itemcases.
if(!player.hasPermission("itemcase.modify.other")) {
// Show message.
chatLogger.message(player, "command.not-owner");
// Exit.
return;
}
}
// Check if itemcase is a shop.
if(itemcase.getType() == Type.SHOWCASE) {
@ -102,23 +119,6 @@ public final class StorageCommand implements Command {
return;
}
// Get owner.
OfflinePlayer owner = itemcase.getOwner();
// Check if this player owns this itemcase.
if(!owner.equals(player)) {
// Check if player is allowed to modify other peoples itemcases.
if(!player.hasPermission("itemcase.modify.other")) {
// Show message.
chatLogger.message(player, "command.not-owner");
// Exit.
return;
}
}
// Open itemcase storage to player.
player.openInventory(itemcase.getStorage());
}