Skip to content

Commit

Permalink
1.17 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjarne Roß committed Jul 3, 2021
1 parent 986ec9a commit 3158ffa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
11 changes: 6 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ plugins {
id("com.github.johnrengelman.shadow").version("6.1.0")
}
group = "nfsprodriver"
version = "1.4"
version = "1.5"
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://oss.sonatype.org/content/repositories/central")
}
dependencies {
val kotlinVersion: String by System.getProperties()
implementation(kotlin("stdlib", kotlinVersion))
//https://papermc.io/javadocs/paper/1.16/overview-summary.html
compileOnly("com.destroystokyo.paper", "paper-api", "1.16.5-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT")
}
val autoRelocate by tasks.register<ConfigureShadowRelocation>("configureShadowRelocation", ConfigureShadowRelocation::class) {
target = tasks.getByName("shadowJar") as ShadowJar?
Expand All @@ -37,7 +38,7 @@ tasks {
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "16"
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kotlin.code.style=official
systemProp.kotlinVersion=1.4.30
systemProp.kotlinVersion=1.5.10
19 changes: 5 additions & 14 deletions src/main/kotlin/BeaconRange.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.block.Beacon
import org.bukkit.block.Block
import org.bukkit.block.BlockState
import org.bukkit.enchantments.Enchantment
import org.bukkit.entity.*
import org.bukkit.inventory.Inventory
import org.bukkit.plugin.java.JavaPlugin
Expand All @@ -14,7 +12,6 @@ import org.bukkit.potion.PotionEffectType
import org.bukkit.inventory.ShapedRecipe

import org.bukkit.inventory.ItemStack
import java.util.function.Predicate


class BeaconRange : JavaPlugin(){
Expand All @@ -34,16 +31,10 @@ class BeaconRange : JavaPlugin(){
remSSRecipe()
}

private fun generateConfig() {

}

private fun addSSRecipe() {
val superStar = ItemStack(Material.NETHER_STAR)
val ssMeta = superStar.itemMeta
ssMeta.setDisplayName("Super Star (enabled)")
superStar.setItemMeta(ssMeta)
superStar.lore = listOf("No effects")
superStar.itemMeta?.setDisplayName("Super Star (enabled)")
superStar.itemMeta?.lore = listOf("No effects")
val superStarRec = ShapedRecipe(NamespacedKey(this, "superStar"), superStar)
superStarRec.shape("SSS", "SSS", "SSS")
superStarRec.setIngredient('S', Material.NETHER_STAR)
Expand Down Expand Up @@ -110,7 +101,7 @@ class BeaconRange : JavaPlugin(){
beaconEffects.forEach { (beaconEffectType, beaconEffectAmp) ->
val inv: Inventory = player.inventory
val stars: List<ItemStack> = inv.contents.filter { itemStack -> itemStack?.itemMeta?.displayName?.contains("Super Star") == true }
if (stars.isEmpty() || stars.first().itemMeta.displayName.contains("enabled")) {
if (stars.isEmpty() || stars.first().itemMeta?.displayName?.contains("enabled") == true) {
val effect = PotionEffect(beaconEffectType, duration, minOf(beaconEffectAmp, config.getInt("maxAmp").minus(1)))
player.addPotionEffect(effect)
}
Expand Down Expand Up @@ -166,7 +157,7 @@ class BeaconRange : JavaPlugin(){
beaconEffects.forEach { beaconEffect ->
lore.add(beaconEffect.key.name+": "+beaconEffect.value.toString())
}
inv.itemInOffHand.lore = lore
inv.itemInOffHand.itemMeta?.lore = lore
}
}
}
Expand All @@ -180,7 +171,7 @@ class BeaconRange : JavaPlugin(){
val inv = player.inventory
val itemName: String? = inv.itemInOffHand.itemMeta?.displayName
if (itemName != null && itemName.contains("Super Star") && itemName.contains("enabled")) {
inv.itemInOffHand.lore?.forEach { starEffect ->
inv.itemInOffHand.itemMeta?.lore?.forEach { starEffect ->
val split: List<String> = starEffect.split(": ")
if (split.count() == 2) {
val effectType: PotionEffectType = PotionEffectType.getByName(split[0])!!
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/events/RightClick.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RightClick : Listener {
val itemName: String? = inv.itemInMainHand.itemMeta?.displayName
if (itemName != null) {
if(itemName.contains("Super Star")) {
val meta: ItemMeta = inv.itemInMainHand.itemMeta
val meta: ItemMeta = inv.itemInMainHand.itemMeta!!
if (itemName.contains("enabled")) {
meta.setDisplayName("Super Star (disabled)")
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
main: BeaconRange
name: BeaconRange
version: 1.4
api-version: "1.16"
version: 1.5
api-version: "1.17"
author: Bjarne Roß
description: Extend the range of your beacons!

0 comments on commit 3158ffa

Please sign in to comment.