Compare commits

...

35 Commits

Author SHA1 Message Date
Auxilor
5ca0cb4f82 libreforge-updater 2023-01-02 15:59:15 +00:00
Auxilor
c2f2088986 libreforge-updater 2022-12-26 14:02:32 +01:00
Auxilor
02c120fc0a Updated model engine 2022-12-20 15:21:13 +00:00
Auxilor
404d908efe libreforge-updater 2022-12-20 15:16:19 +00:00
Auxilor
b430dcaf5b libreforge-updater 2022-12-12 14:02:12 +00:00
Auxilor
84acf13c8d libreforge-updater 2022-12-09 17:02:31 +00:00
Auxilor
5465a7412f libreforge-updater 2022-12-05 10:51:52 +00:00
Auxilor
4a8ea43b5b Merge remote-tracking branch 'origin/master' 2022-12-04 15:05:48 +00:00
Auxilor
a2d147e54c Updated to 1.64.2 2022-12-04 15:05:42 +00:00
Will FP
2ceb670999 Merge pull request #34
Fix bugs
2022-12-04 15:05:24 +00:00
TomTom
a4cef52d5c Merge branch 'Auxilor:master' into fixes 2022-11-30 18:54:38 +01:00
Auxilor
b653d97794 libreforge-updater 2022-11-30 17:39:35 +00:00
TomTom
f44ca8a7e3 Fix bald 2022-11-29 16:35:29 +01:00
TomTom
56ddfeca39 Add being able to disable pet entities 2022-11-29 16:11:04 +01:00
TomTom
332fd55f0b Fix stuff 2022-11-28 16:04:50 +01:00
Auxilor
452c20f534 libreforge-updater 2022-11-27 21:45:42 +00:00
Auxilor
6002bc0b47 libreforge-updater 2022-11-26 19:21:36 +00:00
Auxilor
120db25a11 libreforge-updater 2022-11-24 14:31:26 +00:00
Auxilor
c4ea85ff7f libreforge-updater 2022-11-23 17:26:26 +00:00
Auxilor
1c98a7257e libreforge-updater 2022-11-21 16:04:13 +00:00
Auxilor
5a810e4dfb libreforge-updater 2022-11-17 08:39:45 +00:00
Auxilor
ddaa9d36b6 libreforge-updater 2022-11-12 17:35:52 +00:00
Auxilor
1f274b57d1 libreforge-updater 2022-11-06 19:53:24 +00:00
Auxilor
1a7a92e6de Reworked level GUI to use ecomponent 2022-11-06 15:34:52 +00:00
Auxilor
e369e99510 Updated to 1.57.0 2022-11-04 13:11:09 +00:00
Auxilor
6fb565f6db Added setActivePet to API 2022-11-04 13:11:02 +00:00
Auxilor
c51b29ed35 libreforge-updater 2022-11-01 16:24:09 +00:00
Auxilor
ddbd6479e5 libreforge-updater 2022-10-28 11:36:22 +01:00
Auxilor
84862f7b28 libreforge-updater 2022-10-26 22:13:11 +01:00
Auxilor
9eea5631e7 Fix 2022-10-24 17:15:22 +01:00
Auxilor
ee3c934858 libreforge-updater 2022-10-24 17:05:58 +01:00
Auxilor
35650efe47 libreforge-updater 2022-10-21 19:27:28 +01:00
Auxilor
6f7b800a7d Fix 2022-10-19 21:03:56 +01:00
Auxilor
08f3340399 libreforge-updater 2022-10-19 20:45:39 +01:00
Auxilor
d36551a94b libreforge-updater 2022-10-18 14:15:28 +01:00
17 changed files with 152 additions and 361 deletions

View File

@@ -43,12 +43,14 @@ allprojects {
shadowJar { shadowJar {
relocate('com.willfp.libreforge', 'com.willfp.ecopets.libreforge') relocate('com.willfp.libreforge', 'com.willfp.ecopets.libreforge')
relocate('com.willfp.ecomponent', 'com.willfp.ecopets.ecomponent')
relocate('org.joml', 'com.willfp.ecopets.libreforge.joml') relocate('org.joml', 'com.willfp.ecopets.libreforge.joml')
} }
dependencies { dependencies {
compileOnly 'com.willfp:eco:6.42.0' compileOnly 'com.willfp:eco:6.44.0'
implementation 'com.willfp:libreforge:3.112.1' implementation 'com.willfp:libreforge:3.127.0'
implementation 'com.willfp:ecomponent:1.0.0'
implementation 'org.joml:joml:1.10.4' implementation 'org.joml:joml:1.10.4'
compileOnly 'org.jetbrains:annotations:23.0.0' compileOnly 'org.jetbrains:annotations:23.0.0'

View File

@@ -1,184 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
- the Javadoc guidelines at
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
https://checkstyle.org (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
To suppress certain violations please review suppression filters.
Finally, it is worth reading the documentation.
-->
<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppression.xml"/>
</module>
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
https://checkstyle.org/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, xml"/>
<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<!-- Checks whether files end with a new line. -->
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See https://checkstyle.org/config_misc.html#Translation -->
<module name="Translation"/>
<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<module name="FileLength"/>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="200"/>
</module>
<!-- Checks for whitespace -->
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="FileTabCharacter"/>
<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<!-- Checks for Headers -->
<!-- See https://checkstyle.org/config_header.html -->
<!-- <module name="Header"> -->
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->
<module name="TreeWalker">
<!-- Checks for Javadoc comments. -->
<!-- See https://checkstyle.org/config_javadoc.html -->
<module name="InvalidJavadocPosition"/>
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/>
<module name="MissingJavadocMethod"/>
<!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for imports -->
<!-- See https://checkstyle.org/config_imports.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<!-- <module name="MethodLength"/> -->
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See https://checkstyle.org/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See https://checkstyle.org/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See https://checkstyle.org/config_coding.html -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<!-- <module name="MagicNumber"/> -->
<module name="MissingSwitchDefault"/>
<module name="MultipleVariableDeclarations"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See https://checkstyle.org/config_design.html -->
<!-- <module name="DesignForExtension"/> -->
<module name="FinalClass"/>
<!-- <module name="HideUtilityClassConstructor"/> -->
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<module name="RequireThis"/>
<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
</module>
</module>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<!-- Fields don't need javadoc -->
<suppress files="Effects.java" checks="JavadocVariable"/>
<suppress files="Skills.java" checks="JavadocVariable"/>
<suppress files="Stats.java" checks="JavadocVariable"/>
</suppressions>

View File

@@ -7,7 +7,7 @@ dependencies {
compileOnly 'net.kyori:adventure-api:4.10.1' compileOnly 'net.kyori:adventure-api:4.10.1'
compileOnly 'net.essentialsx:EssentialsX:2.19.0' compileOnly 'net.essentialsx:EssentialsX:2.19.0'
compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6' compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6'
compileOnly 'com.ticxo.modelengine:api:R3.0.0' compileOnly 'com.ticxo.modelengine:api:R3.1.3'
} }
build.dependsOn publishToMavenLocal build.dependsOn publishToMavenLocal

View File

@@ -17,6 +17,10 @@ internal object EcoPetsAPIImpl : EcoPetsAPI {
override fun getActivePet(player: OfflinePlayer): Pet? = player.activePet override fun getActivePet(player: OfflinePlayer): Pet? = player.activePet
override fun setActivePet(player: OfflinePlayer, pet: Pet?) {
player.activePet = pet
}
override fun getPetLevel(player: OfflinePlayer, pet: Pet) = player.getPetLevel(pet) override fun getPetLevel(player: OfflinePlayer, pet: Pet) = player.getPetLevel(pet)
override fun givePetExperience(player: Player, pet: Pet, amount: Double) = override fun givePetExperience(player: Player, pet: Pet, amount: Double) =

View File

@@ -41,6 +41,10 @@ class EcoPetsPlugin : LibReforgePlugin() {
} }
override fun handleReloadAdditional() { override fun handleReloadAdditional() {
if (!this.configYml.getBool("pet-entity.enabled")) {
return
}
this.scheduler.runTimer(1, 1) { this.scheduler.runTimer(1, 1) {
petDisplay.tickAll() petDisplay.tickAll()
} }
@@ -77,10 +81,6 @@ class EcoPetsPlugin : LibReforgePlugin() {
) )
} }
override fun getMinimumEcoVersion(): String {
return "6.37.0"
}
companion object { companion object {
@JvmStatic @JvmStatic
lateinit var instance: EcoPetsPlugin lateinit var instance: EcoPetsPlugin

View File

@@ -28,6 +28,17 @@ interface EcoPetsAPI {
player: OfflinePlayer player: OfflinePlayer
): Pet? ): Pet?
/**
* Set a player's active pet.
*
* @param player The player.
* @param pet The pet.
*/
fun setActivePet(
player: OfflinePlayer,
pet: Pet?
)
/** /**
* Get a player's level of a certain pet. * Get a player's level of a certain pet.
* *
@@ -69,7 +80,8 @@ interface EcoPetsAPI {
) )
/** /**
* Get progress to next level between 0 and 1, where 0 is none and 1 is complete. * Get progress to next level between 0 and 1, where 0 is none and 1 is
* complete.
* *
* @param player The player. * @param player The player.
* @param pet The pet. * @param pet The pet.

View File

@@ -53,7 +53,7 @@ class CommandActivate(plugin: EcoPlugin) : Subcommand(plugin, "activate", "ecope
if (args.size == 1) { if (args.size == 1) {
StringUtil.copyPartialMatches( StringUtil.copyPartialMatches(
args[1], args[0],
Pets.values().filter { sender.hasPet(it) }.map { it.id }, Pets.values().filter { sender.hasPet(it) }.map { it.id },
completions completions
) )

View File

@@ -172,13 +172,15 @@ class Pet(
} }
) )
effects = config.getSubsections("effects").mapNotNull { effects = Effects.compile(
Effects.compile(it, "Pet $id") config.getSubsections("effects"),
}.toSet() "Pet $id"
)
conditions = config.getSubsections("conditions").mapNotNull { conditions = Conditions.compile(
Conditions.compile(it, "Pet $id") config.getSubsections("conditions"),
}.toSet() "Pet $id"
)
for (string in config.getStrings("level-commands")) { for (string in config.getStrings("level-commands")) {
val split = string.split(":") val split = string.split(":")

View File

@@ -9,7 +9,9 @@ import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.event.EventHandler import org.bukkit.event.EventHandler
import org.bukkit.event.Listener import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerChangedWorldEvent
import org.bukkit.event.player.PlayerQuitEvent import org.bukkit.event.player.PlayerQuitEvent
import org.bukkit.event.player.PlayerTeleportEvent
import java.util.UUID import java.util.UUID
import kotlin.math.PI import kotlin.math.PI
import kotlin.math.abs import kotlin.math.abs
@@ -45,17 +47,7 @@ class PetDisplay(
location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15 location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15
if (location.world != null) { if (location.world != null) {
try {
stand.teleport(location) stand.teleport(location)
} catch (_: Throwable) {
/*
For anyone reading - I KNOW TO NEVER CATCH THROWABLE
but NMS is really stupid and does this sometimes:
java.lang.Throwable: null
at net.minecraft.world.entity.Entity.teleportTo(Entity.java:3336) ~[paper-1.19.2.jar:git-Paper-186]
so I guess that's what has to be done. Not sure what the actual cause is.
*/
}
} }
if (!pet.entityTexture.contains(":")) { if (!pet.entityTexture.contains(":")) {
@@ -117,10 +109,24 @@ class PetDisplay(
trackedEntities.clear() trackedEntities.clear()
} }
private fun remove(player: Player) {
trackedEntities[player.uniqueId]?.stand?.remove()
trackedEntities.remove(player.uniqueId)
}
@EventHandler @EventHandler
fun onLeave(event: PlayerQuitEvent) { fun onLeave(event: PlayerQuitEvent) {
trackedEntities[event.player.uniqueId]?.stand?.remove() remove(event.player)
trackedEntities.remove(event.player.uniqueId) }
@EventHandler
fun onTeleport(event: PlayerTeleportEvent) {
remove(event.player)
}
@EventHandler
fun onWorldChange(event: PlayerChangedWorldEvent) {
remove(event.player)
} }
private data class PetArmorStand( private data class PetArmorStand(

View File

@@ -3,6 +3,9 @@ package com.willfp.ecopets.pets
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.gui.menu import com.willfp.eco.core.gui.menu
import com.willfp.eco.core.gui.menu.Menu import com.willfp.eco.core.gui.menu.Menu
import com.willfp.eco.core.gui.menu.MenuLayer
import com.willfp.eco.core.gui.onLeftClick
import com.willfp.eco.core.gui.page.PageChanger
import com.willfp.eco.core.gui.slot import com.willfp.eco.core.gui.slot
import com.willfp.eco.core.gui.slot.ConfigSlot import com.willfp.eco.core.gui.slot.ConfigSlot
import com.willfp.eco.core.gui.slot.FillerMask import com.willfp.eco.core.gui.slot.FillerMask
@@ -10,63 +13,62 @@ import com.willfp.eco.core.gui.slot.MaskItems
import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.Items
import com.willfp.eco.core.items.builder.ItemStackBuilder import com.willfp.eco.core.items.builder.ItemStackBuilder
import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.NumberUtils
import org.bukkit.Material import com.willfp.ecomponent.components.LevelComponent
import com.willfp.ecomponent.components.LevelState
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import kotlin.math.ceil
import kotlin.math.max
import kotlin.math.min
import kotlin.properties.Delegates
class PetLevelGUI( class PetLevelGUI(
plugin: EcoPlugin, plugin: EcoPlugin,
private val pet: Pet private val pet: Pet
) { ) {
private val menu: Menu private val menu: Menu
private val pageKey = "page"
private var levelsPerPage by Delegates.notNull<Int>()
private var pages by Delegates.notNull<Int>()
private fun getPage(menu: Menu, player: Player): Int {
val page = menu.getState(player, pageKey) ?: 1
return min(pages, max(page, 1))
}
init { init {
val maskPattern = plugin.configYml.getStrings("level-gui.mask.pattern").toTypedArray() val maskPattern = plugin.configYml.getStrings("level-gui.mask.pattern").toTypedArray()
val maskItems = MaskItems.fromItemNames(plugin.configYml.getStrings("level-gui.mask.materials")) val maskItems = MaskItems.fromItemNames(plugin.configYml.getStrings("level-gui.mask.materials"))
val progressionOrder = "123456789abcdefghijklmnopqrstuvwxyz"
val progressionPattern = plugin.configYml.getStrings("level-gui.progression-slots.pattern") val progressionPattern = plugin.configYml.getStrings("level-gui.progression-slots.pattern")
val progressionSlots = mutableMapOf<Int, Pair<Int, Int>>() val component = object : LevelComponent(progressionPattern, pet.maxLevel) {
override fun getLevelItem(player: Player, menu: Menu, level: Int, levelState: LevelState): ItemStack {
val key = levelState.name.lowercase().replace("_", "-")
var x = 0 return ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.$key.item")))
for (row in progressionPattern) { .setDisplayName(
x++ plugin.configYml.getFormattedString("level-gui.progression-slots.$key.name")
var y = 0 .replace("%pet%", pet.name)
for (char in row) { .replace("%level%", level.toString())
y++ .replace("%level_numeral%", NumberUtils.toNumeral(level))
if (char == '0') { )
continue .addLoreLines(
pet.injectPlaceholdersInto(
plugin.configYml.getFormattedStrings("level-gui.progression-slots.$key.lore"),
player,
forceLevel = level
)
)
.setAmount(
if (plugin.configYml.getBool("level-gui.progression-slots.level-as-amount")) level else 1
)
.build()
} }
val pos = progressionOrder.indexOf(char) override fun getLevelState(player: Player, level: Int): LevelState {
return when {
if (pos == -1) { level <= player.getPetLevel(pet) -> LevelState.UNLOCKED
continue level == player.getPetLevel(pet) + 1 -> LevelState.IN_PROGRESS
} else -> LevelState.LOCKED
}
progressionSlots[pos + 1] = Pair(x, y)
} }
} }
levelsPerPage = progressionSlots.size
pages = ceil(pet.maxLevel.toDouble() / levelsPerPage).toInt()
menu = menu(plugin.configYml.getInt("level-gui.rows")) { menu = menu(plugin.configYml.getInt("level-gui.rows")) {
setTitle(pet.name) title = pet.name
maxPages(component.pages)
setMask( setMask(
FillerMask( FillerMask(
maskItems, maskItems,
@@ -74,58 +76,11 @@ class PetLevelGUI(
) )
) )
for ((level, value) in progressionSlots) { addComponent(1, 1, component)
setSlot(
value.first,
value.second,
slot(ItemStack(Material.BLACK_STAINED_GLASS_PANE)) {
setUpdater { player, menu, _ ->
val page = getPage(menu, player)
val slotLevel = ((page - 1) * levelsPerPage) + level // Instead of the page changer, this will show up when on the first page
addComponent(
fun getItem(section: String) = MenuLayer.LOWER,
ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.$section.item")))
.setDisplayName(
plugin.configYml.getFormattedString("level-gui.progression-slots.$section.name")
.replace("%pet%", pet.name)
.replace("%level%", slotLevel.toString())
.replace("%level_numeral%", NumberUtils.toNumeral(slotLevel))
)
.addLoreLines(
pet.injectPlaceholdersInto(
plugin.configYml.getFormattedStrings("level-gui.progression-slots.$section.lore"),
player,
forceLevel = slotLevel
)
)
.build()
if (slotLevel > pet.maxLevel) {
maskItems.items[0].item
} else {
val item = when {
slotLevel <= player.getPetLevel(pet) -> {
getItem("unlocked")
}
slotLevel == player.getPetLevel(pet) + 1 -> {
getItem("in-progress")
}
else -> {
getItem("locked")
}
}
if (plugin.configYml.getBool("level-gui.progression-slots.level-as-amount")) {
item.amount = slotLevel
}
item
}
}
}
)
}
setSlot(
plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.row"), plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.row"),
plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.column"), plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.column"),
slot( slot(
@@ -133,39 +88,32 @@ class PetLevelGUI(
.setDisplayName(plugin.configYml.getString("level-gui.progression-slots.prev-page.name")) .setDisplayName(plugin.configYml.getString("level-gui.progression-slots.prev-page.name"))
.build() .build()
) { ) {
onLeftClick { event, _, menu -> onLeftClick { player, _, _, _ -> PetsGUI.open(player) }
val player = event.whoClicked as Player
val page = getPage(menu, player)
val newPage = max(0, page - 1)
if (newPage == 0) {
PetsGUI.open(player)
} else {
menu.addState(player, pageKey, newPage)
}
}
} }
) )
setSlot(
addComponent(
plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.row"),
plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.column"),
PageChanger(
ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.prev-page.material")))
.setDisplayName(plugin.configYml.getString("level-gui.progression-slots.prev-page.name"))
.build(),
PageChanger.Direction.BACKWARDS
)
)
addComponent(
plugin.configYml.getInt("level-gui.progression-slots.next-page.location.row"), plugin.configYml.getInt("level-gui.progression-slots.next-page.location.row"),
plugin.configYml.getInt("level-gui.progression-slots.next-page.location.column"), plugin.configYml.getInt("level-gui.progression-slots.next-page.location.column"),
slot( PageChanger(
ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.next-page.material"))) ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.next-page.material")))
.setDisplayName(plugin.configYml.getString("level-gui.progression-slots.next-page.name")) .setDisplayName(plugin.configYml.getString("level-gui.progression-slots.next-page.name"))
.build() .build(),
) { PageChanger.Direction.FORWARDS
onLeftClick { event, _, menu ->
val player = event.whoClicked as Player
val page = getPage(menu, player)
val newPage = min(pages, page + 1)
menu.addState(player, pageKey, newPage)
}
}
) )
)
setSlot( setSlot(
plugin.configYml.getInt("level-gui.progression-slots.close.location.row"), plugin.configYml.getInt("level-gui.progression-slots.close.location.row"),
plugin.configYml.getInt("level-gui.progression-slots.close.location.column"), plugin.configYml.getInt("level-gui.progression-slots.close.location.column"),
@@ -190,5 +138,7 @@ class PetLevelGUI(
} }
} }
fun open(player: Player) = menu.open(player) fun open(player: Player) {
menu.open(player)
}
} }

View File

@@ -4,6 +4,7 @@ import com.willfp.eco.core.config.interfaces.Config
import com.willfp.libreforge.conditions.ConfiguredCondition import com.willfp.libreforge.conditions.ConfiguredCondition
import com.willfp.libreforge.events.TriggerPreProcessEvent import com.willfp.libreforge.events.TriggerPreProcessEvent
import com.willfp.libreforge.filters.Filter import com.willfp.libreforge.filters.Filter
import com.willfp.libreforge.filters.Filters
import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.Trigger
import org.bukkit.event.EventHandler import org.bukkit.event.EventHandler
import org.bukkit.event.Listener import org.bukkit.event.Listener
@@ -31,7 +32,7 @@ object PetTriggerXPGainListener : Listener {
return return
} }
if (!Filter.matches(data, xpGain.filters)) { if (!Filters.passes(data, xpGain.filters)) {
return return
} }

View File

@@ -4,7 +4,7 @@ import com.google.common.collect.BiMap
import com.google.common.collect.HashBiMap import com.google.common.collect.HashBiMap
import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableList
import com.willfp.eco.core.config.ConfigType import com.willfp.eco.core.config.ConfigType
import com.willfp.eco.core.config.TransientConfig import com.willfp.eco.core.config.readConfig
import com.willfp.eco.core.config.updating.ConfigUpdater import com.willfp.eco.core.config.updating.ConfigUpdater
import com.willfp.ecopets.EcoPetsPlugin import com.willfp.ecopets.EcoPetsPlugin
import java.io.File import java.io.File
@@ -45,7 +45,7 @@ object Pets {
removePet(set) removePet(set)
} }
val petsYml = TransientConfig(File(plugin.dataFolder, "pets.yml"), ConfigType.YAML) val petsYml = File(plugin.dataFolder, "pets.yml").readConfig(ConfigType.YAML)
for ((id, petConfig) in plugin.fetchConfigs("pets")) { for ((id, petConfig) in plugin.fetchConfigs("pets")) {
addNewPet(Pet(id, petConfig, plugin)) addNewPet(Pet(id, petConfig, plugin))

View File

@@ -148,7 +148,7 @@ object PetsGUI {
val newPage = max(1, page - 1) val newPage = max(1, page - 1)
menu.addState(player, pageKey, newPage) menu.setState(player, pageKey, newPage)
} }
} }
) )
@@ -172,7 +172,7 @@ object PetsGUI {
val newPage = min(pages, page + 1) val newPage = min(pages, page + 1)
menu.addState(player, pageKey, newPage) menu.setState(player, pageKey, newPage)
} }
} }
) )

View File

@@ -217,6 +217,7 @@ level-gui:
custom-slots: [ ] custom-slots: [ ]
pet-entity: pet-entity:
enabled: true # If you disable this, there will be no floating pets
name: "%player%&f's %pet%&f (Lvl. %level%)" name: "%player%&f's %pet%&f (Lvl. %level%)"
level-up: level-up:
@@ -258,6 +259,13 @@ cannot-afford-type:
sound: "BLOCK_NOTE_BLOCK_PLING" sound: "BLOCK_NOTE_BLOCK_PLING"
pitch: 0.5 pitch: 0.5
cannot-afford-price:
in-actionbar: true
sound:
enabled: true
sound: "BLOCK_NOTE_BLOCK_PLING"
pitch: 0.5
point-names: # If you have point names that look ugly (eg g_souls) then you can map them to nice names to be shown to players. point-names: # If you have point names that look ugly (eg g_souls) then you can map them to nice names to be shown to players.
example_point: "Nicely Formatted Point" example_point: "Nicely Formatted Point"

View File

@@ -6,8 +6,17 @@ messages:
reloaded: "Reloaded!" reloaded: "Reloaded!"
cannot-afford: "&cYou can't afford to do this! &fCost: &a$$%cost%" cannot-afford: "&cYou can't afford to do this! &fCost: &a$$%cost%"
cannot-afford-type: "&cYou can't afford to do this! &fCost: &a%cost% %type%" cannot-afford-type: "&cYou can't afford to do this! &fCost: &a%cost% %type%"
cannot-afford-price: "&cYou can't afford to do this! &fPrice: %price%"
on-cooldown: "&cThis effect is on cooldown! &fTime left: &a%seconds% seconds" on-cooldown: "&cThis effect is on cooldown! &fTime left: &a%seconds% seconds"
cannot-transmit: "&cYou can't transmit here!" cannot-transmit: "&cYou can't transmit here!"
must-specify-lrcdb-id: "&cYou must specify the ID of the config to download! Not sure what this means? Go to &alrcdb.auxilor.io"
lrcdb-import-error: "&cError importing config: &f%message%"
lrcdb-import-success: "&fImported &a%name%&f! Reload the plugin to install it"
must-specify-config-name: "&cYou must specify the config name!"
invalid-config-name: "&cInvalid config name!"
lrcdb-export-error: "&cError exporting config: &f%message%"
lrcdb-export-success: "&fExported &a%name%&f! View it on &alrcdb.auxilor.io&f, or share your config ID: &f%id%"
needs-player: "&cYou must specify a player!" needs-player: "&cYou must specify a player!"
gave-xp: "&fYou have given &a%xp% &fXP to %player%&f's %pet%&f!" gave-xp: "&fYou have given &a%xp% &fXP to %player%&f's %pet%&f!"
reset-xp: "&fYou have reset %player%&f's %pet%&f XP!" reset-xp: "&fYou have reset %player%&f's %pet%&f XP!"
@@ -25,13 +34,6 @@ messages:
no-pet-active: "&cYou don't have a pet active!" no-pet-active: "&cYou don't have a pet active!"
activated-pet: "&fYou have activated the %pet%&f pet!" activated-pet: "&fYou have activated the %pet%&f pet!"
deactivated-pet: "&fYou have deactivated the %pet%&f pet!" deactivated-pet: "&fYou have deactivated the %pet%&f pet!"
must-specify-lrcdb-id: "&cYou must specify the ID of the config to download! Not sure what this means? Go to &alrcdb.auxilor.io"
lrcdb-import-error: "&cError importing config: &f%message%"
lrcdb-import-success: "&fImported &a%name%&f! Reload the plugin to install it"
must-specify-config-name: "&cYou must specify the config name!"
invalid-config-name: "&cInvalid config name!"
lrcdb-export-error: "&cError exporting config: &f%message%"
lrcdb-export-success: "&fExported &a%name%&f! View it on &alrcdb.auxilor.io&f, or share your config ID: &f%id%"
menu: menu:
title: "Pets" title: "Pets"

View File

@@ -1,4 +1,4 @@
#libreforge-updater #libreforge-updater
#Sun Oct 16 23:27:52 BST 2022 #Mon Jan 02 15:59:15 GMT 2023
version=1.51.1 version=1.67.0
plugin-name=EcoPets plugin-name=EcoPets