mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-03 06:12:21 +00:00
Added enchanting
This commit is contained in:
@@ -3,6 +3,7 @@ package com.willfp.ecoskills.skills;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.willfp.eco.core.config.updating.ConfigUpdater;
|
||||
import com.willfp.ecoskills.skills.skills.SkillCombat;
|
||||
import com.willfp.ecoskills.skills.skills.SkillEnchanting;
|
||||
import com.willfp.ecoskills.skills.skills.SkillMining;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -21,8 +22,8 @@ public class Skills {
|
||||
|
||||
public static final Skill MINING = new SkillMining();
|
||||
public static final Skill COMBAT = new SkillCombat();
|
||||
public static final Skill ENCHANTING = new SkillEnchanting();
|
||||
/*
|
||||
public static final Skill ENCHANTING = new Skill(PLUGIN, "enchanting");
|
||||
public static final Skill FARMING = new Skill(PLUGIN, "farming");
|
||||
public static final Skill WOODCUTTING = new Skill(PLUGIN, "woodcutting");
|
||||
public static final Skill FISHING = new Skill(PLUGIN, "fishing");
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.entity.Player
|
||||
import org.bukkit.persistence.PersistentDataType
|
||||
|
||||
fun Player.getSkillLevel(skill: Skill): Int {
|
||||
return this.persistentDataContainer.getOrDefault(skill.key, PersistentDataType.INTEGER, 1)
|
||||
return this.persistentDataContainer.getOrDefault(skill.key, PersistentDataType.INTEGER, 0)
|
||||
}
|
||||
|
||||
fun Player.setSkillLevel(skill: Skill, level: Int) {
|
||||
@@ -23,7 +23,7 @@ fun Player.setSkillProgress(skill: Skill, level: Double) {
|
||||
}
|
||||
|
||||
fun Player.getEffectLevel(effect: Effect): Int {
|
||||
return this.persistentDataContainer.getOrDefault(effect.key, PersistentDataType.INTEGER, 1)
|
||||
return this.persistentDataContainer.getOrDefault(effect.key, PersistentDataType.INTEGER, 0)
|
||||
}
|
||||
|
||||
fun Player.setEffectLevel(effect: Effect, level: Int) {
|
||||
@@ -31,7 +31,7 @@ fun Player.setEffectLevel(effect: Effect, level: Int) {
|
||||
}
|
||||
|
||||
fun Player.getStatLevel(stat: Stat): Int {
|
||||
return this.persistentDataContainer.getOrDefault(stat.key, PersistentDataType.INTEGER, 1)
|
||||
return this.persistentDataContainer.getOrDefault(stat.key, PersistentDataType.INTEGER, 0)
|
||||
}
|
||||
|
||||
fun Player.setStatLevel(stat: Stat, level: Int) {
|
||||
|
||||
@@ -17,24 +17,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
import java.util.*
|
||||
|
||||
class SkillCombat : Skill(
|
||||
"mining"
|
||||
"combat"
|
||||
) {
|
||||
private val rewards: MutableMap<Material, Double>
|
||||
|
||||
init {
|
||||
rewards = EnumMap(org.bukkit.Material::class.java)
|
||||
}
|
||||
|
||||
override fun postUpdate() {
|
||||
rewards.clear()
|
||||
for (string in this.config.getStrings("xp-rewards", false)) {
|
||||
val split = string.split(":")
|
||||
val material = Material.getMaterial(split[0].uppercase()) ?: continue
|
||||
rewards[material] = split[1].toDouble()
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
fun handleLevelling(event: EntityDeathByEntityEvent) {
|
||||
var player = event.killer
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.willfp.ecoskills.skills.skills
|
||||
|
||||
import com.willfp.eco.core.events.EntityDeathByEntityEvent
|
||||
import com.willfp.ecoskills.api.PlayerSkillExpGainEvent
|
||||
import com.willfp.ecoskills.getStatLevel
|
||||
import com.willfp.ecoskills.skills.Skill
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.attribute.Attribute
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.Projectile
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.block.BlockBreakEvent
|
||||
import org.bukkit.event.enchantment.EnchantItemEvent
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
import java.util.*
|
||||
|
||||
class SkillEnchanting : Skill(
|
||||
"enchanting"
|
||||
) {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
fun handleLevelling(event: EnchantItemEvent) {
|
||||
val player = event.enchanter
|
||||
val cost = event.expLevelCost
|
||||
|
||||
val xp = cost * this.config.getDouble("xp-per-level")
|
||||
val gainEvent = PlayerSkillExpGainEvent(player, this, xp)
|
||||
Bukkit.getPluginManager().callEvent(gainEvent)
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ gui:
|
||||
row: 1
|
||||
column: 5
|
||||
|
||||
name: "&f%player%'s Stats:"
|
||||
name: "&f%player%'s &fStats:"
|
||||
lore:
|
||||
- "&f"
|
||||
- " %ecoskills_defense_name%&f %ecoskills_defense%"
|
||||
@@ -186,7 +186,7 @@ skills:
|
||||
# The maximum obtainable level
|
||||
max-level: 50
|
||||
|
||||
# The experience to give for each heart of a killed enemy
|
||||
# The experience to give for each hp of a killed enemy
|
||||
xp-per-heart: 0.33
|
||||
|
||||
# The level/skill increases to give on levelup
|
||||
@@ -198,7 +198,7 @@ skills:
|
||||
rewards-messages:
|
||||
- " &f+1 %ecoskills_crit_damage_name%"
|
||||
- " &f+2 %ecoskills_strength_name%"
|
||||
- " &6Versatile Tools %ecoskills_serrated_strikes_numeral%"
|
||||
- " &6Serrated Strikes %ecoskills_serrated_strikes_numeral%"
|
||||
enchanting:
|
||||
gui-item: enchanting_table
|
||||
gui-position:
|
||||
@@ -207,6 +207,20 @@ skills:
|
||||
|
||||
# The maximum obtainable level
|
||||
max-level: 50
|
||||
|
||||
# The experience to give for each level cost of enchanting
|
||||
xp-per-level: 4
|
||||
|
||||
# The level/skill increases to give on levelup
|
||||
level-up-rewards:
|
||||
- "wisdom:2"
|
||||
- "crit_chance:1"
|
||||
- "second_chance:1"
|
||||
|
||||
rewards-messages:
|
||||
- " &f+2 %ecoskills_wisdom_name%"
|
||||
- " &f+1 %ecoskills_crit_chance_name%"
|
||||
- " &6Second Chance %ecoskills_second_chance_numeral%"
|
||||
farming:
|
||||
gui-position:
|
||||
row: 3
|
||||
|
||||
Reference in New Issue
Block a user