Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
120db25a11 | ||
|
|
c4ea85ff7f | ||
|
|
1c98a7257e | ||
|
|
5a810e4dfb | ||
|
|
ddaa9d36b6 | ||
|
|
1f274b57d1 | ||
|
|
1a7a92e6de | ||
|
|
e369e99510 | ||
|
|
6fb565f6db | ||
|
|
c51b29ed35 | ||
|
|
ddbd6479e5 | ||
|
|
84862f7b28 | ||
|
|
9eea5631e7 | ||
|
|
ee3c934858 | ||
|
|
35650efe47 | ||
|
|
6f7b800a7d | ||
|
|
08f3340399 | ||
|
|
d36551a94b | ||
|
|
42ed601fd7 | ||
|
|
3cd800aeac | ||
|
|
a8e4f886a5 | ||
|
|
fffdca4515 | ||
|
|
03fe0f6116 |
@@ -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.110.0'
|
implementation 'com.willfp:libreforge:3.122.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'
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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) =
|
||||||
|
|||||||
@@ -77,10 +77,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
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ interface EcoPetsAPI {
|
|||||||
* Get if a player has a pet.
|
* Get if a player has a pet.
|
||||||
*
|
*
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @param pet The pet.
|
* @param pet The pet.
|
||||||
* @return If the player has the pet unlocked
|
* @return If the player has the pet unlocked
|
||||||
*/
|
*/
|
||||||
fun hasPet(
|
fun hasPet(
|
||||||
@@ -28,11 +28,22 @@ 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.
|
||||||
*
|
*
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @param pet The pet.
|
* @param pet The pet.
|
||||||
* @return The level.
|
* @return The level.
|
||||||
*/
|
*/
|
||||||
fun getPetLevel(
|
fun getPetLevel(
|
||||||
@@ -44,7 +55,7 @@ interface EcoPetsAPI {
|
|||||||
* Give pet experience to a player.
|
* Give pet experience to a player.
|
||||||
*
|
*
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @param pet The pet.
|
* @param pet The pet.
|
||||||
* @param amount The amount of experience to give.
|
* @param amount The amount of experience to give.
|
||||||
*/
|
*/
|
||||||
fun givePetExperience(
|
fun givePetExperience(
|
||||||
@@ -56,9 +67,9 @@ interface EcoPetsAPI {
|
|||||||
/**
|
/**
|
||||||
* Give pet experience to a player.
|
* Give pet experience to a player.
|
||||||
*
|
*
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @param pet The pet.
|
* @param pet The pet.
|
||||||
* @param amount The amount of experience to give.
|
* @param amount The amount of experience to give.
|
||||||
* @param applyMultipliers If multipliers should be applied.
|
* @param applyMultipliers If multipliers should be applied.
|
||||||
*/
|
*/
|
||||||
fun givePetExperience(
|
fun givePetExperience(
|
||||||
@@ -69,10 +80,11 @@ 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.
|
||||||
* @return The progress.
|
* @return The progress.
|
||||||
*/
|
*/
|
||||||
fun getPetProgress(
|
fun getPetProgress(
|
||||||
@@ -84,7 +96,7 @@ interface EcoPetsAPI {
|
|||||||
* Get the experience required to advance to the next level.
|
* Get the experience required to advance to the next level.
|
||||||
*
|
*
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @param pet The pet.
|
* @param pet The pet.
|
||||||
* @return The experience required.
|
* @return The experience required.
|
||||||
*/
|
*/
|
||||||
fun getPetXPRequired(
|
fun getPetXPRequired(
|
||||||
@@ -96,7 +108,7 @@ interface EcoPetsAPI {
|
|||||||
* Get experience to the next level.
|
* Get experience to the next level.
|
||||||
*
|
*
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @param pet The pet.
|
* @param pet The pet.
|
||||||
* @return The experience.
|
* @return The experience.
|
||||||
*/
|
*/
|
||||||
fun getPetXP(
|
fun getPetXP(
|
||||||
|
|||||||
@@ -1,16 +1,29 @@
|
|||||||
package com.willfp.ecopets.commands
|
package com.willfp.ecopets.commands
|
||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin
|
|
||||||
import com.willfp.eco.core.command.impl.PluginCommand
|
import com.willfp.eco.core.command.impl.PluginCommand
|
||||||
|
import com.willfp.ecopets.pets.Pets
|
||||||
|
import com.willfp.libreforge.LibReforgePlugin
|
||||||
|
import com.willfp.libreforge.lrcdb.CommandExport
|
||||||
|
import com.willfp.libreforge.lrcdb.CommandImport
|
||||||
|
import com.willfp.libreforge.lrcdb.ExportableConfig
|
||||||
import org.bukkit.command.CommandSender
|
import org.bukkit.command.CommandSender
|
||||||
|
|
||||||
class CommandEcopets(plugin: EcoPlugin) : PluginCommand(plugin, "ecopets", "ecopets.command.ecopets", false) {
|
class CommandEcopets(plugin: LibReforgePlugin) : PluginCommand(plugin, "ecopets", "ecopets.command.ecopets", false) {
|
||||||
init {
|
init {
|
||||||
this.addSubcommand(CommandReload(plugin))
|
this.addSubcommand(CommandReload(plugin))
|
||||||
.addSubcommand(CommandGive(plugin))
|
.addSubcommand(CommandGive(plugin))
|
||||||
.addSubcommand(CommandGiveEgg(plugin))
|
.addSubcommand(CommandGiveEgg(plugin))
|
||||||
.addSubcommand(CommandGiveXP(plugin))
|
.addSubcommand(CommandGiveXP(plugin))
|
||||||
.addSubcommand(CommandReset(plugin))
|
.addSubcommand(CommandReset(plugin))
|
||||||
|
.addSubcommand(CommandImport("pets", plugin))
|
||||||
|
.addSubcommand(CommandExport(plugin) {
|
||||||
|
Pets.values().map {
|
||||||
|
ExportableConfig(
|
||||||
|
it.id,
|
||||||
|
it.config
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onExecute(sender: CommandSender, args: List<String>) {
|
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||||
|
|||||||
@@ -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(":")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ 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.PlayerQuitEvent
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
import java.util.*
|
import java.util.UUID
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
@@ -44,10 +44,18 @@ class PetDisplay(
|
|||||||
|
|
||||||
location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15
|
location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15
|
||||||
|
|
||||||
try {
|
if (location.world != null) {
|
||||||
stand.teleport(location)
|
try {
|
||||||
} catch (_: Exception) {
|
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(":")) {
|
||||||
|
|||||||
@@ -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()
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
val pos = progressionOrder.indexOf(char)
|
|
||||||
|
|
||||||
if (pos == -1) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -258,6 +258,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"
|
||||||
|
|
||||||
@@ -274,5 +281,3 @@ potions:
|
|||||||
particles:
|
particles:
|
||||||
permanent: false
|
permanent: false
|
||||||
triggered: true
|
triggered: true
|
||||||
|
|
||||||
share-configs: true # If your configs are allowed to be used to gather data and improve the plugin. Nothing identifying (IP, Name, etc) is shared.
|
|
||||||
@@ -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!"
|
||||||
|
|||||||
19
eco-core/core-plugin/src/main/resources/lrcdb.yml
Normal file
19
eco-core/core-plugin/src/main/resources/lrcdb.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Options for lrcdb (https://lrcdb.auxilor.io), a website to share configs
|
||||||
|
# with other server owners, so you can get more configs without making them
|
||||||
|
# yourself!
|
||||||
|
|
||||||
|
author: "Unknown Author" # The name attached to configs you export
|
||||||
|
|
||||||
|
# Options about automatically sharing configs you create
|
||||||
|
share-configs:
|
||||||
|
# If you want all your configs to automatically be publicly available,
|
||||||
|
# set this to true. This really helps out other users!
|
||||||
|
publicly: false
|
||||||
|
|
||||||
|
# If you don't want your configs to be usable to gather information about
|
||||||
|
# plugin usage or to improve the plugins in the future, disable this.
|
||||||
|
# Nothing identifying is shared.
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# If you disable share-configs, you can still share select configs publicly
|
||||||
|
# with /ecopets export <config>.
|
||||||
@@ -54,6 +54,8 @@ permissions:
|
|||||||
ecopets.command.reset: true
|
ecopets.command.reset: true
|
||||||
ecopets.command.activate: true
|
ecopets.command.activate: true
|
||||||
ecopets.command.deactivate: true
|
ecopets.command.deactivate: true
|
||||||
|
ecopets.command.import: true
|
||||||
|
ecopets.command.export: true
|
||||||
|
|
||||||
ecopets.command.reload:
|
ecopets.command.reload:
|
||||||
description: Allows reloading the config
|
description: Allows reloading the config
|
||||||
@@ -76,6 +78,12 @@ permissions:
|
|||||||
ecopets.command.reset:
|
ecopets.command.reset:
|
||||||
description: Allows the use of /ecopets reset.
|
description: Allows the use of /ecopets reset.
|
||||||
default: op
|
default: op
|
||||||
|
ecopets.command.import:
|
||||||
|
description: Allows the use of /ecopets import.
|
||||||
|
default: op
|
||||||
|
ecopets.command.export:
|
||||||
|
description: Allows the use of /ecopets export.
|
||||||
|
default: op
|
||||||
ecopets.command.activate:
|
ecopets.command.activate:
|
||||||
description: Allows the use of /pets activate.
|
description: Allows the use of /pets activate.
|
||||||
default: true
|
default: true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#libreforge-updater
|
#libreforge-updater
|
||||||
#Fri Oct 07 19:52:35 BST 2022
|
#Thu Nov 24 14:31:26 GMT 2022
|
||||||
version=1.49.0
|
version=1.62.0
|
||||||
plugin-name=EcoPets
|
plugin-name=EcoPets
|
||||||
|
|||||||
Reference in New Issue
Block a user