Compare commits

...

18 Commits

Author SHA1 Message Date
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
14 changed files with 126 additions and 346 deletions

View File

@@ -43,12 +43,14 @@ allprojects {
shadowJar {
relocate('com.willfp.libreforge', 'com.willfp.ecopets.libreforge')
relocate('com.willfp.ecomponent', 'com.willfp.ecopets.ecomponent')
relocate('org.joml', 'com.willfp.ecopets.libreforge.joml')
}
dependencies {
compileOnly 'com.willfp:eco:6.42.0'
implementation 'com.willfp:libreforge:3.112.1'
compileOnly 'com.willfp:eco:6.44.0'
implementation 'com.willfp:libreforge:3.122.0'
implementation 'com.willfp:ecomponent:1.0.0'
implementation 'org.joml:joml:1.10.4'
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

@@ -17,6 +17,10 @@ internal object EcoPetsAPIImpl : EcoPetsAPI {
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 givePetExperience(player: Player, pet: Pet, amount: Double) =

View File

@@ -77,10 +77,6 @@ class EcoPetsPlugin : LibReforgePlugin() {
)
}
override fun getMinimumEcoVersion(): String {
return "6.37.0"
}
companion object {
@JvmStatic
lateinit var instance: EcoPetsPlugin

View File

@@ -28,6 +28,17 @@ interface EcoPetsAPI {
player: OfflinePlayer
): 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.
*
@@ -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 pet The pet.

View File

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

View File

@@ -3,6 +3,9 @@ package com.willfp.ecopets.pets
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.gui.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.ConfigSlot
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.builder.ItemStackBuilder
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.inventory.ItemStack
import kotlin.math.ceil
import kotlin.math.max
import kotlin.math.min
import kotlin.properties.Delegates
class PetLevelGUI(
plugin: EcoPlugin,
private val pet: Pet
) {
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 {
val maskPattern = plugin.configYml.getStrings("level-gui.mask.pattern").toTypedArray()
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 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
for (row in progressionPattern) {
x++
var y = 0
for (char in row) {
y++
if (char == '0') {
continue
return ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.$key.item")))
.setDisplayName(
plugin.configYml.getFormattedString("level-gui.progression-slots.$key.name")
.replace("%pet%", pet.name)
.replace("%level%", level.toString())
.replace("%level_numeral%", NumberUtils.toNumeral(level))
)
.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)
if (pos == -1) {
continue
}
progressionSlots[pos + 1] = Pair(x, y)
override fun getLevelState(player: Player, level: Int): LevelState {
return when {
level <= player.getPetLevel(pet) -> LevelState.UNLOCKED
level == player.getPetLevel(pet) + 1 -> LevelState.IN_PROGRESS
else -> LevelState.LOCKED
}
}
}
levelsPerPage = progressionSlots.size
pages = ceil(pet.maxLevel.toDouble() / levelsPerPage).toInt()
menu = menu(plugin.configYml.getInt("level-gui.rows")) {
setTitle(pet.name)
title = pet.name
maxPages(component.pages)
setMask(
FillerMask(
maskItems,
@@ -74,58 +76,11 @@ class PetLevelGUI(
)
)
for ((level, value) in progressionSlots) {
setSlot(
value.first,
value.second,
slot(ItemStack(Material.BLACK_STAINED_GLASS_PANE)) {
setUpdater { player, menu, _ ->
val page = getPage(menu, player)
addComponent(1, 1, component)
val slotLevel = ((page - 1) * levelsPerPage) + level
fun getItem(section: String) =
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(
// Instead of the page changer, this will show up when on the first page
addComponent(
MenuLayer.LOWER,
plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.row"),
plugin.configYml.getInt("level-gui.progression-slots.prev-page.location.column"),
slot(
@@ -133,39 +88,32 @@ class PetLevelGUI(
.setDisplayName(plugin.configYml.getString("level-gui.progression-slots.prev-page.name"))
.build()
) {
onLeftClick { event, _, menu ->
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)
}
}
onLeftClick { player, _, _, _ -> PetsGUI.open(player) }
}
)
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.column"),
slot(
PageChanger(
ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.next-page.material")))
.setDisplayName(plugin.configYml.getString("level-gui.progression-slots.next-page.name"))
.build()
) {
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)
}
}
.build(),
PageChanger.Direction.FORWARDS
)
)
setSlot(
plugin.configYml.getInt("level-gui.progression-slots.close.location.row"),
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.events.TriggerPreProcessEvent
import com.willfp.libreforge.filters.Filter
import com.willfp.libreforge.filters.Filters
import com.willfp.libreforge.triggers.Trigger
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
@@ -31,7 +32,7 @@ object PetTriggerXPGainListener : Listener {
return
}
if (!Filter.matches(data, xpGain.filters)) {
if (!Filters.passes(data, xpGain.filters)) {
return
}

View File

@@ -4,7 +4,7 @@ import com.google.common.collect.BiMap
import com.google.common.collect.HashBiMap
import com.google.common.collect.ImmutableList
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.ecopets.EcoPetsPlugin
import java.io.File
@@ -45,7 +45,7 @@ object Pets {
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")) {
addNewPet(Pet(id, petConfig, plugin))

View File

@@ -148,7 +148,7 @@ object PetsGUI {
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)
menu.addState(player, pageKey, newPage)
menu.setState(player, pageKey, newPage)
}
}
)

View File

@@ -258,6 +258,13 @@ cannot-afford-type:
sound: "BLOCK_NOTE_BLOCK_PLING"
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.
example_point: "Nicely Formatted Point"

View File

@@ -6,8 +6,17 @@ messages:
reloaded: "Reloaded!"
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-price: "&cYou can't afford to do this! &fPrice: %price%"
on-cooldown: "&cThis effect is on cooldown! &fTime left: &a%seconds% seconds"
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!"
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!"
@@ -25,13 +34,6 @@ messages:
no-pet-active: "&cYou don't have a pet active!"
activated-pet: "&fYou have activated 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:
title: "Pets"

View File

@@ -1,4 +1,4 @@
#libreforge-updater
#Sun Oct 16 23:27:52 BST 2022
version=1.51.1
#Thu Nov 24 14:31:26 GMT 2022
version=1.62.0
plugin-name=EcoPets