mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2025-12-31 12:56:31 +00:00
Added commands support to Eye Of The Depth effect (command::ban %player%)
This commit is contained in:
@@ -5,9 +5,13 @@ import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.util.NumberUtils
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
import com.willfp.ecoskills.getEffectLevel
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.player.PlayerFishEvent
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class EffectEyeOfTheDepths: Effect(
|
||||
"eye_of_the_depths"
|
||||
@@ -38,13 +42,39 @@ class EffectEyeOfTheDepths: Effect(
|
||||
|
||||
val items = config.getStrings("rare-loot-items")
|
||||
|
||||
val itemName = items[NumberUtils.randInt(0, items.size - 1)]
|
||||
val reward = items[NumberUtils.randInt(0, items.size - 1)]
|
||||
|
||||
val item = Items.lookup(itemName).item
|
||||
|
||||
DropQueue(player)
|
||||
.setLocation(event.caught!!.location)
|
||||
.addItem(item)
|
||||
.push()
|
||||
LootReward.fromString(reward).reward(player, event.caught!!.location)
|
||||
}
|
||||
}
|
||||
|
||||
class LootReward(
|
||||
private val item: ItemStack? = null,
|
||||
private val command: String? = null
|
||||
)
|
||||
{
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromString(from: String): LootReward {
|
||||
return if (from.startsWith("command::", true)) {
|
||||
LootReward(command = from.replace("command::", "").replace("command:: ", ""))
|
||||
} else {
|
||||
LootReward(item = Items.lookup(from).item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun reward(player: Player, location: Location = player.location) {
|
||||
if (item != null) {
|
||||
DropQueue(player)
|
||||
.setLocation(location)
|
||||
.addItem(item)
|
||||
.push()
|
||||
}
|
||||
else {
|
||||
command?.let { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), it.replace("%player%", player.name)) }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ eye_of_the_depths:
|
||||
|
||||
# Disabled worlds
|
||||
disabled-in-worlds: []
|
||||
rare-loot-items:
|
||||
rare-loot-items: # Either an item from items lookup system, or a command (- command: say %player% is cool)
|
||||
- enchanted_book confusion:1
|
||||
- enchanted_book confusion:2
|
||||
- netherite_ingot
|
||||
|
||||
Reference in New Issue
Block a user