mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-04 15:41:36 +00:00
Added magnetic rod
This commit is contained in:
@@ -43,6 +43,7 @@ public class Effects {
|
||||
public static final Effect REIMBURSEMENT = new EffectReimbursement();
|
||||
public static final Effect OVERCOMPENSATION = new EffectOvercompensation();
|
||||
public static final Effect MASTER_LUMBERJACK = new EffectMasterLumberjack();
|
||||
public static final Effect MAGNETIC_ROD = new EffectMagneticRod();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void registerNewEffect(@NotNull final Effect effect) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
import com.willfp.ecoskills.getEffectLevel
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.player.PlayerFishEvent
|
||||
|
||||
class EffectMagneticRod : Effect(
|
||||
"magnetic_rod"
|
||||
) {
|
||||
override fun formatDescription(string: String, level: Int): String {
|
||||
return string.replace("%percentage%", (level * config.getDouble("speed-per-level")).toString())
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
fun handle(event: PlayerFishEvent) {
|
||||
if (!(event.state == PlayerFishEvent.State.CAUGHT_FISH || event.state == PlayerFishEvent.State.CAUGHT_ENTITY)) {
|
||||
return
|
||||
}
|
||||
|
||||
val player = event.player
|
||||
|
||||
val level = player.getEffectLevel(this)
|
||||
|
||||
if (level == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
val vector = player.eyeLocation.toVector()
|
||||
.clone()
|
||||
.subtract(event.caught?.location?.toVector() ?: return)
|
||||
.normalize()
|
||||
|
||||
val add = config.getDouble("speed-per-level") * level / 100
|
||||
|
||||
val result = vector.multiply(1 + add)
|
||||
|
||||
plugin.scheduler.run {
|
||||
event.caught?.velocity = result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,4 +216,9 @@ master_lumberjack:
|
||||
# Chance is as a percentage; if the chance for a player is over 100 then it will always be double drops
|
||||
# with a chance to get triple drops. Same goes if above 200, but then it will always be triple with a chance
|
||||
# for quadruple.
|
||||
chance-per-level: 6
|
||||
chance-per-level: 6
|
||||
magnetic_rod:
|
||||
description: "&8Increases fishing speed by &a%percentage%%"
|
||||
|
||||
# Speed is as a percentage.
|
||||
speed-per-level: 5
|
||||
Reference in New Issue
Block a user