mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-03 06:12:21 +00:00
Continued backend
This commit is contained in:
@@ -5,6 +5,8 @@ import com.willfp.eco.core.command.impl.PluginCommand;
|
||||
import com.willfp.ecoskills.commands.CommandEcoskills;
|
||||
import com.willfp.ecoskills.effects.Effect;
|
||||
import com.willfp.ecoskills.effects.Effects;
|
||||
import com.willfp.ecoskills.stats.Stat;
|
||||
import com.willfp.ecoskills.stats.Stats;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -30,6 +32,10 @@ public class EcoSkillsPlugin extends EcoPlugin {
|
||||
this.getEventManager().unregisterListener(effect);
|
||||
this.getEventManager().registerListener(effect);
|
||||
}
|
||||
for (Stat stat : Stats.values()) {
|
||||
this.getEventManager().unregisterListener(stat);
|
||||
this.getEventManager().registerListener(stat);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,15 @@ package com.willfp.ecoskills.effects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.willfp.eco.core.config.updating.ConfigUpdater;
|
||||
import com.willfp.ecoskills.EcoSkillsPlugin;
|
||||
import com.willfp.ecoskills.skills.Skill;
|
||||
import com.willfp.ecoskills.effects.effects.EffectBountifulHarvest;
|
||||
import com.willfp.ecoskills.effects.effects.EffectCraftsmanship;
|
||||
import com.willfp.ecoskills.effects.effects.EffectEyeOfTheDepths;
|
||||
import com.willfp.ecoskills.effects.effects.EffectPotionmaster;
|
||||
import com.willfp.ecoskills.effects.effects.EffectSeamlessMovement;
|
||||
import com.willfp.ecoskills.effects.effects.EffectSecondChance;
|
||||
import com.willfp.ecoskills.effects.effects.EffectSerratedStrikes;
|
||||
import com.willfp.ecoskills.effects.effects.EffectShamanism;
|
||||
import com.willfp.ecoskills.effects.effects.EffectVersatileTools;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -24,15 +32,15 @@ public class Effects {
|
||||
*/
|
||||
private static final EcoSkillsPlugin PLUGIN = EcoSkillsPlugin.getInstance();
|
||||
|
||||
public static final Skill MINING = new Skill(PLUGIN, "mining");
|
||||
public static final Skill COMBAT = new Skill(PLUGIN, "combat");
|
||||
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");
|
||||
public static final Skill ALCHEMY = new Skill(PLUGIN, "alchemy");
|
||||
public static final Skill ARMORY = new Skill(PLUGIN, "armory");
|
||||
public static final Skill EXPLORATION = new Skill(PLUGIN, "exploration");
|
||||
public static final Effect BOUNTIFUL_HARVEST = new EffectBountifulHarvest();
|
||||
public static final Effect CRAFTSMANSHIP = new EffectCraftsmanship();
|
||||
public static final Effect EYE_OF_THE_DEPTHS = new EffectEyeOfTheDepths();
|
||||
public static final Effect POTIONMASTER = new EffectPotionmaster();
|
||||
public static final Effect SEAMLESS_MOVEMENT = new EffectSeamlessMovement();
|
||||
public static final Effect SECOND_CHANCE = new EffectSecondChance();
|
||||
public static final Effect SERRATED_STRIKES = new EffectSerratedStrikes();
|
||||
public static final Effect SHAMANISM = new EffectShamanism();
|
||||
public static final Effect VERSATILE_TOOLS = new EffectVersatileTools();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void registerNewEffect(@NotNull final Effect effect) {
|
||||
|
||||
@@ -19,4 +19,13 @@ fun Player.getEffectLevel(effect: Effect): Int {
|
||||
|
||||
fun Player.setEffectLevel(effect: Effect, level: Int) {
|
||||
this.persistentDataContainer.set(effect.key, PersistentDataType.INTEGER, level)
|
||||
}
|
||||
|
||||
fun Player.getStatLevel(stat: Stat): Int {
|
||||
return this.persistentDataContainer.getOrDefault(stat.key, PersistentDataType.INTEGER, 1)
|
||||
}
|
||||
|
||||
fun Player.setStatLevel(stat: Stat, level: Int) {
|
||||
this.persistentDataContainer.set(stat.key, PersistentDataType.INTEGER, level)
|
||||
stat.updateStatLevel(this)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.ecoskills.effects
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.ecoskills.EcoSkillsPlugin
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.event.Listener
|
||||
@@ -13,6 +14,7 @@ abstract class Effect(
|
||||
|
||||
val key: NamespacedKey
|
||||
val uuid: UUID
|
||||
val config: Config
|
||||
lateinit var name: String
|
||||
lateinit var description: String
|
||||
|
||||
@@ -20,6 +22,7 @@ abstract class Effect(
|
||||
update()
|
||||
key = plugin.namespacedKeyFactory.create(id)
|
||||
uuid = UUID.nameUUIDFromBytes(id.toByteArray())
|
||||
config = plugin.configYml.getSubsection("effects.$id")
|
||||
|
||||
Effects.registerNewEffect(this)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectBountifulHarvest: Effect(
|
||||
"bountiful_harvest"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectCraftsmanship: Effect(
|
||||
"craftsmanship"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectEyeOfTheDepths: Effect(
|
||||
"eye_of_the_depths"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectPotionmaster: Effect(
|
||||
"potionmaster"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectSeamlessMovement: Effect(
|
||||
"seamless_movement"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectSecondChance: Effect(
|
||||
"second_chance"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectSerratedStrikes: Effect(
|
||||
"serrated_strikes"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectShamanism: Effect(
|
||||
"shamanism"
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
|
||||
class EffectVersatileTools: Effect(
|
||||
"versatile_tools"
|
||||
) {
|
||||
}
|
||||
@@ -1,23 +1,28 @@
|
||||
package com.willfp.ecoskills.skills
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.ecoskills.EcoSkillsPlugin
|
||||
import org.bukkit.NamespacedKey
|
||||
import java.util.*
|
||||
|
||||
class Skill(
|
||||
protected val plugin: EcoPlugin,
|
||||
val id: String
|
||||
) {
|
||||
protected val plugin: EcoPlugin = EcoSkillsPlugin.getInstance()
|
||||
|
||||
val key: NamespacedKey
|
||||
val uuid: UUID
|
||||
lateinit var name: String
|
||||
|
||||
init {
|
||||
update()
|
||||
key = plugin.namespacedKeyFactory.create(id)
|
||||
uuid = UUID.nameUUIDFromBytes(id.toByteArray())
|
||||
|
||||
Skills.registerNewSkill(this)
|
||||
}
|
||||
|
||||
fun update() {
|
||||
name = plugin.langYml.getString("skills.names.$id")
|
||||
name = plugin.langYml.getString("skills.$id.name")
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.willfp.ecoskills.stats
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.ecoskills.EcoSkillsPlugin
|
||||
import com.willfp.ecoskills.skills.Skills
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.Listener
|
||||
import java.util.*
|
||||
|
||||
class Stat(
|
||||
protected val plugin: EcoPlugin,
|
||||
abstract class Stat(
|
||||
val id: String
|
||||
) {
|
||||
) : Listener {
|
||||
protected val plugin: EcoPlugin = EcoSkillsPlugin.getInstance()
|
||||
|
||||
val key: NamespacedKey
|
||||
val uuid: UUID
|
||||
val config: Config
|
||||
lateinit var icon: String
|
||||
lateinit var color: String
|
||||
lateinit var name: String
|
||||
@@ -16,13 +24,19 @@ class Stat(
|
||||
init {
|
||||
update()
|
||||
key = plugin.namespacedKeyFactory.create(id)
|
||||
uuid = UUID.nameUUIDFromBytes(id.toByteArray())
|
||||
config = plugin.configYml.getSubsection("stats.$id")
|
||||
|
||||
Stats.registerNewStat(this)
|
||||
}
|
||||
|
||||
fun update() {
|
||||
icon = plugin.langYml.getString("stats.icons.$id")
|
||||
name = plugin.langYml.getString("stats.names.$id")
|
||||
color = plugin.langYml.getString("stats.colors.$id")
|
||||
icon = plugin.langYml.getString("stats.$id.icon")
|
||||
name = plugin.langYml.getString("stats.$id.name")
|
||||
color = plugin.langYml.getString("stats.$id.color")
|
||||
}
|
||||
|
||||
open fun updateStatLevel(player: Player) {
|
||||
// Override when needed.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.willfp.ecoskills.stats.stats
|
||||
|
||||
import com.willfp.ecoskills.getStatLevel
|
||||
import com.willfp.ecoskills.stats.Stat
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.entity.EntityDamageEvent
|
||||
|
||||
class StatDefense() : Stat(
|
||||
"defense"
|
||||
) {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
fun handle(event: EntityDamageEvent) {
|
||||
if (event.entity !is Player) {
|
||||
return
|
||||
}
|
||||
|
||||
val player = event.entity as Player
|
||||
|
||||
var multiplier = this.config.getDouble("percent-less-damage-per-level") * player.getStatLevel(this)
|
||||
multiplier /= 100
|
||||
multiplier += 1
|
||||
|
||||
event.damage = (event.damage) / multiplier
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.willfp.ecoskills.stats.stats
|
||||
|
||||
import com.willfp.ecoskills.getStatLevel
|
||||
import com.willfp.ecoskills.stats.Stat
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.Projectile
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
|
||||
class StatStrength() : Stat(
|
||||
"defense"
|
||||
) {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
fun handle(event: EntityDamageByEntityEvent) {
|
||||
var player = event.damager
|
||||
|
||||
if (player is Projectile) {
|
||||
if (player.shooter !is Player) {
|
||||
return
|
||||
} else {
|
||||
player = player.shooter as Player
|
||||
}
|
||||
}
|
||||
|
||||
if (player !is Player) {
|
||||
return
|
||||
}
|
||||
|
||||
var multiplier = this.config.getDouble("percent-more-damage-per-level") * player.getStatLevel(this)
|
||||
multiplier /= 100
|
||||
multiplier += 1
|
||||
|
||||
event.damage = (event.damage) * multiplier
|
||||
}
|
||||
}
|
||||
@@ -3,3 +3,83 @@
|
||||
# by Auxilor
|
||||
#
|
||||
|
||||
stats:
|
||||
defense:
|
||||
# 100% halves the incoming damage
|
||||
percent-less-damage-per-level: 1
|
||||
strength:
|
||||
# 100% is double damage
|
||||
percent-more-damage-per-level: 1
|
||||
crit_chance:
|
||||
# Nothing happens above 100%, 200% is the same as it.
|
||||
chance-per-level: 1
|
||||
crit_damage:
|
||||
# The percent more damage to deal on crits for each level.
|
||||
percent-more-damage-per-level: 2
|
||||
# The amount more damage to deal on crits by default.
|
||||
base-percent-more: 50
|
||||
speed:
|
||||
# The percent more speed to give for the speed attribute (internal in the game)
|
||||
# for each level
|
||||
percent-faster-per-level: 1
|
||||
wisdom:
|
||||
# The percent more xp to gain from orbs for each level of the stat.
|
||||
percent-more-xp-gain: 1
|
||||
|
||||
effects:
|
||||
bountiful_harvest:
|
||||
# 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: 1
|
||||
versatile_tools:
|
||||
# The percent (%) more damage to deal with a pickaxe for each level of the effect.
|
||||
percent-more-per-level: 2
|
||||
eye_of_the_depths:
|
||||
# Chance is as a percentage.
|
||||
chance-per-level: 0.1
|
||||
# The rare loot items are listed below.
|
||||
# You can import drops from the following plugins:
|
||||
# EcoArmor, EcoItems, Talismans, StatTrackers, EcoWeapons, Reforges, Oraxen
|
||||
# You can also use vanilla items with their material
|
||||
# You can set enchantments on items with the following syntax:
|
||||
# <item> <enchantment:level> <enchantment:level> etc
|
||||
# For example, a reaper scythe with Razor 4 and Criticals 3 would be:
|
||||
# ecoweapons:reaper_scythe razor:4 criticals:3
|
||||
rare-loot-items:
|
||||
- enchanted_book confusion:1
|
||||
- enchanted_book confusion:2
|
||||
- netherite_ingot
|
||||
- ecoarmor:set_miner_helmet
|
||||
- ecoarmor:set_miner_chestplate
|
||||
- ecoarmor:set_miner_leggings
|
||||
- ecoarmor:set_miner_boots
|
||||
- reforges:dynamic
|
||||
serrated_strikes:
|
||||
# Chance is as a percentage.
|
||||
chance-per-level: 2
|
||||
# The damage to deal for each 'bleed tick'
|
||||
bleed-tick-damage: 2
|
||||
# The amount of ticks to wait between each bleed tick
|
||||
bleed-tick-spacing: 15
|
||||
# The amount of bleed ticks to give
|
||||
bleed-ticks: 4
|
||||
seamless_movement:
|
||||
# The chance to ignore fall damage, as a percentage
|
||||
chance-per-level: 2
|
||||
potionmaster:
|
||||
# The percent more time for potions to last for each level of the effect
|
||||
percent-more-per-level: 4
|
||||
shamanism:
|
||||
# The percent faster regen for each level of the effect
|
||||
percent-faster-per-level: 4
|
||||
craftsmanship:
|
||||
# 100% is double durability
|
||||
percent-less-per-level: 3
|
||||
second_chance:
|
||||
# Items will try to heal every time durability damage is taken below this level
|
||||
below-durability-check: 30
|
||||
# Chance per level as a percentage
|
||||
# This will follow a binomial distribution where the amount of trials is the durability check (30 by default, see above)
|
||||
# Since this chance will be called many times, it would be best to have this be low.
|
||||
chance-per-level: 0.1
|
||||
@@ -7,39 +7,50 @@ messages:
|
||||
|
||||
skills:
|
||||
color: "&9"
|
||||
names:
|
||||
mining: "Mining"
|
||||
combat: "Combat"
|
||||
enchanting: "Enchanting"
|
||||
farming: "Farming"
|
||||
woodcutting: "Woodcutting"
|
||||
fishing: "Fishing"
|
||||
alchemy: "Alchemy"
|
||||
armory: "Armory"
|
||||
exploration: "Exploration"
|
||||
mining:
|
||||
name: "Mining"
|
||||
combat:
|
||||
name: "Combat"
|
||||
enchanting:
|
||||
name: "Enchanting"
|
||||
farming:
|
||||
name: "Farming"
|
||||
woodcutting:
|
||||
name: "Woodcutting"
|
||||
fishing:
|
||||
name: "Fishing"
|
||||
alchemy:
|
||||
name: "Alchemy"
|
||||
armory:
|
||||
name: "Armory"
|
||||
exploration:
|
||||
name: "Exploration"
|
||||
|
||||
stats:
|
||||
names:
|
||||
defense: "Defense"
|
||||
strength: "Strength"
|
||||
crit_chance: "Crit Chance"
|
||||
crit_damage: "Crit Damage"
|
||||
speed: "Speed"
|
||||
wisdom: "Wisdom"
|
||||
colors:
|
||||
defense: '&#e884b0'
|
||||
strength: '&#db0000'
|
||||
crit_chance: '&#f7ff85'
|
||||
crit_damage: '�d9e'
|
||||
speed: '(ffe6'
|
||||
wisdom: '&#c8ffa6'
|
||||
icons:
|
||||
defense: '&#e884b0❤'
|
||||
strength: '&#db0000❁'
|
||||
crit_chance: '&#f7ff85☣'
|
||||
crit_damage: '�d9e☠'
|
||||
speed: '(ffe6✦'
|
||||
wisdom: '&#c8ffa6✎'
|
||||
defense:
|
||||
name: "Defense"
|
||||
color: '&#e884b0'
|
||||
icon: '&#e884b0❤'
|
||||
strength:
|
||||
name: "Strength"
|
||||
color: '&#db0000'
|
||||
icon: '&#db0000❁'
|
||||
crit_chance:
|
||||
name: "Crit Chance"
|
||||
color: '&#f7ff85'
|
||||
icon: '&#f7ff85☣'
|
||||
crit_damage:
|
||||
name: "Crit Damage"
|
||||
color: '�d9e'
|
||||
icon: '�d9e☠'
|
||||
speed:
|
||||
name: "Speed"
|
||||
color: '(ffe6'
|
||||
icon: '(ffe6✦'
|
||||
wisdom:
|
||||
name: "Wisdom"
|
||||
color: '&#c8ffa6'
|
||||
icon: '&#c8ffa6✎'
|
||||
|
||||
effects:
|
||||
bountiful_harvest:
|
||||
@@ -63,8 +74,8 @@ effects:
|
||||
shamanism:
|
||||
name: "Shamanism"
|
||||
description: "Increases the speed at which you regain health"
|
||||
craftmanship:
|
||||
name: "Craftmanship"
|
||||
craftsmanship:
|
||||
name: "Craftsmanship"
|
||||
description: "Take less durability damage on axes"
|
||||
second_chance:
|
||||
name: "Second Chance"
|
||||
|
||||
Reference in New Issue
Block a user