Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjarne Roß committed Aug 5, 2021
1 parent 3158ffa commit cce290a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
17 changes: 13 additions & 4 deletions src/main/kotlin/BeaconRange.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.bukkit.potion.PotionEffectType
import org.bukkit.inventory.ShapedRecipe

import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta


class BeaconRange : JavaPlugin(){
Expand All @@ -33,8 +34,10 @@ class BeaconRange : JavaPlugin(){

private fun addSSRecipe() {
val superStar = ItemStack(Material.NETHER_STAR)
superStar.itemMeta?.setDisplayName("Super Star (enabled)")
superStar.itemMeta?.lore = listOf("No effects")
val meta = superStar.itemMeta!!
meta.setDisplayName("Super Star (enabled)")
meta.lore = listOf("No effects")
superStar.itemMeta = meta
val superStarRec = ShapedRecipe(NamespacedKey(this, "superStar"), superStar)
superStarRec.shape("SSS", "SSS", "SSS")
superStarRec.setIngredient('S', Material.NETHER_STAR)
Expand All @@ -53,6 +56,7 @@ class BeaconRange : JavaPlugin(){
val defaultPrim: String? = config.getString("defaultPrim")
val defaultSec: String? = config.getString("defaultSec")
val useSuperStar: Boolean = config.getBoolean("useSuperStar")
val superStarWBeacon: Boolean = config.getBoolean("superStarWBeacon")
server.worlds.forEach { world ->
val loadedChunks = world.loadedChunks
val beacons: MutableList<Beacon> = mutableListOf()
Expand Down Expand Up @@ -108,6 +112,9 @@ class BeaconRange : JavaPlugin(){
}
if (useSuperStar) {
setSuperStar(player, beaconEffects)
if (!superStarWBeacon) {
addSuperStarEffects(player)
}
}
}
world.loadedChunks.forEach { chunk ->
Expand Down Expand Up @@ -152,12 +159,14 @@ class BeaconRange : JavaPlugin(){
private fun setSuperStar (player: Player, beaconEffects: MutableMap<PotionEffectType, Int>) {
val inv = player.inventory
if (inv.itemInOffHand.itemMeta?.displayName?.contains("Super Star") == true) {
if (beaconEffects.keys.count() > 0) {
if (beaconEffects.keys.isNotEmpty()) {
val meta = inv.itemInOffHand.itemMeta!!
val lore = mutableListOf<String>()
beaconEffects.forEach { beaconEffect ->
lore.add(beaconEffect.key.name+": "+beaconEffect.value.toString())
}
inv.itemInOffHand.itemMeta?.lore = lore
meta.lore = lore
inv.itemInOffHand.itemMeta = meta
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ useDefault: true
defaultPrim: NIGHT_VISION
defaultSec: SATURATION
# Must be boolean: Whether to use the super star for transmitting stored effects
useSuperStar: false
useSuperStar: false
# Must be boolean: Whether the super star needs to be used with or without a beacon in the near
superStarWBeacon: true

0 comments on commit cce290a

Please sign in to comment.