Skip to content

Commit

Permalink
Add hasOwner method to item super class
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jun 9, 2024
1 parent ee7faac commit 0e15784
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/games/stendhal/server/entity/item/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,16 @@ public void autobind(String player) {
}
}

/**
* Checks if an item is marked as "owned" by a specific player.
*
* @return
* Always {@code false} in this implementation.
*/
public boolean hasOwner() {
return false;
}

/**
* Get the item's itemData. The itemData contains context specific
* information that is used by the implementation.
Expand Down
8 changes: 6 additions & 2 deletions src/games/stendhal/server/entity/item/OwnedItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright © 2020 - Arianne *
* Copyright © 2020-2024 - Faiumoni e. V. *
***************************************************************************
***************************************************************************
* *
Expand All @@ -21,6 +21,9 @@

/**
* Class representing an item owned by an entity.
*
* An "owned" item is different than a bound item in that it can be used by players other than the
* owner but they do not get the same or full benefit of.
*/
public abstract class OwnedItem extends Item {

Expand Down Expand Up @@ -82,8 +85,9 @@ public boolean onUsed(final RPEntity user) {
* Override to check if item has owner.
*
* @return
* <code>true</code> if owned.
* {@ true} if owned.
*/
@Override
public boolean hasOwner() {
return getOwner() != null;
}
Expand Down

0 comments on commit 0e15784

Please sign in to comment.