More fixes for MC 1.20.1

This commit is contained in:
GeorgH93 2023-07-14 22:38:19 +02:00
parent 5e24997f93
commit cf7a6c0617
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 11 additions and 3 deletions

View File

@ -47,6 +47,8 @@ public interface Backpack extends InventoryHolder
*/
UUID getOwnerId();
@Nullable Player getOwnerPlayer();
/**
* Let a given player open this backpack.
*

View File

@ -119,6 +119,12 @@ public Backpack(final OfflinePlayer owner, ItemStack[] backpack, final int ID)
return Bukkit.getServer().getOfflinePlayer(ownerId);
}
@Override
public @Nullable Player getOwnerPlayer()
{
return Bukkit.getServer().getPlayer(ownerId);
}
private void checkResize()
{
Player owner = Bukkit.getServer().getPlayer(this.ownerId);

View File

@ -69,15 +69,15 @@ public void onResult(Backpack backpack)
if(backpack != null)
{
backpack.clear();
if(commandSender.equals(backpack.getOwner()))
if(commandSender instanceof Player && ((Player) commandSender).getUniqueId().equals(backpack.getOwnerId()))
{
messageCleared.send(commandSender);
}
else
{
if(backpack.getOwner().isOnline())
Player owner = backpack.getOwnerPlayer();
if(owner != null)
{
Player owner = backpack.getOwner().getPlayer();
messageClearedOther.send(commandSender, owner);
messageClearedBy.send(owner, commandSender);
}