Class Property
java.lang.Object
me.fami6xx.rpuniverse.core.properties.Property
Represents a property in the RP Universe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a lock to the property.voidaddTrustedPlayer(UUID playerUUID)Adds a player to the list of trusted players.protected voidCalled after loading the property from the file.protected voidCalled before saving the property to the file.doublecalculateSellAmount(double percentageBack)Calculates how much the player would get if they sold the property right now.protected voidDeactivates the property, deleting the hologram.Gets the associated locks of the property.org.bukkit.LocationGets the location of the hologram associated with the property.longGets the last active timestamp of the property.Gets the list of locked blocks associated with the property.getOwner()Gets the owner of the property.doublegetPrice()Gets the price of the property.Gets the unique identifier for the property.longGets the rent duration of the property in milliseconds.longGets the maximum duration of the rent.longGets the start timestamp of the rent.Gets the list of trusted players for the property.booleanChecks if the property is available (i.e., has no owner).booleanChecks if the property is rentable.protected voidremove()Removes the property from the server.voidremoveLock(Lock lock)Removes a lock from the property.voidremoveTrustedPlayer(UUID playerUUID)Removes a player from the list of trusted players.voidsellProperty(double percentageBack)Sells the property, giving the owner a percentage of the price back.voidsetHologramLocation(org.bukkit.Location hologramLocation)Sets the location of the hologram associated with the property.voidsetLockedBlocks(List<UUID> locksUUID)Sets the list of locked blocks associated with the property.voidSets the owner of the property and updates the last active timestamp.voidsetPrice(double price)Sets the price of the property.voidsetRentable(boolean rentable)Sets whether the property is rentable.voidsetRentDuration(long rentDuration)Sets the rent duration of the property in milliseconds.voidsetRentMaximumDuration(long rentMaximumDuration)Sets the maximum duration of the rent.voidsetRentStart(long rentStart)Sets the start timestamp of the rent.voidsetTrustedPlayers(List<UUID> trustedPlayers)Sets the list of trusted players for the property.voidUpdates the last active timestamp to the current time.
-
Constructor Details
-
Property
Constructs a new Property with the specified property ID.- Parameters:
propertyId- the unique identifier for the property
-
-
Method Details
-
beforeSave
protected void beforeSave()Called before saving the property to the file.Makes sure that all the data that needs to be saved is savable.
-
afterLoad
protected void afterLoad()Called after loading the property from the file.Makes sure that all the data that needs to be loaded is loaded.
-
deactivate
protected void deactivate()Deactivates the property, deleting the hologram. -
remove
protected void remove()Removes the property from the server. Doesn't remove the property from file system.Includes removal of all associated locks and the hologram.
-
getPropertyId
Gets the unique identifier for the property.- Returns:
- the property ID
-
getLocksUUID
Gets the list of locked blocks associated with the property.- Returns:
- the list of locked blocks
-
setLockedBlocks
Sets the list of locked blocks associated with the property.- Parameters:
locksUUID- the new list of locked blocks
-
addLock
Adds a lock to the property.Assuming that the lock is not already associated with the property.
Assuming you've already added the lock to LockHandler.
- Parameters:
lock- the lock to add
-
removeLock
Removes a lock from the property.Also removes the lock from the LockHandler. Completely deleting it from the server.
- Parameters:
lock- the lock to remove
-
getHologramLocation
public org.bukkit.Location getHologramLocation()Gets the location of the hologram associated with the property.- Returns:
- the hologram location
-
setHologramLocation
public void setHologramLocation(org.bukkit.Location hologramLocation)Sets the location of the hologram associated with the property.Destroys the current hologram and creates a new one.
- Parameters:
hologramLocation- the new hologram location
-
isRentable
public boolean isRentable()Checks if the property is rentable.- Returns:
- true if the property is rentable, false otherwise
-
setRentable
public void setRentable(boolean rentable)Sets whether the property is rentable.- Parameters:
rentable- true if the property should be rentable, false otherwise
-
getPrice
public double getPrice()Gets the price of the property.- Returns:
- the price of the property
-
setPrice
public void setPrice(double price)Sets the price of the property.- Parameters:
price- the new price of the property
-
getRentDuration
public long getRentDuration()Gets the rent duration of the property in milliseconds.- Returns:
- the rent duration in milliseconds
-
setRentDuration
public void setRentDuration(long rentDuration)Sets the rent duration of the property in milliseconds.- Parameters:
rentDuration- the new rent duration in milliseconds
-
getOwner
Gets the owner of the property.- Returns:
- the owner UUID
-
setOwner
Sets the owner of the property and updates the last active timestamp.- Parameters:
owner- the new owner UUID
-
sellProperty
public void sellProperty(double percentageBack)Sells the property, giving the owner a percentage of the price back.- Parameters:
percentageBack- the percentage of the price to give back (0.0 - 1.0)
-
calculateSellAmount
public double calculateSellAmount(double percentageBack)Calculates how much the player would get if they sold the property right now.- Parameters:
percentageBack- the percentage of the (price or rent-remaining-value) to give back (0.0 - 1.0)- Returns:
- the amount the player would receive
-
getTrustedPlayers
Gets the list of trusted players for the property.- Returns:
- the list of trusted players
-
setTrustedPlayers
Sets the list of trusted players for the property.- Parameters:
trustedPlayers- the new list of trusted players
-
addTrustedPlayer
Adds a player to the list of trusted players.- Parameters:
playerUUID- the UUID of the player to add
-
removeTrustedPlayer
Removes a player from the list of trusted players.- Parameters:
playerUUID- the UUID of the player to remove
-
getLastActive
public long getLastActive()Gets the last active timestamp of the property.- Returns:
- the last active timestamp in milliseconds
-
updateLastActive
public void updateLastActive()Updates the last active timestamp to the current time. -
isAvailable
public boolean isAvailable()Checks if the property is available (i.e., has no owner).- Returns:
- true if the property is available, false otherwise
-
getRentStart
public long getRentStart()Gets the start timestamp of the rent.- Returns:
- the start timestamp of the rent in milliseconds
-
setRentStart
public void setRentStart(long rentStart)Sets the start timestamp of the rent.- Parameters:
rentStart- the new start timestamp of the rent in milliseconds
-
getRentMaximumDuration
public long getRentMaximumDuration()Gets the maximum duration of the rent.- Returns:
- the maximum duration of the rent in milliseconds
-
setRentMaximumDuration
public void setRentMaximumDuration(long rentMaximumDuration)Sets the maximum duration of the rent.- Parameters:
rentMaximumDuration- the new maximum duration of the rent in milliseconds
-
getAssociatedLocks
Gets the associated locks of the property.- Returns:
- the associated locks
-