Merge branch 'Auxilor:master' into master

This commit is contained in:
Sedri05 2022-08-30 21:34:30 +02:00 committed by GitHub
commit d3b8806a82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 291 additions and 186 deletions

View File

@ -11,6 +11,7 @@ import com.willfp.ecoenchants.config.TypesYml
import com.willfp.ecoenchants.config.VanillaEnchantsYml
import com.willfp.ecoenchants.display.EnchantDisplay
import com.willfp.ecoenchants.enchants.EcoEnchants
import com.willfp.ecoenchants.enchants.LoreConversion
import com.willfp.ecoenchants.enchants.impl.EnchantmentTelekinesis
import com.willfp.ecoenchants.enchants.registerVanillaEnchants
import com.willfp.ecoenchants.integrations.EnchantRegistrations
@ -33,6 +34,7 @@ class EcoEnchantsPlugin : LibReforgePlugin() {
init {
instance = this
EcoEnchants.update(this)
}
override fun handleEnableAdditional() {
@ -54,7 +56,8 @@ class EcoEnchantsPlugin : LibReforgePlugin() {
VillagerSupport(this),
EnchantingTableSupport(this),
LootSupport(this),
AnvilSupport(this)
AnvilSupport(this),
LoreConversion(this)
)
}

View File

@ -0,0 +1,116 @@
package com.willfp.ecoenchants.enchants
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.fast.fast
import com.willfp.eco.util.NumberUtils
import org.bukkit.ChatColor
import org.bukkit.enchantments.Enchantment
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.inventory.InventoryOpenEvent
import org.bukkit.event.player.PlayerItemHeldEvent
import org.bukkit.inventory.BlockInventoryHolder
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.EnchantmentStorageMeta
class LoreConversion(
private val plugin: EcoPlugin
) : Listener {
@EventHandler
fun loreConverter(event: PlayerItemHeldEvent) {
if (!plugin.configYml.getBool("lore-conversion.enabled")) {
return
}
convertLore(event.player.inventory.getItem(event.newSlot))
}
@EventHandler
fun aggressiveLoreConverter(event: InventoryOpenEvent) {
if (!plugin.configYml.getBool("lore-conversion.enabled")) {
return
}
if (!plugin.configYml.getBool("lore-conversion.aggressive")) {
return
}
val inventory = event.inventory
if (inventory.holder !is BlockInventoryHolder) {
return
}
for (itemStack in inventory.contents) {
convertLore(itemStack)
}
}
private fun convertLore(itemStack: ItemStack?) {
if (itemStack == null) {
return
}
val meta = itemStack.itemMeta ?: return
val toAdd = mutableMapOf<Enchantment, Int>()
val lore = itemStack.fast().lore.toMutableList()
for (line in lore.toList()) {
val uncolored = ChatColor.stripColor(line) ?: continue
var enchant: EcoEnchant?
var level: Int
val split = uncolored.split(" ").toMutableList()
if (split.isEmpty()) {
continue
}
if (split.size == 1) {
enchant = EcoEnchants.getByName(split[0])
level = 1
} else {
val attemptFullLine = EcoEnchants.getByName(line)
if (attemptFullLine != null) {
enchant = attemptFullLine
level = 1
} else {
var levelString = split.last()
split.remove(levelString)
levelString = levelString.trim { it <= ' ' }
level = try {
NumberUtils.fromNumeral(levelString)
} catch (e: IllegalArgumentException) {
continue
}
val enchantName = split.joinToString(" ")
enchant = EcoEnchants.getByName(enchantName)
}
}
if (enchant == null) {
continue
}
toAdd[enchant] = level
}
if (meta is EnchantmentStorageMeta) {
lore.clear()
for ((enchant, level) in toAdd) {
meta.addStoredEnchant(enchant, level, true)
}
} else {
lore.clear()
for ((enchant, level) in toAdd) {
meta.addEnchant(enchant, level, true)
}
}
itemStack.itemMeta = meta
itemStack.fast().lore = lore
}
}

View File

@ -95,6 +95,13 @@ enchantinfo:
- "&fApplicable to: &a%targets%"
- "&fConflicts with: &a%conflicts%"
# Options for converting lore-based enchants (from other plugins) with EcoEnchants enchantments
# with the same names. If you're switching over from another plugin and don't want your players to
# lose their enchantments, just switch this on.
lore-conversion:
enabled: false # If lore conversion should be enabled
aggressive: false # Will convert all items in all inventories when opened, likely to use a lot of performance
cooldown:
in-actionbar: true
sound:

View File

@ -1,10 +1,10 @@
display-name: Abattoir
description: Tridents deal %placeholder%% more damage against passive mobs
placeholder: '30 * %level%)'
display-name: "Abattoir"
description: "Tridents deal &a%placeholder%% &8more damage against passive mobs"
placeholder: "30 * %level%"
type: normal
targets:
- trident
- trident
conflicts:
- serrated
- bladed
@ -22,7 +22,7 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.3 * %level%
multiplier: "1 + 0.3 * %level%"
triggers:
- trident_attack
filters:
@ -38,4 +38,4 @@ effects:
- villager
- axolotl
- chicken
conditions: []
conditions: [ ]

View File

@ -1,13 +1,13 @@
display-name: Abrasion
description: Damages your opponents armor by %placeholder%.
placeholder: '%level%'
type: Normal
display-name: "Abrasion"
description: "Deals &a%placeholder% &8damage to your opponents armor"
placeholder: "%level%"
type: normal
targets:
- sword
- axe
- sword
- axe
conflicts: []
conflicts: [ ]
rarity: legendary
max-level: 2
@ -21,4 +21,4 @@ effects:
damage: "%level%"
triggers:
- melee_attack
conditions: []
conditions: [ ]

View File

@ -1,12 +1,12 @@
display-name: Aerial
description: Deal %placeholder%% more arrow damage when you are in air
placeholder: '10*%level%'
display-name: "Aerial"
description: "Deal &a%placeholder%% &8more arrow damage when you are in air"
placeholder: "10 * %level%"
type: normal
targets:
- bow
- crossbow
conflicts: []
- bow
- crossbow
conflicts: [ ]
rarity: epic
max-level: 3
@ -17,7 +17,7 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.1 * %level%
multiplier: "1 + 0.1 * %level%"
triggers:
- bow_attack
conditions:

View File

@ -1,11 +1,11 @@
display-name: Aquatic
description: Trident deals %placeholder%% additional damage when shot from water
placeholder: '5*%level%'
type: Normal
display-name: "Aquatic"
description: "Trident deals &a%placeholder%% &8additional damage when shot from water"
placeholder: "5 * %level%"
type: normal
targets:
- trident
conflicts: []
- trident
conflicts: [ ]
rarity: rare
max-level: 8
@ -16,7 +16,7 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.05 * %level%
multiplier: "1 + 0.05 * %level%"
triggers:
- trident_attack
conditions:

View File

@ -1,10 +1,10 @@
display-name: Arachnid
description: Increases damage against spiders
placeholder: '30*%level%'
type: Normal
display-name: "Arachnid"
description: "Increases damage against spiders"
placeholder: "30 * %level%"
type: normal
targets:
- trident
- trident
conflicts:
- serrated
- bladed
@ -22,11 +22,11 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.3 * %level%
multiplier: "1 + 0.3 * %level%"
triggers:
- trident_attack
filters:
entities:
- spider
- cave_spider
conditions: []
conditions: [ ]

View File

@ -1,11 +1,11 @@
display-name: Arcanic
description: "%placeholder%% chance to ignore potion damage"
placeholder: '%level% * 8'
type: Normal
display-name: "Arcanic"
description: "&a%placeholder%% &8chance to ignore potion damage"
placeholder: "%level% * 8"
type: normal
targets:
- armor
conflicts: []
- armor
conflicts: [ ]
rarity: epic
max-level: 6
@ -23,4 +23,4 @@ effects:
damageCause:
- poison
- magic
conditions: []
conditions: [ ]

View File

@ -1,11 +1,11 @@
display-name: Atmospheric
description: Deal %placeholder%% more trident damage when you are in air
placeholder: '10*%level%'
display-name: "Atmospheric"
description: "Deal &a%placeholder%% &8more trident damage when you are in air"
placeholder: "10 * %level%"
type: normal
targets:
- trident
conflicts: []
- trident
conflicts: [ ]
rarity: epic
max-level: 3
@ -16,7 +16,7 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.1 * %level%
multiplier: "1 + 0.1 * %level%"
triggers:
- bow_attack
conditions:

View File

@ -1,11 +1,11 @@
display-name: Bladed
description: Trident deals %placeholder%% additional damage
placeholder: '0.5*%level%'
type: Special
display-name: "Bladed"
description: "Trident deals &a%placeholder%% &8more damage"
placeholder: "0.5 * %level%"
type: special
targets:
- trident
conflicts: []
- trident
conflicts: [ ]
rarity: veryspecial
max-level: 5
@ -16,7 +16,7 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.5 * %level%
multiplier: "1 + 0.5 * %level%"
triggers:
- trident_attack
conditions: []
conditions: [ ]

View File

@ -1,10 +1,10 @@
display-name: Blast Mining
description: "%placeholder%% chance to mine blocks in a 3x3 area"
placeholder: '20 * %level%'
type: Normal
display-name: "Blast Mining"
description: "&a%placeholder%% &8chance to mine blocks in a 3x3 area"
placeholder: "20 * %level%"
type: normal
targets:
- pickaxe
- pickaxe
conflicts:
- drill
- vein
@ -18,12 +18,11 @@ enchantable: true
effects:
- id: mine_radius
args:
chance: 20 * %level%
chance: "20 * %level%"
radius: 1
blacklisted_blocks: []
blacklisted_blocks: [ ]
check_hardness: true
disable_on_sneak: true
whitelist: [ ]
triggers:
- mine_block
conditions: []
conditions: [ ]

View File

@ -1,11 +1,11 @@
display-name: Bleed
description: Causes your opponent to bleed, damaging them repeatedly
placeholder: '1.5 * %level%'
display-name: "Bleed"
description: "&a%placeholder%% &8chance to cause your opponent to bleed, damaging them repeatedly"
placeholder: "1.5 * %level%"
type: normal
targets:
- sword
conflicts: []
- sword
conflicts: [ ]
rarity: legendary
max-level: 7
@ -16,8 +16,10 @@ enchantable: true
effects:
- id: bleed
args:
chance: 1.5 * %level%
chance: "1.5 * %level%"
damage: 1
interval: 15
amount: 2 * %level%
conditions: []
amount: "2 * %level%"
triggers:
- melee_attack
conditions: [ ]

View File

@ -1,12 +1,12 @@
display-name: Blind
description: "%placeholder%% chance of blinding your opponent"
placeholder: '%level%'
type: Normal
display-name: "Blind"
description: "&a%placeholder%% &8chance of blinding your opponent"
placeholder: "%level%"
type: normal
targets:
- bow
- crossbow
conflicts: []
- bow
- crossbow
conflicts: [ ]
rarity: legendary
max-level: 6
@ -17,9 +17,11 @@ enchantable: true
effects:
- id: potion_effect
args:
chance: %level%
chance: "%level%"
effect: blindness
level: 1
duration: 20 * %level%
duration: "20 * %level%"
apply_to_player: false
conditions: []
triggers:
- melee_attack
conditions: [ ]

View File

@ -1,11 +1,11 @@
display-name: Block Breather
description: "%placeholder%% chance to ignore suffocation damage"
placeholder: '%level%*15'
type: Normal
display-name: "Block Breather"
description: "&a%placeholder%% &8chance to ignore suffocation damage"
placeholder: "%level% * 15"
type: normal
targets:
- helmet
conflicts: []
- helmet
conflicts: [ ]
rarity: common
max-level: 3
@ -21,5 +21,5 @@ effects:
- take_damage
filters:
damageCause:
- SUFFOCATION
conditions: []
- suffocation
conditions: [ ]

View File

@ -1,12 +1,12 @@
display-name: Boss Hunter
description: Deal %placeholder%% more damage against bosses
placeholder: '10 * %level%'
type: Normal
display-name: "Boss Hunter"
description: "Deal &a%placeholder%% &8more damage against bosses"
placeholder: "10 * %level%"
type: normal
targets:
- bow
- crossbow
conflicts: []
- bow
- crossbow
conflicts: [ ]
rarity: rare
max-level: 8
@ -17,9 +17,9 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.1 * %level%
multiplier: "1 + 0.1 * %level%"
triggers:
- bow_attack
filters:
onlyBosses: true
conditions: []
conditions: [ ]

View File

@ -1,11 +1,11 @@
display-name: Butchering
description: Deal %placeholder%% more damage against passive mobs
placeholder: '25*%level%'
type: Normal
display-name: "Butchering"
description: "Deal &a%placeholder%% &8more damage against passive mobs"
placeholder: "25 * %level%"
type: normal
targets:
- sword
- axe
- sword
- axe
conflicts:
- sharpness
- bane_of_arthropods
@ -23,7 +23,7 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.25 * %level%
multiplier: "1 + 0.25 * %level%"
triggers:
- melee_attack
filters:
@ -39,4 +39,4 @@ effects:
- villager
- axolotl
- chicken
conditions: []
conditions: [ ]

View File

@ -1,10 +1,10 @@
display-name: Carve
description: "%placeholder%% chance to heavily damage all entities around attacked entity"
placeholder: '10*%level%'
display-name: "Carve"
description: "&a%placeholder%% &8chance to heavily damage nearby entities when you swing"
placeholder: "10 * %level%"
type: special
targets:
- axe
- axe
conflicts:
- cleave
rarity: special
@ -17,12 +17,12 @@ enchantable: true
effects:
- id: damage_nearby_entities
args:
chance: "10*%level%"
chance: "10 * %level%"
damage: 2
radius: "0.5*%level%"
entities: []
radius: "0.5 * %level%"
entities: [ ]
damage_as_player: true
damage_self: false
triggers:
- melee_attack
conditions: []
conditions: [ ]

View File

@ -1,10 +1,10 @@
display-name: Cleave
description: "%placeholder%% chance to damage all entities around attacked entity"
placeholder: '5*%level%'
type: Normal
display-name: "Cleave"
description: "&a%placeholder%% &8chance to damage all entities around attacked entity"
placeholder: "5 * %level%"
type: normal
targets:
- axe
- axe
conflicts:
- carve
rarity: rare
@ -17,12 +17,12 @@ enchantable: true
effects:
- id: damage_nearby_entities
args:
chance: "5*%level%"
chance: "5 * %level%"
damage: 2
radius: "0.25*%level%"
radius: "0.25 * %level%"
entities: [ ]
damage_as_player: true
damage_self: false
triggers:
- melee_attack
conditions: []
conditions: [ ]

View File

@ -1,11 +1,11 @@
display-name: Confusion
description: "%placeholder%% chance to shuffle your opponents hotbar"
placeholder: '2*%level%'
display-name: "Confusion"
description: "&a%placeholder%% &8chance to shuffle your opponents hotbar"
placeholder: "2 * %level%"
type: Special
targets:
- sword
conflicts: []
- sword
conflicts: [ ]
rarity: special
max-level: 4
@ -16,7 +16,7 @@ enchantable: true
effects:
- id: shuffle_hotbar
args:
chance: 2 * %level%
chance: "2 * %level%"
triggers:
- melee_attack
conditions: []
conditions: [ ]

View File

@ -1,12 +1,12 @@
display-name: Corrosive
description: Damages your opponents armor
placeholder: '%level%'
type: Normal
display-name: "Corrosive"
description: "Deals &a%placeholder% &8damage to your opponents armor"
placeholder: "%level%"
type: normal
targets:
- bow
- crossbow
conflicts: []
- bow
- crossbow
conflicts: [ ]
rarity: legendary
max-level: 2
@ -20,4 +20,4 @@ effects:
damage: "%level%"
triggers:
- melee_attack
conditions: []
conditions: [ ]

View File

@ -1,12 +1,12 @@
display-name: Criticals
description: Increases critical damage by %placeholder%
placeholder: '10*%level%'
type: Normal
display-name: "Criticals"
description: "Increases critical damage by &a%placeholder%%"
placeholder: "10 * %level%"
type: normal
targets:
- sword
- axe
conflicts: []
- sword
- axe
conflicts: [ ]
rarity: epic
max-level: 3
@ -17,7 +17,7 @@ enchantable: true
effects:
- id: crit_multiplier
args:
multiplier: 1 + 0.1*%level%
multiplier: "1 + 0.1 * %level%"
triggers:
- melee_attack
conditions: []
conditions: [ ]

View File

@ -1,12 +1,12 @@
display-name: Cubism
description: Deal %placeholder%% more against slimes and magma cubes
placeholder: '5*%level%'
type: Normal
display-name: "Cubism"
description: "Deal &a%placeholder%% &8more against slimes and magma cubes"
placeholder: "5 * %level%"
type: normal
targets:
- sword
- axe
conflicts: []
- sword
- axe
conflicts: [ ]
rarity: rare
max-level: 7
@ -17,11 +17,11 @@ enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.05 * %level%
multiplier: "1 + 0.05 * %level%"
triggers:
- melee_attack
filters:
entities:
- slime
- magma_cube
conditions: []
conditions: [ ]

View File

@ -1,12 +1,12 @@
display-name: "Telekinesis"
description: "among us"
description: "Drops and experience go directly into your inventory"
type: normal
targets:
- pickaxe
- sword
- axe
conflicts: []
conflicts: [ ]
rarity: common
max-level: 1

View File

@ -1,24 +0,0 @@
display-name: "Test"
description: "Gives a &a%placeholder%%&8 bonus to damage"
placeholder: "%level% * 20"
type: normal
targets:
- sword
conflicts:
- sharpness
rarity: common
max-level: 4
tradeable: true
discoverable: true
enchantable: true
effects:
- id: damage_multiplier
args:
multiplier: 1 + 0.2 * %level%
triggers:
- melee_attack
conditions: [ ]

View File

@ -1,4 +1,4 @@
#libreforge-updater
#Mon Aug 29 16:15:50 BST 2022
version=9.0.0
#Tue Aug 30 20:29:10 BST 2022
version=9.0.0-b1
plugin-name=EcoEnchants