mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2024-11-25 12:05:56 +01:00
Make charge stay
This commit is contained in:
parent
21d0992532
commit
b696d770ce
@ -27,13 +27,13 @@ class Messages(file: File, stream: InputStream) {
|
||||
@JvmStatic
|
||||
fun CONTAINER_FULL_WARNING() = AxMinionsAPI.INSTANCE.getMessages().get<String>("warnings.container-full")
|
||||
@JvmStatic
|
||||
fun TIME_DAY() = AxMinionsAPI.INSTANCE.getMessages().get<Long>("time.day")
|
||||
fun TIME_DAY() = AxMinionsAPI.INSTANCE.getMessages().get<String>("time.day")
|
||||
@JvmStatic
|
||||
fun TIME_HOUR() = AxMinionsAPI.INSTANCE.getMessages().get<Long>("time.hour")
|
||||
fun TIME_HOUR() = AxMinionsAPI.INSTANCE.getMessages().get<String>("time.hour")
|
||||
@JvmStatic
|
||||
fun TIME_MINUTE() = AxMinionsAPI.INSTANCE.getMessages().get<Long>("time.minute")
|
||||
fun TIME_MINUTE() = AxMinionsAPI.INSTANCE.getMessages().get<String>("time.minute")
|
||||
@JvmStatic
|
||||
fun TIME_SECOND() = AxMinionsAPI.INSTANCE.getMessages().get<Long>("time.second")
|
||||
fun TIME_SECOND() = AxMinionsAPI.INSTANCE.getMessages().get<String>("time.second")
|
||||
@JvmStatic
|
||||
fun NO_CHARGE_WARNING() = AxMinionsAPI.INSTANCE.getMessages().get<String>("warnings.no-charge")
|
||||
@JvmStatic
|
||||
|
@ -51,7 +51,7 @@ abstract class MinionType(private val name: String, private val defaults: InputS
|
||||
run(minion)
|
||||
}
|
||||
|
||||
fun getItem(level: Int = 1, actions: Long = 0): ItemStack {
|
||||
fun getItem(level: Int = 1, actions: Long = 0, charge: Long = 0): ItemStack {
|
||||
val builder = ItemBuilder(
|
||||
config.getSection("item"),
|
||||
Placeholder.unparsed("level", level.toString()),
|
||||
@ -60,6 +60,7 @@ abstract class MinionType(private val name: String, private val defaults: InputS
|
||||
builder.storePersistentData(Keys.MINION_TYPE, PersistentDataType.STRING, name)
|
||||
builder.storePersistentData(Keys.LEVEL, PersistentDataType.INTEGER, level)
|
||||
builder.storePersistentData(Keys.STATISTICS, PersistentDataType.LONG, actions)
|
||||
builder.storePersistentData(Keys.CHARGE, PersistentDataType.LONG, charge)
|
||||
|
||||
return builder.clonedGet()
|
||||
}
|
||||
|
@ -14,4 +14,6 @@ object Keys {
|
||||
val STATISTICS = NamespacedKey(AxMinionsAPI.INSTANCE.getAxMinionsInstance(), "statistics")
|
||||
@JvmField
|
||||
val PLACED = NamespacedKey(AxMinionsAPI.INSTANCE.getAxMinionsInstance(), "placed")
|
||||
@JvmField
|
||||
val CHARGE = NamespacedKey(AxMinionsAPI.INSTANCE.getAxMinionsInstance(), "charge")
|
||||
}
|
@ -7,10 +7,12 @@ import com.artillexstudios.axminions.api.config.Messages
|
||||
import com.artillexstudios.axminions.api.data.DataHandler
|
||||
import com.artillexstudios.axminions.api.integrations.Integrations
|
||||
import com.artillexstudios.axminions.api.minions.Minion
|
||||
import com.artillexstudios.axminions.api.minions.miniontype.MinionType
|
||||
import com.artillexstudios.axminions.minions.MinionTicker
|
||||
import com.artillexstudios.axminions.minions.Minions
|
||||
import org.bukkit.entity.Player
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
class AxMinionsAPIImpl(private val plugin: AxMinionsPlugin) : AxMinionsAPI {
|
||||
|
||||
|
@ -45,6 +45,7 @@ class MinionPlaceListener : Listener {
|
||||
|
||||
val level = meta.persistentDataContainer.get(Keys.LEVEL, PersistentDataType.INTEGER) ?: 0
|
||||
val stats = meta.persistentDataContainer.get(Keys.STATISTICS, PersistentDataType.LONG) ?: 0
|
||||
val charge = meta.persistentDataContainer.get(Keys.CHARGE, PersistentDataType.LONG) ?: 0
|
||||
|
||||
if (Config.PLACE_PERMISSION() && !event.player.hasPermission("axminions.place.${minionType.getName()}")) {
|
||||
event.player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.PLACE_MISSING_PERMISSION()))
|
||||
@ -93,7 +94,7 @@ class MinionPlaceListener : Listener {
|
||||
0.0,
|
||||
locationId,
|
||||
0,
|
||||
0
|
||||
charge
|
||||
)
|
||||
Minions.startTicking(chunk)
|
||||
|
||||
|
@ -365,7 +365,7 @@ class Minion(
|
||||
}
|
||||
|
||||
override fun getAsItem(): ItemStack {
|
||||
return type.getItem(level, actions)
|
||||
return type.getItem(level, actions, charge)
|
||||
}
|
||||
|
||||
override fun getLevel(): Int {
|
||||
|
Loading…
Reference in New Issue
Block a user