Class LifestealerUser
java.lang.Object
dev.chicoferreira.lifestealer.user.LifestealerUser
Stores lifesteal information about a player, such has the amount of hearts they have, the heart cap, etc.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
A record containing information about a ban. -
Constructor Summary
ConstructorsConstructorDescriptionLifestealerUser
(@NotNull UUID uuid, int hearts, @Nullable LifestealerUser.Ban ban, @NotNull LifestealerUserRules modifierRules) -
Method Summary
Modifier and TypeMethodDescriptionint
Thread-safety: Requires a read lock on this user.@Nullable LifestealerUser.Ban
Gets the ban information of the user if they are banned, otherwise null.@NotNull LifestealerUserRules
Gets the modifier rules of the user.@NotNull UUID
getUuid()
Thread-safety: Requires a read lock on this user.void
readLock()
Locks the user for reading.void
Unlocks the user after reading.void
Locks the user for writing.void
Unlocks the user after writing.
-
Constructor Details
-
LifestealerUser
public LifestealerUser(@NotNull @NotNull UUID uuid, int hearts, @Nullable @Nullable LifestealerUser.Ban ban, @NotNull @NotNull LifestealerUserRules modifierRules)
-
-
Method Details
-
readLock
public void readLock()Locks the user for reading. You need to use this method before reading any user information. You also need to unlock the user after you're done reading. -
readUnlock
public void readUnlock()Unlocks the user after reading. You need to call this method after you're done reading the user information. -
writeLock
public void writeLock()Locks the user for writing. You need to use this method before writing any user information. You also need to unlock the user after you're done writing. -
writeUnlock
public void writeUnlock()Unlocks the user after writing. You need to call this method after you're done writing the user information. -
getUuid
Thread-safety: Requires a read lock on this user.- Returns:
- the UUID of the user
-
getHearts
public int getHearts()Thread-safety: Requires a read lock on this user.- Returns:
- the amount of hearts the user has
-
getInternalBan
Gets the ban information of the user if they are banned, otherwise null. This method is only intended to be used by theLifestealerUserController
. If you want to check if a player is banned, useLifestealerUserController.getBan(LifestealerUser)
.Thread-safety: Requires a read lock on this user.
- Returns:
- the ban information of the user if they have a banning record, otherwise null
-
getRulesModifier
Gets the modifier rules of the user. This rule will have its values summed with the values in the rule given by theLifestealerUserRulesController
which is based on the user's permissions to get the final rule value.Use
LifestealerUserController.computeUserRules(Player, LifestealerUser)
to get the final rule value.Thread-safety: Requires a read lock on this user.
-