libreforge-updater

This commit is contained in:
WillFP
2022-05-16 13:08:12 +01:00
parent 7c76885d77
commit 8c75aa755f
29 changed files with 2341 additions and 2341 deletions

44
.gitignore vendored
View File

@@ -1,23 +1,23 @@
# Java # Java
*.class *.class
# Eclipse IDE # Eclipse IDE
.settings/ .settings/
bin/ bin/
.classpath .classpath
.project .project
# IntelliJ IDEA # IntelliJ IDEA
.idea/ .idea/
*.iml *.iml
# Gradle # Gradle
.gradle .gradle
**/build/ **/build/
!src/**/build/ !src/**/build/
.gradletasknamecache .gradletasknamecache
!gradle-wrapper.jar !gradle-wrapper.jar
gradle-app.setting gradle-app.setting
# Mac OSX # Mac OSX
.DS_Store .DS_Store

1348
LICENSE.md

File diff suppressed because it is too large Load Diff

View File

@@ -1,42 +1,42 @@
<h1 align="center"> <h1 align="center">
<br> <br>
<img src="https://i.imgur.com/q618Awa.png" alt="Boosters logo" width="256"> <img src="https://i.imgur.com/q618Awa.png" alt="Boosters logo" width="256">
<br> <br>
</h1> </h1>
<h4 align="center">Source code for Boosters, a premium spigot plugin.</h4> <h4 align="center">Source code for Boosters, a premium spigot plugin.</h4>
<p align="center"> <p align="center">
<a href="https://polymart.org/resource/ecoitems.1241"> <a href="https://polymart.org/resource/ecoitems.1241">
<img alt="spigot" src="https://img.shields.io/badge/polymart-boosters-yellow?style=for-the-badge"/> <img alt="spigot" src="https://img.shields.io/badge/polymart-boosters-yellow?style=for-the-badge"/>
</a> </a>
<a href="https://bstats.org/plugin/bukkit/EcoItems" alt="bstats servers"> <a href="https://bstats.org/plugin/bukkit/EcoItems" alt="bstats servers">
<img src="https://img.shields.io/bstats/servers/14269?color=yellow&style=for-the-badge"/> <img src="https://img.shields.io/bstats/servers/14269?color=yellow&style=for-the-badge"/>
</a> </a>
<a href="https://bstats.org/plugin/bukkit/EcoItems" alt="bstats players"> <a href="https://bstats.org/plugin/bukkit/EcoItems" alt="bstats players">
<img src="https://img.shields.io/bstats/players/14269?color=yellow&style=for-the-badge"/> <img src="https://img.shields.io/bstats/players/14269?color=yellow&style=for-the-badge"/>
</a> </a>
<a href="https://plugins.auxilor.io/boosters/" alt="Docs (gitbook)"> <a href="https://plugins.auxilor.io/boosters/" alt="Docs (gitbook)">
<img src="https://img.shields.io/badge/docs-gitbook-yellow?style=for-the-badge&logo=appveyor"/> <img src="https://img.shields.io/badge/docs-gitbook-yellow?style=for-the-badge&logo=appveyor"/>
</a> </a>
<a href="https://discord.gg/ZcwpSsE/" alt="Discord"> <a href="https://discord.gg/ZcwpSsE/" alt="Discord">
<img src="https://img.shields.io/discord/452518336627081236?label=discord&style=for-the-badge&color=yellow"/> <img src="https://img.shields.io/discord/452518336627081236?label=discord&style=for-the-badge&color=yellow"/>
</a> </a>
</p> </p>
[![Picture](https://i.imgur.com/7MJFmb9.png)]() [![Picture](https://i.imgur.com/7MJFmb9.png)]()
## License ## License
*Click here to read [the entire license](https://github.com/Auxilor/Boosters/blob/master/LICENSE.md).* *Click here to read [the entire license](https://github.com/Auxilor/Boosters/blob/master/LICENSE.md).*
<h1 align="center"> <h1 align="center">
<br> <br>
<a href="http://gamersupps.gg/discount/Auxilor?afmc=Auxilor" target="_blank"> <a href="http://gamersupps.gg/discount/Auxilor?afmc=Auxilor" target="_blank">
<img src="https://i.imgur.com/uFDpBAC.png" alt="supps banner"> <img src="https://i.imgur.com/uFDpBAC.png" alt="supps banner">
</a> </a>
<a href="https://dedimc.promo/Auxilor" target="_blank"> <a href="https://dedimc.promo/Auxilor" target="_blank">
<img src="https://i.imgur.com/zdDLhFA.png" alt="dedimc banner"> <img src="https://i.imgur.com/zdDLhFA.png" alt="dedimc banner">
</a> </a>
<br> <br>
</h1> </h1>

View File

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

View File

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

View File

@@ -1,15 +1,15 @@
group 'com.willfp' group 'com.willfp'
version rootProject.version version rootProject.version
dependencies { dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
} }
publishing { publishing {
publications { publications {
Library(MavenPublication) { Library(MavenPublication) {
from project.components.java from project.components.java
artifact tasks.shadowJar artifact tasks.shadowJar
} }
} }
} }

View File

@@ -1,86 +1,86 @@
@file:JvmName("BoosterUtils") @file:JvmName("BoosterUtils")
package com.willfp.boosters package com.willfp.boosters
import com.willfp.boosters.boosters.ActivatedBooster import com.willfp.boosters.boosters.ActivatedBooster
import com.willfp.boosters.boosters.Booster import com.willfp.boosters.boosters.Booster
import com.willfp.boosters.boosters.Boosters import com.willfp.boosters.boosters.Boosters
import com.willfp.boosters.boosters.addActiveBooster import com.willfp.boosters.boosters.addActiveBooster
import com.willfp.eco.core.data.ServerProfile import com.willfp.eco.core.data.ServerProfile
import com.willfp.eco.core.data.profile import com.willfp.eco.core.data.profile
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer import org.bukkit.OfflinePlayer
import org.bukkit.Sound import org.bukkit.Sound
import org.bukkit.entity.Player import org.bukkit.entity.Player
val OfflinePlayer.boosters: List<Booster> val OfflinePlayer.boosters: List<Booster>
get() { get() {
val found = mutableListOf<Booster>() val found = mutableListOf<Booster>()
for (booster in Boosters.values()) { for (booster in Boosters.values()) {
val amount = this.profile.read(booster.ownedDataKey) val amount = this.profile.read(booster.ownedDataKey)
for (i in 0 until amount) { for (i in 0 until amount) {
found.add(booster) found.add(booster)
} }
} }
return found return found
} }
fun OfflinePlayer.getAmountOfBooster(booster: Booster): Int { fun OfflinePlayer.getAmountOfBooster(booster: Booster): Int {
return this.profile.read(booster.ownedDataKey) return this.profile.read(booster.ownedDataKey)
} }
fun OfflinePlayer.setAmountOfBooster(booster: Booster, amount: Int) { fun OfflinePlayer.setAmountOfBooster(booster: Booster, amount: Int) {
this.profile.write(booster.ownedDataKey, amount) this.profile.write(booster.ownedDataKey, amount)
} }
fun OfflinePlayer.incrementBoosters(booster: Booster, amount: Int) { fun OfflinePlayer.incrementBoosters(booster: Booster, amount: Int) {
this.setAmountOfBooster(booster, this.getAmountOfBooster(booster) + amount) this.setAmountOfBooster(booster, this.getAmountOfBooster(booster) + amount)
} }
fun Player.activateBooster(booster: Booster): Boolean { fun Player.activateBooster(booster: Booster): Boolean {
val amount = this.getAmountOfBooster(booster) val amount = this.getAmountOfBooster(booster)
if (amount <= 0) { if (amount <= 0) {
return false return false
} }
this.setAmountOfBooster(booster, amount - 1) this.setAmountOfBooster(booster, amount - 1)
for (activationMessage in booster.getActivationMessages(this)) { for (activationMessage in booster.getActivationMessages(this)) {
Bukkit.broadcastMessage(activationMessage) Bukkit.broadcastMessage(activationMessage)
} }
for (expiryCommand in booster.activationCommands) { for (expiryCommand in booster.activationCommands) {
Bukkit.dispatchCommand( Bukkit.dispatchCommand(
Bukkit.getConsoleSender(), Bukkit.getConsoleSender(),
expiryCommand.replace("%player%", booster.active?.player?.name ?: "") expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
) )
} }
ServerProfile.load().write( ServerProfile.load().write(
booster.expiryTimeKey, booster.expiryTimeKey,
(booster.duration.toDouble() * 50) + System.currentTimeMillis() (booster.duration.toDouble() * 50) + System.currentTimeMillis()
) )
ServerProfile.load().write( ServerProfile.load().write(
booster.activeDataKey, booster.activeDataKey,
this.uniqueId.toString() this.uniqueId.toString()
) )
Bukkit.getServer().addActiveBooster( Bukkit.getServer().addActiveBooster(
ActivatedBooster(booster, this.uniqueId) ActivatedBooster(booster, this.uniqueId)
) )
for (player in Bukkit.getOnlinePlayers()) { for (player in Bukkit.getOnlinePlayers()) {
player.playSound( player.playSound(
player.location, player.location,
Sound.UI_TOAST_CHALLENGE_COMPLETE, Sound.UI_TOAST_CHALLENGE_COMPLETE,
2f, 2f,
0.9f 0.9f
) )
} }
return true return true
} }

View File

@@ -1,75 +1,75 @@
package com.willfp.boosters package com.willfp.boosters
import com.willfp.boosters.boosters.Boosters import com.willfp.boosters.boosters.Boosters
import com.willfp.boosters.boosters.activeBoosters import com.willfp.boosters.boosters.activeBoosters
import com.willfp.boosters.boosters.expireBooster import com.willfp.boosters.boosters.expireBooster
import com.willfp.boosters.commands.CommandBoosters import com.willfp.boosters.commands.CommandBoosters
import com.willfp.boosters.config.BoostersYml import com.willfp.boosters.config.BoostersYml
import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.core.command.impl.PluginCommand
import com.willfp.eco.core.data.ServerProfile import com.willfp.eco.core.data.ServerProfile
import com.willfp.eco.core.data.profile import com.willfp.eco.core.data.profile
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
import com.willfp.eco.core.placeholder.PlayerlessPlaceholder import com.willfp.eco.core.placeholder.PlayerlessPlaceholder
import com.willfp.eco.util.formatEco import com.willfp.eco.util.formatEco
import com.willfp.eco.util.savedDisplayName import com.willfp.eco.util.savedDisplayName
import com.willfp.libreforge.LibReforgePlugin import com.willfp.libreforge.LibReforgePlugin
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.event.Listener import org.bukkit.event.Listener
import kotlin.math.floor import kotlin.math.floor
class BoostersPlugin : LibReforgePlugin() { class BoostersPlugin : LibReforgePlugin() {
val boostersYml = BoostersYml(this) val boostersYml = BoostersYml(this)
override fun handleEnableAdditional() { override fun handleEnableAdditional() {
this.registerHolderProvider { Bukkit.getServer().activeBoosters.map { it.booster } } this.registerHolderProvider { Bukkit.getServer().activeBoosters.map { it.booster } }
} }
override fun handleReloadAdditional() { override fun handleReloadAdditional() {
this.scheduler.runTimer(1, 1) { this.scheduler.runTimer(1, 1) {
for (booster in Boosters.values()) { for (booster in Boosters.values()) {
if (booster.active == null) { if (booster.active == null) {
continue continue
} }
if (booster.secondsLeft <= 0) { if (booster.secondsLeft <= 0) {
for (expiryMessage in booster.expiryMessages) { for (expiryMessage in booster.expiryMessages) {
Bukkit.broadcastMessage(expiryMessage) Bukkit.broadcastMessage(expiryMessage)
} }
for (expiryCommand in booster.expiryCommands) { for (expiryCommand in booster.expiryCommands) {
Bukkit.dispatchCommand( Bukkit.dispatchCommand(
Bukkit.getConsoleSender(), Bukkit.getConsoleSender(),
expiryCommand.replace("%player%", booster.active?.player?.name ?: "") expiryCommand.replace("%player%", booster.active?.player?.name ?: "")
) )
} }
Bukkit.getServer().expireBooster(booster) Bukkit.getServer().expireBooster(booster)
} }
} }
} }
} }
override fun loadListeners(): List<Listener> { override fun loadListeners(): List<Listener> {
return listOf( return listOf(
) )
} }
override fun loadPluginCommands(): List<PluginCommand> { override fun loadPluginCommands(): List<PluginCommand> {
return listOf( return listOf(
CommandBoosters(this) CommandBoosters(this)
) )
} }
override fun getMinimumEcoVersion(): String { override fun getMinimumEcoVersion(): String {
return "6.35.1" return "6.35.1"
} }
init { init {
instance = this instance = this
} }
companion object { companion object {
lateinit var instance: BoostersPlugin lateinit var instance: BoostersPlugin
} }
} }

View File

@@ -1,47 +1,47 @@
@file:Suppress("unused") @file:Suppress("unused")
package com.willfp.boosters.boosters package com.willfp.boosters.boosters
import com.willfp.eco.core.data.ServerProfile import com.willfp.eco.core.data.ServerProfile
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer import org.bukkit.OfflinePlayer
import org.bukkit.Server import org.bukkit.Server
import java.util.* import java.util.*
private val boosters = mutableSetOf<ActivatedBooster>() private val boosters = mutableSetOf<ActivatedBooster>()
fun Server.addActiveBooster(activatedBooster: ActivatedBooster) { fun Server.addActiveBooster(activatedBooster: ActivatedBooster) {
boosters += activatedBooster boosters += activatedBooster
} }
val Server.activeBoosters: Set<ActivatedBooster> val Server.activeBoosters: Set<ActivatedBooster>
get() = boosters.toSet() get() = boosters.toSet()
fun Server.expireBooster(booster: Booster) { fun Server.expireBooster(booster: Booster) {
boosters.removeIf { it.booster == booster } boosters.removeIf { it.booster == booster }
ServerProfile.load().write( ServerProfile.load().write(
booster.activeDataKey, booster.activeDataKey,
"" ""
) )
} }
data class ActivatedBooster( data class ActivatedBooster(
val booster: Booster, val booster: Booster,
private val uuid: UUID private val uuid: UUID
) { ) {
val player: OfflinePlayer val player: OfflinePlayer
get() = Bukkit.getOfflinePlayer(uuid) get() = Bukkit.getOfflinePlayer(uuid)
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (other !is ActivatedBooster) { if (other !is ActivatedBooster) {
return false return false
} }
return other.booster == this.booster return other.booster == this.booster
} }
override fun hashCode(): Int { override fun hashCode(): Int {
return Objects.hash(this.booster) return Objects.hash(this.booster)
} }
} }

View File

@@ -1,192 +1,192 @@
package com.willfp.boosters.boosters package com.willfp.boosters.boosters
import com.willfp.boosters.BoostersPlugin import com.willfp.boosters.BoostersPlugin
import com.willfp.boosters.getAmountOfBooster import com.willfp.boosters.getAmountOfBooster
import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.data.keys.PersistentDataKeyType
import com.willfp.eco.core.data.profile import com.willfp.eco.core.data.profile
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
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.core.placeholder.PlayerlessPlaceholder import com.willfp.eco.core.placeholder.PlayerlessPlaceholder
import com.willfp.eco.util.StringUtils import com.willfp.eco.util.StringUtils
import com.willfp.eco.util.formatEco import com.willfp.eco.util.formatEco
import com.willfp.eco.util.savedDisplayName import com.willfp.eco.util.savedDisplayName
import com.willfp.libreforge.Holder import com.willfp.libreforge.Holder
import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.conditions.Conditions
import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.Effects
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import java.util.* import java.util.*
import kotlin.math.floor import kotlin.math.floor
class Booster( class Booster(
private val plugin: BoostersPlugin, private val plugin: BoostersPlugin,
val config: Config, val config: Config,
) : Holder { ) : Holder {
override val id = config.getString("id") override val id = config.getString("id")
val ownedDataKey: PersistentDataKey<Int> = PersistentDataKey( val ownedDataKey: PersistentDataKey<Int> = PersistentDataKey(
plugin.namespacedKeyFactory.create(id), plugin.namespacedKeyFactory.create(id),
PersistentDataKeyType.INT, PersistentDataKeyType.INT,
0 0
).player() ).player()
val activeDataKey: PersistentDataKey<String> = PersistentDataKey( val activeDataKey: PersistentDataKey<String> = PersistentDataKey(
plugin.namespacedKeyFactory.create("${id}_active"), plugin.namespacedKeyFactory.create("${id}_active"),
PersistentDataKeyType.STRING, PersistentDataKeyType.STRING,
"" ""
).server() ).server()
val expiryTimeKey = PersistentDataKey( val expiryTimeKey = PersistentDataKey(
plugin.namespacedKeyFactory.create("${id}_expiry_time"), plugin.namespacedKeyFactory.create("${id}_expiry_time"),
PersistentDataKeyType.DOUBLE, PersistentDataKeyType.DOUBLE,
0.0 0.0
).server() ).server()
val active: ActivatedBooster? val active: ActivatedBooster?
get() { get() {
val activeKey = Bukkit.getServer().profile.read(activeDataKey) val activeKey = Bukkit.getServer().profile.read(activeDataKey)
if (activeKey.isEmpty()) { if (activeKey.isEmpty()) {
return null return null
} }
val uuid = UUID.fromString(activeKey) val uuid = UUID.fromString(activeKey)
return ActivatedBooster(this, uuid) return ActivatedBooster(this, uuid)
} }
val secondsLeft: Int val secondsLeft: Int
get() { get() {
val endTime = Bukkit.getServer().profile.read(expiryTimeKey) val endTime = Bukkit.getServer().profile.read(expiryTimeKey)
val currentTime = System.currentTimeMillis() val currentTime = System.currentTimeMillis()
return if (endTime < currentTime || active == null) { return if (endTime < currentTime || active == null) {
0 0
} else { } else {
((endTime - currentTime) / 1000).toInt() ((endTime - currentTime) / 1000).toInt()
} }
} }
val name = config.getFormattedString("name") val name = config.getFormattedString("name")
val duration = config.getInt("duration") val duration = config.getInt("duration")
fun getActivationMessages(player: Player): List<String> { fun getActivationMessages(player: Player): List<String> {
val messages = mutableListOf<String>() val messages = mutableListOf<String>()
for (string in config.getFormattedStrings( for (string in config.getFormattedStrings(
"messages.activation", "messages.activation",
StringUtils.FormatOption.WITHOUT_PLACEHOLDERS StringUtils.FormatOption.WITHOUT_PLACEHOLDERS
)) { )) {
messages.add(string.replace("%player%", player.displayName)) messages.add(string.replace("%player%", player.displayName))
} }
return messages return messages
} }
val expiryMessages: List<String> = config.getFormattedStrings("messages.expiry") val expiryMessages: List<String> = config.getFormattedStrings("messages.expiry")
val activationCommands: List<String> = config.getFormattedStrings("commands.activation") val activationCommands: List<String> = config.getFormattedStrings("commands.activation")
val expiryCommands: List<String> = config.getFormattedStrings("commands.expiry") val expiryCommands: List<String> = config.getFormattedStrings("commands.expiry")
fun getGuiItem(player: Player): ItemStack { fun getGuiItem(player: Player): ItemStack {
return ItemStackBuilder(Items.lookup(config.getString("gui.item"))) return ItemStackBuilder(Items.lookup(config.getString("gui.item")))
.setDisplayName(config.getFormattedString("gui.name")) .setDisplayName(config.getFormattedString("gui.name"))
.addLoreLines( .addLoreLines(
config.getStrings("gui.lore") config.getStrings("gui.lore")
.map { it.replace("%amount%", player.getAmountOfBooster(this).toString()) } .map { it.replace("%amount%", player.getAmountOfBooster(this).toString()) }
.formatEco(player) .formatEco(player)
) )
.build() .build()
} }
val guiRow = config.getInt("gui.position.row") val guiRow = config.getInt("gui.position.row")
val guiColumn = config.getInt("gui.position.column") val guiColumn = config.getInt("gui.position.column")
override val conditions = config.getSubsections("conditions").mapNotNull { override val conditions = config.getSubsections("conditions").mapNotNull {
Conditions.compile(it, "Booster $id") Conditions.compile(it, "Booster $id")
}.toSet() }.toSet()
override val effects = config.getSubsections("effects").mapNotNull { override val effects = config.getSubsections("effects").mapNotNull {
Effects.compile(it, "Booster $id") Effects.compile(it, "Booster $id")
}.toSet() }.toSet()
init { init {
Boosters.addNewBooster(this) Boosters.addNewBooster(this)
PlaceholderManager.registerPlaceholder( PlaceholderManager.registerPlaceholder(
PlayerlessPlaceholder( PlayerlessPlaceholder(
plugin, plugin,
"${id}_info" "${id}_info"
) { ) {
val active = this.active val active = this.active
if (active != null) { if (active != null) {
plugin.langYml.getString("active-placeholder") plugin.langYml.getString("active-placeholder")
.replace("%player%", active.player.savedDisplayName) .replace("%player%", active.player.savedDisplayName)
.replace("%booster%", active.booster.name) .replace("%booster%", active.booster.name)
.formatEco(formatPlaceholders = false) .formatEco(formatPlaceholders = false)
} else { } else {
plugin.langYml.getString("no-currently-active") plugin.langYml.getString("no-currently-active")
.formatEco(formatPlaceholders = false) .formatEco(formatPlaceholders = false)
} }
} }
) )
PlaceholderManager.registerPlaceholder( PlaceholderManager.registerPlaceholder(
PlayerlessPlaceholder( PlayerlessPlaceholder(
plugin, plugin,
"${id}_player", "${id}_player",
) { ) {
active?.player?.savedDisplayName ?: "" active?.player?.savedDisplayName ?: ""
} }
) )
PlaceholderManager.registerPlaceholder( PlaceholderManager.registerPlaceholder(
PlayerlessPlaceholder( PlayerlessPlaceholder(
plugin, plugin,
"${id}_seconds_remaining" "${id}_seconds_remaining"
) { ) {
secondsLeft.toString() secondsLeft.toString()
} }
) )
PlaceholderManager.registerPlaceholder( PlaceholderManager.registerPlaceholder(
PlayerlessPlaceholder( PlayerlessPlaceholder(
plugin, plugin,
"${id}_time_remaining" "${id}_time_remaining"
) { ) {
if (secondsLeft <= 0) { if (secondsLeft <= 0) {
return@PlayerlessPlaceholder "00:00:00" return@PlayerlessPlaceholder "00:00:00"
} }
// if you've seen this code on the internet, no you haven't. shush // if you've seen this code on the internet, no you haven't. shush
val seconds = secondsLeft % 3600 % 60 val seconds = secondsLeft % 3600 % 60
val minutes = floor(secondsLeft % 3600 / 60.0).toInt() val minutes = floor(secondsLeft % 3600 / 60.0).toInt()
val hours = floor(secondsLeft / 3600.0).toInt() val hours = floor(secondsLeft / 3600.0).toInt()
val hh = (if (hours < 10) "0" else "") + hours val hh = (if (hours < 10) "0" else "") + hours
val mm = (if (minutes < 10) "0" else "") + minutes val mm = (if (minutes < 10) "0" else "") + minutes
val ss = (if (seconds < 10) "0" else "") + seconds val ss = (if (seconds < 10) "0" else "") + seconds
"${hh}:${mm}:${ss}" "${hh}:${mm}:${ss}"
} }
) )
} }
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (other !is Booster) { if (other !is Booster) {
return false return false
} }
return other.id == this.id return other.id == this.id
} }
override fun hashCode(): Int { override fun hashCode(): Int {
return this.id.hashCode() return this.id.hashCode()
} }
} }

View File

@@ -1,76 +1,76 @@
package com.willfp.boosters.boosters package com.willfp.boosters.boosters
import com.google.common.collect.BiMap 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.boosters.BoostersPlugin import com.willfp.boosters.BoostersPlugin
import com.willfp.eco.core.config.updating.ConfigUpdater import com.willfp.eco.core.config.updating.ConfigUpdater
import com.willfp.libreforge.chains.EffectChains import com.willfp.libreforge.chains.EffectChains
object Boosters { object Boosters {
/** /**
* Registered boosters. * Registered boosters.
*/ */
private val BY_ID: BiMap<String, Booster> = HashBiMap.create() private val BY_ID: BiMap<String, Booster> = HashBiMap.create()
/** /**
* Get all registered [Booster]s. * Get all registered [Booster]s.
* *
* @return A list of all [Booster]s. * @return A list of all [Booster]s.
*/ */
@JvmStatic @JvmStatic
fun values(): List<Booster> { fun values(): List<Booster> {
return ImmutableList.copyOf(BY_ID.values) return ImmutableList.copyOf(BY_ID.values)
} }
/** /**
* Get [Booster] matching ID. * Get [Booster] matching ID.
* *
* @param name The name to search for. * @param name The name to search for.
* @return The matching [Booster], or null if not found. * @return The matching [Booster], or null if not found.
*/ */
@JvmStatic @JvmStatic
fun getByID(name: String): Booster? { fun getByID(name: String): Booster? {
return BY_ID[name] return BY_ID[name]
} }
/** /**
* Update all [Booster]s. * Update all [Booster]s.
* *
* @param plugin Instance of Booster. * @param plugin Instance of Booster.
*/ */
@ConfigUpdater @ConfigUpdater
@JvmStatic @JvmStatic
fun update(plugin: BoostersPlugin) { fun update(plugin: BoostersPlugin) {
plugin.boostersYml.getSubsections("chains").mapNotNull { plugin.boostersYml.getSubsections("chains").mapNotNull {
EffectChains.compile(it, "Effect Chains") EffectChains.compile(it, "Effect Chains")
} }
for (booster in values()) { for (booster in values()) {
removeBooster(booster) removeBooster(booster)
} }
for (config in plugin.boostersYml.getSubsections("boosters")) { for (config in plugin.boostersYml.getSubsections("boosters")) {
Booster(plugin, config) Booster(plugin, config)
} }
} }
/** /**
* Add new [Booster] to Booster. * Add new [Booster] to Booster.
* *
* @param booster The [Booster] to add. * @param booster The [Booster] to add.
*/ */
@JvmStatic @JvmStatic
fun addNewBooster(booster: Booster) { fun addNewBooster(booster: Booster) {
BY_ID.remove(booster.id) BY_ID.remove(booster.id)
BY_ID[booster.id] = booster BY_ID[booster.id] = booster
} }
/** /**
* Remove [Booster] from Booster. * Remove [Booster] from Booster.
* *
* @param booster The [Booster] to remove. * @param booster The [Booster] to remove.
*/ */
@JvmStatic @JvmStatic
fun removeBooster(booster: Booster) { fun removeBooster(booster: Booster) {
BY_ID.remove(booster.id) BY_ID.remove(booster.id)
} }
} }

View File

@@ -1,53 +1,53 @@
package com.willfp.boosters.commands package com.willfp.boosters.commands
import com.willfp.boosters.activateBooster import com.willfp.boosters.activateBooster
import com.willfp.boosters.boosters.Boosters import com.willfp.boosters.boosters.Boosters
import com.willfp.boosters.incrementBoosters import com.willfp.boosters.incrementBoosters
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.core.command.impl.Subcommand
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.util.StringUtil import org.bukkit.util.StringUtil
class CommandActivate(plugin: EcoPlugin) : class CommandActivate(plugin: EcoPlugin) :
Subcommand( Subcommand(
plugin, plugin,
"activate", "activate",
"boosters.command.activate", "boosters.command.activate",
true true
) { ) {
override fun onExecute(sender: CommandSender, args: List<String>) { override fun onExecute(sender: CommandSender, args: List<String>) {
val player = sender as? Player ?: return val player = sender as? Player ?: return
if (args.isEmpty()) { if (args.isEmpty()) {
sender.sendMessage(plugin.langYml.getMessage("requires-booster")) sender.sendMessage(plugin.langYml.getMessage("requires-booster"))
return return
} }
val booster = Boosters.getByID(args[0].lowercase()) val booster = Boosters.getByID(args[0].lowercase())
if (booster == null) { if (booster == null) {
sender.sendMessage(plugin.langYml.getMessage("invalid-booster")) sender.sendMessage(plugin.langYml.getMessage("invalid-booster"))
return return
} }
player.incrementBoosters(booster, 1) player.incrementBoosters(booster, 1)
player.activateBooster(booster) player.activateBooster(booster)
} }
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> { override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
val completions = mutableListOf<String>() val completions = mutableListOf<String>()
if (args.size == 1) { if (args.size == 1) {
StringUtil.copyPartialMatches( StringUtil.copyPartialMatches(
args[0], args[0],
Boosters.values().map { it.id }, Boosters.values().map { it.id },
completions completions
) )
return completions return completions
} }
return emptyList() return emptyList()
} }
} }

View File

@@ -1,32 +1,32 @@
package com.willfp.boosters.commands package com.willfp.boosters.commands
import com.willfp.boosters.gui.BoosterGUI import com.willfp.boosters.gui.BoosterGUI
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.core.command.impl.PluginCommand
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.entity.Player import org.bukkit.entity.Player
class CommandBoosters(plugin: EcoPlugin) : class CommandBoosters(plugin: EcoPlugin) :
PluginCommand( PluginCommand(
plugin, plugin,
"boosters", "boosters",
"boosters.command.boosters", "boosters.command.boosters",
false false
) { ) {
init { init {
this.addSubcommand(CommandGive(plugin)) this.addSubcommand(CommandGive(plugin))
.addSubcommand(CommandReload(plugin)) .addSubcommand(CommandReload(plugin))
.addSubcommand(CommandCancel(plugin)) .addSubcommand(CommandCancel(plugin))
.addSubcommand(CommandActivate(plugin)) .addSubcommand(CommandActivate(plugin))
} }
override fun onExecute(sender: CommandSender, args: List<String>) { override fun onExecute(sender: CommandSender, args: List<String>) {
if (sender !is Player) { if (sender !is Player) {
sender.sendMessage(this.plugin.langYml.getMessage("not-player")) sender.sendMessage(this.plugin.langYml.getMessage("not-player"))
return return
} }
BoosterGUI.open(sender) BoosterGUI.open(sender)
} }
} }

View File

@@ -1,25 +1,25 @@
package com.willfp.boosters.commands package com.willfp.boosters.commands
import com.willfp.boosters.BoostersPlugin import com.willfp.boosters.BoostersPlugin
import com.willfp.boosters.boosters.activeBoosters import com.willfp.boosters.boosters.activeBoosters
import com.willfp.boosters.boosters.expireBooster import com.willfp.boosters.boosters.expireBooster
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.core.command.impl.Subcommand
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
class CommandCancel(plugin: EcoPlugin) : class CommandCancel(plugin: EcoPlugin) :
Subcommand( Subcommand(
plugin, plugin,
"cancel", "cancel",
"boosters.command.cancel", "boosters.command.cancel",
false false
) { ) {
override fun onExecute(sender: CommandSender, args: List<String>) { override fun onExecute(sender: CommandSender, args: List<String>) {
for (booster in Bukkit.getServer().activeBoosters) { for (booster in Bukkit.getServer().activeBoosters) {
Bukkit.getServer().expireBooster(booster.booster) Bukkit.getServer().expireBooster(booster.booster)
} }
sender.sendMessage(plugin.langYml.getMessage("cancelled")) sender.sendMessage(plugin.langYml.getMessage("cancelled"))
} }
} }

View File

@@ -1,100 +1,100 @@
package com.willfp.boosters.commands package com.willfp.boosters.commands
import com.willfp.boosters.boosters.Boosters import com.willfp.boosters.boosters.Boosters
import com.willfp.boosters.incrementBoosters import com.willfp.boosters.incrementBoosters
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.core.command.impl.Subcommand
import com.willfp.eco.util.StringUtils import com.willfp.eco.util.StringUtils
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.util.StringUtil import org.bukkit.util.StringUtil
class CommandGive(plugin: EcoPlugin) : class CommandGive(plugin: EcoPlugin) :
Subcommand( Subcommand(
plugin, plugin,
"give", "give",
"boosters.command.give", "boosters.command.give",
false false
) { ) {
override fun onExecute(sender: CommandSender, args: List<String>) { override fun onExecute(sender: CommandSender, args: List<String>) {
if (args.isEmpty()) { if (args.isEmpty()) {
sender.sendMessage(plugin.langYml.getMessage("requires-player")) sender.sendMessage(plugin.langYml.getMessage("requires-player"))
return return
} }
if (args.size == 1) { if (args.size == 1) {
sender.sendMessage(plugin.langYml.getMessage("requires-booster")) sender.sendMessage(plugin.langYml.getMessage("requires-booster"))
return return
} }
val booster = Boosters.getByID(args[1].lowercase()) val booster = Boosters.getByID(args[1].lowercase())
if (booster == null) { if (booster == null) {
sender.sendMessage(plugin.langYml.getMessage("invalid-booster")) sender.sendMessage(plugin.langYml.getMessage("invalid-booster"))
return return
} }
var amount = 1 var amount = 1
if (args.size >= 3) { if (args.size >= 3) {
amount = args[2].toIntOrNull() ?: amount amount = args[2].toIntOrNull() ?: amount
} }
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
val player = Bukkit.getOfflinePlayer(args[0]) val player = Bukkit.getOfflinePlayer(args[0])
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
sender.sendMessage(plugin.langYml.getMessage("invalid-player")) sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
return return
} }
player.incrementBoosters(booster, amount) player.incrementBoosters(booster, amount)
sender.sendMessage( sender.sendMessage(
plugin.langYml.getMessage("gave-booster", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS) plugin.langYml.getMessage("gave-booster", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
.replace("%player%", player.name ?: return) .replace("%player%", player.name ?: return)
.replace("%booster%", booster.name) .replace("%booster%", booster.name)
.replace("%amount%", amount.toString()) .replace("%amount%", amount.toString())
) )
} }
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> { override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
val completions = mutableListOf<String>() val completions = mutableListOf<String>()
if (args.size == 1) { if (args.size == 1) {
StringUtil.copyPartialMatches( StringUtil.copyPartialMatches(
args[0], args[0],
Bukkit.getOnlinePlayers().map { player -> player.name }.toCollection(ArrayList()), Bukkit.getOnlinePlayers().map { player -> player.name }.toCollection(ArrayList()),
completions completions
) )
return completions return completions
} }
if (args.size == 2) { if (args.size == 2) {
StringUtil.copyPartialMatches( StringUtil.copyPartialMatches(
args[1], args[1],
Boosters.values().map { it.id }, Boosters.values().map { it.id },
completions completions
) )
return completions return completions
} }
if (args.size == 3) { if (args.size == 3) {
StringUtil.copyPartialMatches( StringUtil.copyPartialMatches(
args[2], args[2],
listOf( listOf(
"1", "1",
"2", "2",
"3", "3",
"4", "4",
"5", "5",
"10" "10"
), ),
completions completions
) )
return completions return completions
} }
return emptyList() return emptyList()
} }
} }

View File

@@ -1,19 +1,19 @@
package com.willfp.boosters.commands package com.willfp.boosters.commands
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.core.command.impl.Subcommand
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
class CommandReload(plugin: EcoPlugin) : class CommandReload(plugin: EcoPlugin) :
Subcommand( Subcommand(
plugin, plugin,
"reload", "reload",
"boosters.command.reload", "boosters.command.reload",
false false
) { ) {
override fun onExecute(sender: CommandSender, args: List<String>) { override fun onExecute(sender: CommandSender, args: List<String>) {
plugin.reload() plugin.reload()
sender.sendMessage(plugin.langYml.getMessage("reloaded")) sender.sendMessage(plugin.langYml.getMessage("reloaded"))
} }
} }

View File

@@ -1,12 +1,12 @@
package com.willfp.boosters.config package com.willfp.boosters.config
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.config.BaseConfig import com.willfp.eco.core.config.BaseConfig
import com.willfp.eco.core.config.ConfigType import com.willfp.eco.core.config.ConfigType
class BoostersYml(plugin: EcoPlugin) : BaseConfig( class BoostersYml(plugin: EcoPlugin) : BaseConfig(
"boosters", "boosters",
plugin, plugin,
false, false,
ConfigType.YAML ConfigType.YAML
) )

View File

@@ -1,81 +1,81 @@
package com.willfp.boosters.gui package com.willfp.boosters.gui
import com.willfp.boosters.BoostersPlugin import com.willfp.boosters.BoostersPlugin
import com.willfp.boosters.activateBooster import com.willfp.boosters.activateBooster
import com.willfp.boosters.boosters.Booster import com.willfp.boosters.boosters.Booster
import com.willfp.boosters.boosters.Boosters import com.willfp.boosters.boosters.Boosters
import com.willfp.eco.core.config.updating.ConfigUpdater import com.willfp.eco.core.config.updating.ConfigUpdater
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.slot import com.willfp.eco.core.gui.slot
import com.willfp.eco.core.gui.slot.FillerMask import com.willfp.eco.core.gui.slot.FillerMask
import com.willfp.eco.core.gui.slot.MaskItems import com.willfp.eco.core.gui.slot.MaskItems
import com.willfp.eco.core.gui.slot.functional.SlotHandler import com.willfp.eco.core.gui.slot.functional.SlotHandler
import com.willfp.eco.util.tryAsPlayer import com.willfp.eco.util.tryAsPlayer
import org.bukkit.Sound import org.bukkit.Sound
import org.bukkit.entity.Player import org.bukkit.entity.Player
object BoosterGUI { object BoosterGUI {
private lateinit var gui: Menu private lateinit var gui: Menu
private fun makeHandler(booster: Booster, plugin: BoostersPlugin): SlotHandler { private fun makeHandler(booster: Booster, plugin: BoostersPlugin): SlotHandler {
return SlotHandler { event, _, _ -> return SlotHandler { event, _, _ ->
val player = event.whoClicked.tryAsPlayer() ?: return@SlotHandler val player = event.whoClicked.tryAsPlayer() ?: return@SlotHandler
if (booster.active != null) { if (booster.active != null) {
player.sendMessage(plugin.langYml.getMessage("already-active")) player.sendMessage(plugin.langYml.getMessage("already-active"))
player.playSound( player.playSound(
player.location, player.location,
Sound.BLOCK_NOTE_BLOCK_BASS, Sound.BLOCK_NOTE_BLOCK_BASS,
1f, 1f,
0.5f 0.5f
) )
return@SlotHandler return@SlotHandler
} }
if (!player.activateBooster(booster)) { if (!player.activateBooster(booster)) {
player.sendMessage(plugin.langYml.getMessage("dont-have")) player.sendMessage(plugin.langYml.getMessage("dont-have"))
player.playSound( player.playSound(
player.location, player.location,
Sound.BLOCK_NOTE_BLOCK_BASS, Sound.BLOCK_NOTE_BLOCK_BASS,
1f, 1f,
0.5f 0.5f
) )
return@SlotHandler return@SlotHandler
} }
player.closeInventory() player.closeInventory()
} }
} }
@JvmStatic @JvmStatic
@ConfigUpdater @ConfigUpdater
fun update(plugin: BoostersPlugin) { fun update(plugin: BoostersPlugin) {
gui = menu(plugin.configYml.getInt("gui.rows")) { gui = menu(plugin.configYml.getInt("gui.rows")) {
setMask( setMask(
FillerMask( FillerMask(
MaskItems.fromItemNames(plugin.configYml.getStrings("gui.mask.items")), MaskItems.fromItemNames(plugin.configYml.getStrings("gui.mask.items")),
*plugin.configYml.getStrings("gui.mask.pattern").toTypedArray() *plugin.configYml.getStrings("gui.mask.pattern").toTypedArray()
) )
) )
for (booster in Boosters.values()) { for (booster in Boosters.values()) {
setSlot( setSlot(
booster.guiRow, booster.guiRow,
booster.guiColumn, booster.guiColumn,
slot( slot(
{ player, _ -> booster.getGuiItem(player) } { player, _ -> booster.getGuiItem(player) }
) { ) {
onLeftClick(makeHandler(booster, plugin)) onLeftClick(makeHandler(booster, plugin))
} }
) )
} }
setTitle(plugin.configYml.getFormattedString("gui.title")) setTitle(plugin.configYml.getFormattedString("gui.title"))
} }
} }
fun open(player: Player) { fun open(player: Player) {
gui.open(player) gui.open(player)
} }
} }

View File

@@ -1,124 +1,124 @@
boosters: boosters:
- id: 1_5sell_multiplier - id: 1_5sell_multiplier
name: "1.5x Sell Multiplier" name: "1.5x Sell Multiplier"
duration: 72000 duration: 72000
effects: effects:
- id: sell_multiplier - id: sell_multiplier
args: args:
multiplier: 1.5 multiplier: 1.5
conditions: [] conditions: []
commands: commands:
activation: [] activation: []
expiry: [] expiry: []
messages: messages:
activation: activation:
- "" - ""
- " %player%&f has activated a &a1.5x Sell Multiplier Booster&f!" - " %player%&f has activated a &a1.5x Sell Multiplier Booster&f!"
- " &fThis booster will last an hour, be sure to thank them!" - " &fThis booster will last an hour, be sure to thank them!"
- "" - ""
expiry: expiry:
- "" - ""
- " &fThe &a1.5x Sell Multiplier Booster&f has ended" - " &fThe &a1.5x Sell Multiplier Booster&f has ended"
- " &fGet another one here: &ahttps://store.ecomc.net/package/756887" - " &fGet another one here: &ahttps://store.ecomc.net/package/756887"
- "" - ""
gui: gui:
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ== item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ==
name: "&d1.5x Sell Multiplier" name: "&d1.5x Sell Multiplier"
lore: lore:
- "" - ""
- "&fGives everyone online a" - "&fGives everyone online a"
- "&a1.5x Sell Multiplier" - "&a1.5x Sell Multiplier"
- "&fto make money faster!" - "&fto make money faster!"
- "" - ""
- "&fDuration: &a1 Hour" - "&fDuration: &a1 Hour"
- "" - ""
- "&fYou have: &a%amount%" - "&fYou have: &a%amount%"
- "&fGet more at &astore.ecomc.net" - "&fGet more at &astore.ecomc.net"
- "" - ""
- "&e&oClick to activate!" - "&e&oClick to activate!"
- "" - ""
position: position:
row: 2 row: 2
column: 2 column: 2
- id: 2sell_multiplier - id: 2sell_multiplier
name: "2x Sell Multiplier" name: "2x Sell Multiplier"
duration: 72000 duration: 72000
effects: effects:
- id: sell_multiplier - id: sell_multiplier
args: args:
multiplier: 2 multiplier: 2
conditions: [] conditions: []
commands: commands:
activation: [] activation: []
expiry: [] expiry: []
messages: messages:
activation: activation:
- "" - ""
- " %player%&f has activated a &a2x Sell Multiplier Booster&f!" - " %player%&f has activated a &a2x Sell Multiplier Booster&f!"
- " &fThis booster will last an hour, be sure to thank them!" - " &fThis booster will last an hour, be sure to thank them!"
- "" - ""
expiry: expiry:
- "" - ""
- " &fThe &a2x Sell Multiplier Booster&f has ended" - " &fThe &a2x Sell Multiplier Booster&f has ended"
- " &fGet another one here: &ahttps://store.ecomc.net/package/756888" - " &fGet another one here: &ahttps://store.ecomc.net/package/756888"
- "" - ""
gui: gui:
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBhN2I5NGM0ZTU4MWI2OTkxNTlkNDg4NDZlYzA5MTM5MjUwNjIzN2M4OWE5N2M5MzI0OGEwZDhhYmM5MTZkNSJ9fX0= item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBhN2I5NGM0ZTU4MWI2OTkxNTlkNDg4NDZlYzA5MTM5MjUwNjIzN2M4OWE5N2M5MzI0OGEwZDhhYmM5MTZkNSJ9fX0=
name: "&d2x Sell Multiplier" name: "&d2x Sell Multiplier"
lore: lore:
- "" - ""
- "&fGives everyone online a" - "&fGives everyone online a"
- "&a2x Sell Multiplier" - "&a2x Sell Multiplier"
- "&fto make money faster!" - "&fto make money faster!"
- "" - ""
- "&fDuration: &a1 Hour" - "&fDuration: &a1 Hour"
- "" - ""
- "&fYou have: &a%amount%" - "&fYou have: &a%amount%"
- "&fGet more at &astore.ecomc.net" - "&fGet more at &astore.ecomc.net"
- "" - ""
- "&e&oClick to activate!" - "&e&oClick to activate!"
- "" - ""
position: position:
row: 2 row: 2
column: 5 column: 5
- id: skill_xp - id: skill_xp
name: "2x Skill XP Multiplier" name: "2x Skill XP Multiplier"
duration: 72000 duration: 72000
effects: effects:
- id: skill_xp_multiplier - id: skill_xp_multiplier
args: args:
multiplier: 2 multiplier: 2
conditions: [] conditions: []
commands: commands:
activation: [] activation: []
expiry: [] expiry: []
messages: messages:
activation: activation:
- "" - ""
- " %player%&f has activated a &a2x Skill XP Booster&f!" - " %player%&f has activated a &a2x Skill XP Booster&f!"
- " &fThis booster will last an hour, be sure to thank them!" - " &fThis booster will last an hour, be sure to thank them!"
- "" - ""
expiry: expiry:
- "" - ""
- " &fThe &a2x Skill XP Booster&f has ended" - " &fThe &a2x Skill XP Booster&f has ended"
- " &fGet another one here: &ahttps://store.ecomc.net/package/756893" - " &fGet another one here: &ahttps://store.ecomc.net/package/756893"
- "" - ""
gui: gui:
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkyNmMxZjJjM2MxNGQwODZjNDBjZmMyMzVmZTkzODY5NGY0YTUxMDY3YWRhNDcyNmI0ODZlYTFjODdiMDNlMiJ9fX0= item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkyNmMxZjJjM2MxNGQwODZjNDBjZmMyMzVmZTkzODY5NGY0YTUxMDY3YWRhNDcyNmI0ODZlYTFjODdiMDNlMiJ9fX0=
name: "&d2x Skill XP Multiplier" name: "&d2x Skill XP Multiplier"
lore: lore:
- "" - ""
- "&fGives everyone online a" - "&fGives everyone online a"
- "&a2x Skill XP Multiplier" - "&a2x Skill XP Multiplier"
- "&fto level up faster!" - "&fto level up faster!"
- "" - ""
- "&fDuration: &a1 Hour" - "&fDuration: &a1 Hour"
- "" - ""
- "&fYou have: &a%amount%" - "&fYou have: &a%amount%"
- "&fGet more at &astore.ecomc.net" - "&fGet more at &astore.ecomc.net"
- "" - ""
- "&e&oClick to activate!" - "&e&oClick to activate!"
- "" - ""
position: position:
row: 2 row: 2
column: 8 column: 8

View File

@@ -1,54 +1,54 @@
# #
# Boosters # Boosters
# by Auxilor # by Auxilor
# #
gui: gui:
title: Boosters title: Boosters
rows: 3 rows: 3
mask: mask:
items: items:
- black_stained_glass_Pane - black_stained_glass_Pane
pattern: pattern:
- "111111111" - "111111111"
- "101101101" - "101101101"
- "111111111" - "111111111"
cooldown: cooldown:
in-actionbar: true in-actionbar: true
sound: sound:
enabled: true enabled: true
sound: "BLOCK_NOTE_BLOCK_PLING" sound: "BLOCK_NOTE_BLOCK_PLING"
pitch: 0.5 pitch: 0.5
cannot-afford: cannot-afford:
in-actionbar: true in-actionbar: true
sound: sound:
enabled: true enabled: true
sound: "BLOCK_NOTE_BLOCK_PLING" sound: "BLOCK_NOTE_BLOCK_PLING"
pitch: 0.5 pitch: 0.5
cannot-afford-type: cannot-afford-type:
in-actionbar: true in-actionbar: true
sound: sound:
enabled: true enabled: true
sound: "BLOCK_NOTE_BLOCK_PLING" sound: "BLOCK_NOTE_BLOCK_PLING"
pitch: 0.5 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"
use-faster-move-trigger: true # Disable if you want move trigger to detect sub-1-block movements use-faster-move-trigger: true # Disable if you want move trigger to detect sub-1-block movements
raytrace-distance: 80 # The distance that alt_click should check for a location raytrace-distance: 80 # The distance that alt_click should check for a location
block-item-drop-place-check: true # If the block_item_drop trigger should only fire on naturally placed blocks (prevents dupes) block-item-drop-place-check: true # If the block_item_drop trigger should only fire on naturally placed blocks (prevents dupes)
potions: potions:
icon: icon:
permanent: true permanent: true
triggered: true triggered: true
ambient: ambient:
permanent: false permanent: false
triggered: true triggered: true
particles: particles:
permanent: false permanent: false
triggered: true triggered: true

View File

@@ -1,3 +1,3 @@
resource-id: 2036 resource-id: 2036
bstats-id: 14269 bstats-id: 14269
color: "&e" color: "&e"

View File

@@ -1,21 +1,21 @@
messages: messages:
prefix: "&a&lBoosters&r &8» &r" prefix: "&a&lBoosters&r &8» &r"
no-permission: "&cYou don't have permission to do this!" no-permission: "&cYou don't have permission to do this!"
not-player: "&cThis command must be run by a player" not-player: "&cThis command must be run by a player"
invalid-command: "&cUnknown subcommand!" invalid-command: "&cUnknown subcommand!"
reloaded: "Reloaded!" reloaded: "Reloaded!"
requires-player: "&cYou must specify a player!" requires-player: "&cYou must specify a player!"
invalid-player: "&cInvalid player!" invalid-player: "&cInvalid player!"
requires-booster: "&cYou must specify a booster!" requires-booster: "&cYou must specify a booster!"
invalid-booster: "&cInvalid booster!" invalid-booster: "&cInvalid booster!"
gave-booster: "Gave %player% %booster% &fx%amount%!" gave-booster: "Gave %player% %booster% &fx%amount%!"
already-active: "&cThis booster is already active!" already-active: "&cThis booster is already active!"
dont-have: "&cYou don't have any of these boosters! Get some at &astore.ecomc.net" dont-have: "&cYou don't have any of these boosters! Get some at &astore.ecomc.net"
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-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%"
cancelled: "Cancelled the active boosters" cancelled: "Cancelled the active boosters"
cannot-transmit: "&cYou can't transmit here!" cannot-transmit: "&cYou can't transmit here!"
no-currently-active: "&cNot Active!" no-currently-active: "&cNot Active!"
active-placeholder: "&fThanks %player% &ffor activating %booster%&f!" active-placeholder: "&fThanks %player% &ffor activating %booster%&f!"

View File

@@ -1,57 +1,57 @@
name: Boosters name: Boosters
version: ${projectVersion} version: ${projectVersion}
main: com.willfp.boosters.BoostersPlugin main: com.willfp.boosters.BoostersPlugin
api-version: 1.17 api-version: 1.17
authors: [ Auxilor ] authors: [ Auxilor ]
website: willfp.com website: willfp.com
load: POSTWORLD load: POSTWORLD
depend: depend:
- eco - eco
- PlaceholderAPI - PlaceholderAPI
softdepend: softdepend:
- EcoSkills - EcoSkills
- AureliumSkills - AureliumSkills
- Jobs - Jobs
- mcMMO - mcMMO
- Vault - Vault
- EcoArmor - EcoArmor
- TMMobcoins - TMMobcoins
commands: commands:
boosters: boosters:
description: Base Command description: Base Command
permission: boosters.command.boosters permission: boosters.command.boosters
aliases: aliases:
- boost - boost
permissions: permissions:
boosters.*: boosters.*:
description: All boosters permissions description: All boosters permissions
default: op default: op
children: children:
boosters.command.*: true boosters.command.*: true
boosters.command.*: boosters.command.*:
description: All commands description: All commands
default: op default: op
children: children:
boosters.command.reload: true boosters.command.reload: true
boosters.command.give: true boosters.command.give: true
boosters.command.boosters: true boosters.command.boosters: true
boosters.command.cancel: true boosters.command.cancel: true
boosters.command.activate: true boosters.command.activate: true
boosters.command.reload: boosters.command.reload:
description: Allows reloading the config description: Allows reloading the config
default: op default: op
boosters.command.boosters: boosters.command.boosters:
description: Allows the use of /boosters. description: Allows the use of /boosters.
default: true default: true
boosters.command.give: boosters.command.give:
description: Allows the use of /boosters give. description: Allows the use of /boosters give.
default: op default: op
boosters.command.activate: boosters.command.activate:
description: Allows the use of /boosters activate. description: Allows the use of /boosters activate.
default: op default: op
boosters.command.cancel: boosters.command.cancel:
description: Allows the use of /boosters cancel. description: Allows the use of /boosters cancel.
default: op default: op

View File

@@ -1,4 +1,4 @@
#libreforge-updater #libreforge-updater
#Mon May 16 13:04:37 BST 2022 #Mon May 16 13:08:11 BST 2022
version=4.6.3 version=4.6.4
plugin-name=Boosters plugin-name=Boosters

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

468
gradlew vendored
View File

@@ -1,234 +1,234 @@
#!/bin/sh #!/bin/sh
# #
# Copyright <20> 2015-2021 the original authors. # Copyright <20> 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# https://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
############################################################################## ##############################################################################
# #
# Gradle start up script for POSIX generated by Gradle. # Gradle start up script for POSIX generated by Gradle.
# #
# Important for running: # Important for running:
# #
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or # noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole # bash, then to run this script, type that shell name before the whole
# command line, like: # command line, like:
# #
# ksh Gradle # ksh Gradle
# #
# Busybox and similar reduced shells will NOT work, because this script # Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features: # requires all of these POSIX shell features:
# * functions; # * functions;
# * expansions <20>$var<61>, <20>${var}<7D>, <20>${var:-default}<7D>, <20>${var+SET}<7D>, # * expansions <20>$var<61>, <20>${var}<7D>, <20>${var:-default}<7D>, <20>${var+SET}<7D>,
# <20>${var#prefix}<7D>, <20>${var%suffix}<7D>, and <20>$( cmd )<29>; # <20>${var#prefix}<7D>, <20>${var%suffix}<7D>, and <20>$( cmd )<29>;
# * compound commands having a testable exit status, especially <20>case<73>; # * compound commands having a testable exit status, especially <20>case<73>;
# * various built-in commands including <20>command<6E>, <20>set<65>, and <20>ulimit<69>. # * various built-in commands including <20>command<6E>, <20>set<65>, and <20>ulimit<69>.
# #
# Important for patching: # Important for patching:
# #
# (2) This script targets any POSIX shell, so it avoids extensions provided # (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided. # by Bash, Ksh, etc; in particular arrays are avoided.
# #
# The "traditional" practice of packing multiple parameters into a # The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security # space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating # problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java. # options in "$@", and eventually passing that to Java.
# #
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details. # see the in-line comments for details.
# #
# There are tweaks for specific operating systems such as AIX, CygWin, # There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
# #
############################################################################## ##############################################################################
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
app_path=$0 app_path=$0
# Need this for daisy-chained symlinks. # Need this for daisy-chained symlinks.
while while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ] [ -h "$app_path" ]
do do
ls=$( ls -ld "$app_path" ) ls=$( ls -ld "$app_path" )
link=${ls#*' -> '} link=${ls#*' -> '}
case $link in #( case $link in #(
/*) app_path=$link ;; #( /*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;; *) app_path=$APP_HOME$link ;;
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} >&2 } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} >&2 } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "$( uname )" in #( case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #( CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #( Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #( MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;; NONSTOP* ) nonstop=true ;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD=$JAVA_HOME/bin/java JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
fi fi
# Collect all arguments for the java command, stacking in reverse order: # Collect all arguments for the java command, stacking in reverse order:
# * args from the command line # * args from the command line
# * the main class name # * the main class name
# * -classpath # * -classpath
# * -D...appname settings # * -D...appname settings
# * --module-path (only if needed) # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" ) JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh # Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do for arg do
if if
case $arg in #( case $arg in #(
-*) false ;; # don't mess with options #( -*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #( [ -e "$t" ] ;; #(
*) false ;; *) false ;;
esac esac
then then
arg=$( cygpath --path --ignore --mixed "$arg" ) arg=$( cygpath --path --ignore --mixed "$arg" )
fi fi
# Roll the args list around exactly as many times as the number of # Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but # args, so each arg winds up back in the position where it started, but
# possibly modified. # possibly modified.
# #
# NB: a `for` loop captures its iteration list before it begins, so # NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of # changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`. # iterations, nor the values presented in `arg`.
shift # remove old arg shift # remove old arg
set -- "$@" "$arg" # push replacement arg set -- "$@" "$arg" # push replacement arg
done done
fi fi
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and # double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded. # * put everything else in single quotes, so that it's not re-expanded.
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \ -classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
# #
# In Bash we could simply go: # In Bash we could simply go:
# #
# readarray ARGS < <( xargs -n1 <<<"$var" ) && # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@" # set -- "${ARGS[@]}" "$@"
# #
# but POSIX shell has neither arrays nor command substitution, so instead we # but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any # post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse # character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap # that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement. # the whole thing up as a single "set" statement.
# #
# This will of course break if any of these variables contains a newline or # This will of course break if any of these variables contains a newline or
# an unmatched quote. # an unmatched quote.
# #
eval "set -- $( eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 | xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' ' tr '\n' ' '
)" '"$@"' )" '"$@"'
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"

178
gradlew.bat vendored
View File

@@ -1,89 +1,89 @@
@rem @rem
@rem Copyright 2015 the original author or authors. @rem Copyright 2015 the original author or authors.
@rem @rem
@rem Licensed under the Apache License, Version 2.0 (the "License"); @rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License. @rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at @rem You may obtain a copy of the License at
@rem @rem
@rem https://www.apache.org/licenses/LICENSE-2.0 @rem https://www.apache.org/licenses/LICENSE-2.0
@rem @rem
@rem Unless required by applicable law or agreed to in writing, software @rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS, @rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@rem @rem
@rem ########################################################################## @rem ##########################################################################
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter. @rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:findJavaFromJavaHome :findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if "%ERRORLEVEL%"=="0" goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1 exit /b 1
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal
:omega :omega

View File

@@ -1,6 +1,6 @@
jdk: openjdk16 jdk: openjdk16
before_install: before_install:
- source "$HOME/.sdkman/bin/sdkman-init.sh" - source "$HOME/.sdkman/bin/sdkman-init.sh"
- sdk update - sdk update
- sdk install java 16.0.1-open - sdk install java 16.0.1-open
- sdk use java 16.0.1-open - sdk use java 16.0.1-open

View File

@@ -1,5 +1,5 @@
rootProject.name = 'Boosters' rootProject.name = 'Boosters'
// Core // Core
include ':eco-core' include ':eco-core'
include ':eco-core:core-plugin' include ':eco-core:core-plugin'