Skip to content

Commit be7350d

Browse files
committed
Optimizations and bug fixes
1 parent 03151ad commit be7350d

File tree

6 files changed

+62
-56
lines changed

6 files changed

+62
-56
lines changed

Diff for: eco-api/build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ dependencies {
55
compileOnly 'com.github.Archy-X:AureliumSkills:Beta1.2.4'
66
}
77

8+
group 'com.willfp'
9+
version rootProject.version
10+
811
build.dependsOn publishToMavenLocal
912

1013
publishing {
1114
publications {
1215
maven(MavenPublication) {
1316
from(components.java)
17+
artifactId 'libreforge'
1418
}
1519
}
16-
}
20+
}

Diff for: eco-api/src/main/kotlin/com/willfp/libreforge/LibReforge.kt

+50-52
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import com.willfp.libreforge.triggers.Triggers
1313
import org.apache.commons.lang.StringUtils
1414
import org.bukkit.Bukkit
1515
import org.bukkit.entity.Player
16-
import org.bukkit.event.Listener
1716
import java.util.*
1817

1918
private val holderProviders = mutableSetOf<HolderProvider>()
@@ -129,73 +128,72 @@ fun Player.updateEffects() {
129128
}
130129
this.clearEffectCache()
131130

132-
LibReforge.plugin.scheduler.run {
133-
val after = this.getHolders()
134-
previousStates[this.uniqueId] = after
131+
val after = this.getHolders()
132+
previousStates[this.uniqueId] = after
135133

136-
val beforeFreq = ListUtils.listToFrequencyMap(before)
137-
val afterFreq = ListUtils.listToFrequencyMap(after.toList())
134+
val beforeFreq = ListUtils.listToFrequencyMap(before)
135+
val afterFreq = ListUtils.listToFrequencyMap(after.toList())
138136

139-
val added = mutableListOf<Holder>()
140-
val removed = mutableListOf<Holder>()
137+
val added = mutableListOf<Holder>()
138+
val removed = mutableListOf<Holder>()
141139

142-
for ((holder, freq) in afterFreq) {
143-
var amount = freq
144-
amount -= beforeFreq[holder] ?: 0
145-
if (amount < 1) {
146-
continue
147-
}
140+
for ((holder, freq) in afterFreq) {
141+
var amount = freq
142+
amount -= beforeFreq[holder] ?: 0
143+
if (amount < 1) {
144+
continue
145+
}
148146

149-
for (i in 0 until amount) {
150-
added.add(holder)
151-
}
147+
for (i in 0 until amount) {
148+
added.add(holder)
152149
}
150+
}
153151

154-
for ((holder, freq) in beforeFreq) {
155-
var amount = freq
152+
for ((holder, freq) in beforeFreq) {
153+
var amount = freq
156154

157-
amount -= afterFreq[holder] ?: 0
158-
if (amount < 1) {
159-
continue
160-
}
161-
for (i in 0 until amount) {
162-
removed.add(holder)
163-
}
155+
amount -= afterFreq[holder] ?: 0
156+
if (amount < 1) {
157+
continue
164158
}
159+
for (i in 0 until amount) {
160+
removed.add(holder)
161+
}
162+
}
165163

166-
for (holder in added) {
167-
var areConditionsMet = true
168-
for ((condition, config) in holder.conditions) {
169-
if (!condition.isConditionMet(this, config)) {
170-
areConditionsMet = false
171-
break
172-
}
164+
for (holder in added) {
165+
var areConditionsMet = true
166+
for ((condition, config) in holder.conditions) {
167+
if (!condition.isConditionMet(this, config)) {
168+
areConditionsMet = false
169+
break
173170
}
171+
}
174172

175-
if (areConditionsMet) {
176-
for ((effect, config) in holder.effects) {
177-
effect.enableForPlayer(this, config)
178-
}
173+
if (areConditionsMet) {
174+
for ((effect, config) in holder.effects) {
175+
effect.enableForPlayer(this, config)
179176
}
180177
}
181-
for (holder in removed) {
182-
for ((effect, _) in holder.effects) {
183-
effect.disableForPlayer(this)
184-
}
178+
}
179+
180+
for (holder in removed) {
181+
for ((effect, _) in holder.effects) {
182+
effect.disableForPlayer(this)
185183
}
184+
}
186185

187-
for (holder in after) {
188-
var areConditionsMet = true
189-
for ((condition, config) in holder.conditions) {
190-
if (!condition.isConditionMet(this, config)) {
191-
areConditionsMet = false
192-
break
193-
}
186+
for (holder in after) {
187+
var areConditionsMet = true
188+
for ((condition, config) in holder.conditions) {
189+
if (!condition.isConditionMet(this, config)) {
190+
areConditionsMet = false
191+
break
194192
}
195-
if (!areConditionsMet) {
196-
for ((effect, _) in holder.effects) {
197-
effect.disableForPlayer(this)
198-
}
193+
}
194+
if (!areConditionsMet) {
195+
for ((effect, _) in holder.effects) {
196+
effect.disableForPlayer(this)
199197
}
200198
}
201199
}

Diff for: eco-api/src/main/kotlin/com/willfp/libreforge/conditions/conditions/ConditionAboveY.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ConditionAboveY: Condition("above_y") {
1616
fun handle(event: PlayerMoveEvent) {
1717
val player = event.player
1818

19-
if (event.from.y == event.to.y) {
19+
if (event.from.blockY == event.to.blockY) {
2020
return
2121
}
2222

Diff for: eco-api/src/main/kotlin/com/willfp/libreforge/conditions/conditions/ConditionBelowY.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ConditionBelowY: Condition("below_y") {
1616
fun handle(event: PlayerMoveEvent) {
1717
val player = event.player
1818

19-
if (event.from.y == event.to.y) {
19+
if (event.from.blockY == event.to.blockY) {
2020
return
2121
}
2222

Diff for: eco-api/src/main/kotlin/com/willfp/libreforge/conditions/conditions/ConditionInAir.kt

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class ConditionInAir: Condition("in_air") {
1717
fun handle(event: PlayerMoveEvent) {
1818
val player = event.player
1919

20+
if (event.from.world?.getBlockAt(event.from)?.type == event.to.world?.getBlockAt(event.to)?.type) {
21+
return
22+
}
23+
2024
player.updateEffects()
2125
}
2226

Diff for: gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = 1.2.0
1+
version = 1.2.1
22
plugin-name = libreforge

0 commit comments

Comments
 (0)