Skip to content

Commit 27cccd9

Browse files
committed
Fix Weeping Vine check crashing versions <1.16, restructure server version info in constants, bump version
1 parent 04efc16 commit 27cccd9

File tree

9 files changed

+33
-35
lines changed

9 files changed

+33
-35
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Peter DeVita
3+
Copyright (c) 2020-2021 Peter DeVita
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CreeperHeal2 (v1.3.0) (1.13-1.16)
1+
# CreeperHeal2 (v1.3.1) (1.13-1.16)
22

33
[Spigot Plugin Page](https://www.spigotmc.org/resources/creeperheal2.80585/)
44

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.pdevita</groupId>
88
<artifactId>CreeperHeal2</artifactId>
9-
<version>1.3.0-SNAPSHOT</version>
9+
<version>1.3.1-SNAPSHOT</version>
1010

1111
<properties>
1212
<kotlin.version>1.4.30</kotlin.version>

src/main/kotlin/net/pdevita/creeperheal2/constants/ConstantsManager.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@ import org.bukkit.Material
55

66

77
class ConstantsManager {
8-
val gravityBlocks: HashSet<Material>
9-
val dependentBlocks: DependentBlocks
10-
val multiBlocks: MultiBlocks
11-
private val versionList = ArrayList<Int>()
8+
val version: Pair<Int, Int> = getServerVersion()
9+
val gravityBlocks: HashSet<Material> = GravityBlocks().getBlocks(version)
10+
val dependentBlocks: DependentBlocks = DependentBlocks(version)
11+
val multiBlocks: MultiBlocks = MultiBlocks(version)
1212

13-
init {
14-
// Version extracting test, just here for convenience/testing
13+
private fun getServerVersion(): Pair<Int, Int> {
1514
var version = Bukkit.getBukkitVersion()
1615
version = version.substringBefore("-")
1716
val splitVersion = version.split(".")
18-
versionList.addAll(listOf(splitVersion[0].toInt(), splitVersion[1].toInt()))
19-
gravityBlocks = GravityBlocks().getBlocks(versionList)
20-
dependentBlocks = DependentBlocks(versionList)
21-
multiBlocks = MultiBlocks(versionList)
17+
return Pair(splitVersion[0].toInt(), splitVersion[1].toInt())
2218
}
2319
}

src/main/kotlin/net/pdevita/creeperheal2/constants/DependentBlocks.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ import java.util.*
66

77
// List of blocks that need to be attached to a block in this version of MC
88

9-
class DependentBlocks(version: ArrayList<Int>) {
9+
class DependentBlocks(version: Pair<Int, Int>) {
1010
val sideBlocks: EnumMap<Material, FindDependentBlock> = EnumMap(Material::class.java)
1111

1212
init {
13-
if (version[1] >= 13) {
14-
this.getVersionBlocks(version[1], 13, Blocks13())
13+
if (version.second >= 13) {
14+
this.getVersionBlocks(version.second, 13, Blocks13())
1515
}
16-
if (version[1] >= 14) {
17-
this.getVersionBlocks(version[1], 14, Blocks14())
16+
if (version.second >= 14) {
17+
this.getVersionBlocks(version.second, 14, Blocks14())
1818
}
19-
if (version[1] >= 15) {
20-
this.getVersionBlocks(version[1], 15, Blocks15())
19+
if (version.second >= 15) {
20+
this.getVersionBlocks(version.second, 15, Blocks15())
2121
}
22-
if (version[1] >= 16) {
23-
this.getVersionBlocks(version[1], 16, Blocks16())
22+
if (version.second >= 16) {
23+
this.getVersionBlocks(version.second, 16, Blocks16())
2424
}
2525
}
2626

src/main/kotlin/net/pdevita/creeperheal2/constants/GravityBlocks.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ class GravityBlocks {
2424
Material.YELLOW_CONCRETE_POWDER
2525
))
2626

27-
fun getBlocks(version: ArrayList<Int>): HashSet<Material> {
27+
fun getBlocks(version: Pair<Int, Int>): HashSet<Material> {
2828
val materials = HashSet<Material>()
29-
if (version[1] >= 13) {
29+
if (version.second >= 13) {
3030
materials.addAll(GBlocks13().blocks)
3131
materials.addAll(concrete)
3232
}
33-
if (version[1] >= 14) {
33+
if (version.second >= 14) {
3434
materials.addAll(GBlocks14().blocks)
3535
}
36-
if (version[1] >= 15) {
36+
if (version.second >= 15) {
3737
materials.addAll(GBlocks15().blocks)
3838
}
3939
return materials

src/main/kotlin/net/pdevita/creeperheal2/constants/MultiBlocks.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import net.pdevita.creeperheal2.utils.FindDependentBlock
66
import org.bukkit.Material
77
import java.util.*
88

9-
class MultiBlocks(version: ArrayList<Int>) {
9+
class MultiBlocks(version: Pair<Int, Int>) {
1010
val blocks: EnumMap<Material, FindDependentBlock> = EnumMap(Material::class.java)
1111

1212
init {
13-
if (version[1] >= 13) {
14-
this.getVersionBlocks(version[1], 13, MBlocks13())
13+
if (version.second >= 13) {
14+
this.getVersionBlocks(version.second, 13, MBlocks13())
1515
}
16-
if (version[1] >= 16) {
17-
this.getVersionBlocks(version[1], 16, MBlocks16())
16+
if (version.second >= 16) {
17+
this.getVersionBlocks(version.second, 16, MBlocks16())
1818
}
1919
}
2020

src/main/kotlin/net/pdevita/creeperheal2/core/Explosion.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,11 @@ class Explosion() {
389389
// Post-processing on block list
390390
this@Explosion.postProcessTask = async(Dispatchers.async) {
391391
// Fix Weeping Vine plants being weird
392-
for (block in totalBlockList) {
393-
if (block.state.type == Material.WEEPING_VINES_PLANT) {
394-
block.state.type = Material.WEEPING_VINES
392+
if (plugin.constants.version.second >= 16) {
393+
for (block in totalBlockList) {
394+
if (block.state.type == Material.WEEPING_VINES_PLANT) {
395+
block.state.type = Material.WEEPING_VINES
396+
}
395397
}
396398
}
397399
// If TNT exploding is on, remove the TNT and dump it's dependents back into the tree

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CreeperHeal2
22
main: net.pdevita.creeperheal2.CreeperHeal2
3-
version: 1.3.0
3+
version: 1.3.1
44
api-version: 1.13
55
author: pmdevita
66

0 commit comments

Comments
 (0)