Package me.fami6xx.rpuniverse.core.jobs
Class SellStep
java.lang.Object
me.fami6xx.rpuniverse.core.jobs.SellStep
Represents a sell step where players can sell items at a specific location.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SellStepfromJsonObject(com.google.gson.JsonObject jsonObject)Creates a SellStep from its JSON object.static SellStepfromString(String s)Converts a string representation of a SellStep object into an actual SellStep object.Gets the description of the sell step.org.bukkit.inventory.ItemStackGets the item that players can sell.doubleGets the value of the item (per unit).doubleGets the percentage of the sale price that goes to the job.Gets the UUID of the job this SellStep belongs to.org.bukkit.LocationGets the location where the sell step is performed.intGets the maximum number of items a player can sell at once.getName()Gets the name of the sell step.doubleGets the percentage of the sale price that goes to the player.intGets the time it takes to sell the item (in ticks).getUuid()Gets the UUID of this SellStep.voidsetDescription(String description)Sets the description of the sell step.voidsetItemToSell(org.bukkit.inventory.ItemStack itemToSell)Sets the item that players can sell.voidsetItemValue(double itemValue)Sets the value of the item (per unit).voidsetJobPercentage(double jobPercentage)Sets the percentage of the sale price that goes to the job.voidsetJobUUID(UUID jobUUID)Sets the UUID of the job this SellStep belongs to.voidsetLocation(org.bukkit.Location location)Sets the location where the sell step is performed.voidsetMaxSellAmount(int maxSellAmount)Sets the maximum number of items a player can sell at once.voidSets the name of the sell step.voidsetPlayerPercentage(double playerPercentage)Sets the percentage of the sale price that goes to the player.voidsetTimeToSell(int timeToSell)Sets the time it takes to sell the item (in ticks).com.google.gson.JsonObjectConverts this SellStep to a JSON object.toString()Converts this SellStep to a YAML string representation.voidValidates that the sum of playerPercentage and jobPercentage is 100%.
-
Constructor Details
-
SellStep
public SellStep(@Nonnull UUID jobUUID, @Nonnull org.bukkit.Location location, @Nonnull org.bukkit.inventory.ItemStack itemToSell, double itemValue, int timeToSell, int maxSellAmount, double playerPercentage, double jobPercentage, @Nonnull String name, @Nonnull String description)Constructor for creating a new SellStep.- Parameters:
jobUUID- The UUID of the job this sell step belongs to.location- The location where the sell step is performed.itemToSell- The item that players can sell.itemValue- The value of the item (per unit).timeToSell- The time it takes to sell the item (in ticks).maxSellAmount- The maximum number of items a player can sell at once.playerPercentage- The percentage of the sale price that goes to the player.jobPercentage- The percentage of the sale price that goes to the job.name- The name of the sell step.description- The description of the sell step.
-
-
Method Details
-
getUuid
Gets the UUID of this SellStep.- Returns:
- The UUID of this SellStep.
-
getJobUUID
Gets the UUID of the job this SellStep belongs to.- Returns:
- The UUID of the job.
-
setJobUUID
Sets the UUID of the job this SellStep belongs to.- Parameters:
jobUUID- The new UUID of the job.
-
getLocation
public org.bukkit.Location getLocation()Gets the location where the sell step is performed.- Returns:
- The location of the sell step.
-
setLocation
public void setLocation(@Nonnull org.bukkit.Location location)Sets the location where the sell step is performed.- Parameters:
location- The new location of the sell step.
-
getItemToSell
public org.bukkit.inventory.ItemStack getItemToSell()Gets the item that players can sell.- Returns:
- The item to sell.
-
setItemToSell
public void setItemToSell(@Nonnull org.bukkit.inventory.ItemStack itemToSell)Sets the item that players can sell.- Parameters:
itemToSell- The new item to sell.
-
getItemValue
public double getItemValue()Gets the value of the item (per unit).- Returns:
- The value of the item.
-
setItemValue
public void setItemValue(double itemValue)Sets the value of the item (per unit).- Parameters:
itemValue- The new value of the item.
-
getTimeToSell
public int getTimeToSell()Gets the time it takes to sell the item (in ticks).- Returns:
- The time to sell the item.
-
setTimeToSell
public void setTimeToSell(int timeToSell)Sets the time it takes to sell the item (in ticks).- Parameters:
timeToSell- The new time to sell the item.
-
getMaxSellAmount
public int getMaxSellAmount()Gets the maximum number of items a player can sell at once.- Returns:
- The maximum sell amount.
-
setMaxSellAmount
public void setMaxSellAmount(int maxSellAmount)Sets the maximum number of items a player can sell at once.- Parameters:
maxSellAmount- The new maximum sell amount.
-
getPlayerPercentage
public double getPlayerPercentage()Gets the percentage of the sale price that goes to the player.- Returns:
- The player percentage.
-
setPlayerPercentage
public void setPlayerPercentage(double playerPercentage)Sets the percentage of the sale price that goes to the player.- Parameters:
playerPercentage- The new player percentage.
-
getJobPercentage
public double getJobPercentage()Gets the percentage of the sale price that goes to the job.- Returns:
- The job percentage.
-
setJobPercentage
public void setJobPercentage(double jobPercentage)Sets the percentage of the sale price that goes to the job.- Parameters:
jobPercentage- The new job percentage.
-
getName
Gets the name of the sell step.- Returns:
- The name of the sell step.
-
setName
Sets the name of the sell step.- Parameters:
name- The new name of the sell step.
-
getDescription
Gets the description of the sell step.- Returns:
- The description of the sell step.
-
setDescription
Sets the description of the sell step.- Parameters:
description- The new description of the sell step.
-
fromString
Converts a string representation of a SellStep object into an actual SellStep object.- Parameters:
s- The string representation of the SellStep object.- Returns:
- The SellStep object created from the string representation, or null if an error occurs during parsing.
-
toString
Converts this SellStep to a YAML string representation. -
toJsonObject
public com.google.gson.JsonObject toJsonObject()Converts this SellStep to a JSON object.- Returns:
- A
JsonObjectrepresenting this SellStep.
-
fromJsonObject
Creates a SellStep from its JSON object.- Parameters:
jsonObject- The JSON representation of a SellStep.- Returns:
- A new
SellStepinstance populated from the JSON data.
-
validatePercentages
public void validatePercentages()Validates that the sum of playerPercentage and jobPercentage is 100%.- Throws:
IllegalArgumentException- if the percentages do not sum to 100%.
-