Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Update to v1.0.1 #33

Merged
merged 8 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ Purchase and download the plugin on our Spigot Page, and drop it in to your Spig
### ‼️Important Note
This plugin is built in Kotlin. While the plugin will automatically download the necessary libraries for the plugin to run, it is recommended that you install the [Kotlin Spigot Plugin](https://modrinth.com/plugin/kotlinmc/). **This is only required if you are running on a server version below 1.16.**

---
## Changelog

🐛 v1.0.1 - August 31, 2023
- Fixed some Artifact & Enchantment Bugs
- Internal Optimization
- Update to Kotlin v1.9.x
- Added the `BRICK` Artifact for 1.20+

⚔️ v1.0.0 - June 28, 2023

First Release of PlasmaEnchants

---
## 🔮 Future Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ interface PlasmaConfig {
* Fetches a list of mobs that should not drop naturally occuring enchantments.
* @return List of Mobs
*/
get() = "enchantments.spawn.drops.blacklisted-mobs"[configuration, List::class.java, listOf<String>()].mapNotNull { type -> EntityType.values().first { it.name == type.toString().uppercase() } }
get() = "enchantments.spawn.drops.blacklisted-mobs"[configuration, List::class.java, listOf<String>()].mapNotNull { type -> EntityType.entries.first { it.name == type.toString().uppercase() } }
/**
* Sets the list of mobs that should not drop naturally occuring enchantments.
* @param value List of Mobs
Expand All @@ -296,7 +296,7 @@ interface PlasmaConfig {
* Fetches a list of mobs that should only drop naturally occuring enchantments.
* @return List of Mobs
*/
get() = "enchantments.spawn.drops.whitelisted-mobs"[configuration, List::class.java, listOf<String>()].mapNotNull { type -> EntityType.values().first { it.name == type.toString().uppercase() } }
get() = "enchantments.spawn.drops.whitelisted-mobs"[configuration, List::class.java, listOf<String>()].mapNotNull { type -> EntityType.entries.first { it.name == type.toString().uppercase() } }
/**
* Sets the list of mobs that should only drop naturally occuring enchantments.
* @param value List of Mobs
Expand Down Expand Up @@ -372,7 +372,7 @@ interface PlasmaConfig {
* Fetches an immutable copy of list of loot tables that should not include naturally spawned enchantments.
* @return List of Blacklisted Loot Tables
*/
get() = "enchantments.spawn.loot.blacklisted-loottables"[configuration, List::class.java, listOf<String>()].mapNotNull { table -> LootTables.values().first { it.name == table.toString().uppercase() } }
get() = "enchantments.spawn.loot.blacklisted-loottables"[configuration, List::class.java, listOf<String>()].mapNotNull { table -> LootTables.entries.first { it.name == table.toString().uppercase() } }
/**
* Sets the list of loot tables that should not include naturally spawned enchantments.
* @param value List of Blacklisted Loot Tables
Expand All @@ -384,7 +384,7 @@ interface PlasmaConfig {
* Fetches an immutable copy of list of loot tables that should only include naturally spawned enchantments.
* @return List of Whitelisted Loot Tables
*/
get() = "enchantments.spawn.loot.whitelisted-loottables"[configuration, List::class.java, listOf<String>()].mapNotNull { table -> LootTables.values().first { it.name == table.toString().uppercase() } }
get() = "enchantments.spawn.loot.whitelisted-loottables"[configuration, List::class.java, listOf<String>()].mapNotNull { table -> LootTables.entries.first { it.name == table.toString().uppercase() } }
/**
* Sets the list of loot tables that should only include naturally spawned enchantments.
* @param value List of Whitelisted Loot Tables
Expand Down Expand Up @@ -1091,7 +1091,7 @@ interface PlasmaConfig {
* Fetches the list of professions that can trade artifacts.
* @return List of Villager Professions
*/
get() = "artifacts.trades.professions"[configuration, List::class.java, listOf<String>()].mapNotNull { profession -> Villager.Profession.values().firstOrNull { it.name.equals(profession.toString(), ignoreCase = true) } }
get() = "artifacts.trades.professions"[configuration, List::class.java, listOf<String>()].mapNotNull { profession -> Villager.Profession.entries.firstOrNull { it.name.equals(profession.toString(), ignoreCase = true) } }
/**
* Sets the list of professions that can trade artifacts.
* @param value List of Villager Professions
Expand All @@ -1115,7 +1115,7 @@ interface PlasmaConfig {
* Fetches the list of professions that can trade crafted artifacts.
* @return List of Villager Professions
*/
get() = "artifacts.trades.craftable-artifacts.professions"[configuration, List::class.java, listOf<String>()].mapNotNull { profession -> Villager.Profession.values().firstOrNull { it.name.equals(profession.toString(), ignoreCase = true) } }.ifEmpty { artifactTradesProfessions }
get() = "artifacts.trades.craftable-artifacts.professions"[configuration, List::class.java, listOf<String>()].mapNotNull { profession -> Villager.Profession.entries.firstOrNull { it.name.equals(profession.toString(), ignoreCase = true) } }.ifEmpty { artifactTradesProfessions }
/**
* Sets the list of professions that can trade crafted artifacts.
* @param value List of Villager Professions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.bukkit.enchantments.Enchantment
import org.bukkit.entity.*
import org.bukkit.event.Event
import org.bukkit.event.block.Action.*
import org.bukkit.event.entity.EntityDamageByEntityEvent
import org.bukkit.event.entity.EntityDamageEvent.DamageCause
import org.bukkit.inventory.ItemFlag
import org.bukkit.inventory.ItemStack
Expand Down Expand Up @@ -94,7 +95,7 @@ enum class PArtifacts(
val target = event.entity as? LivingEntity ?: return@Action

target.world.strikeLightning(target.location)
target.damage(r.nextInt(-10, 10) + 15.0)
event.damage += r.nextInt(-10, 10) + 15.0
}, ItemStack(Material.CREEPER_HEAD), Material.NETHER_STAR, ChatColor.LIGHT_PURPLE
),

Expand All @@ -107,8 +108,11 @@ enum class PArtifacts(

SHULKER(
SWORDS, Action(INTERACT) { event ->
val bullet = event.player.world.spawn(event.player.eyeLocation, ShulkerBullet::class.java)
bullet.target = event.player.getNearbyEntities(10.0, 10.0, 10.0).randomOrNull() as? LivingEntity
val bullet = event.player.world.spawn(event.player.eyeLocation, ShulkerBullet::class.java).apply {
shooter = event.player
}

bullet.target = event.player.getNearbyEntities(10.0, 10.0, 10.0).minByOrNull { it.location.distanceSquared(bullet.location) } as? LivingEntity
}, ItemStack(Material.SHULKER_SHELL, 48), Material.SHULKER_SHELL, ChatColor.GOLD
),

Expand Down Expand Up @@ -163,8 +167,8 @@ enum class PArtifacts(
),

SEA(
LEGGINGS, Action(DEFENDING) { event ->
if (event.cause == DamageCause.DROWNING || event.damager is Guardian || event.damager is Dolphin) event.isCancelled = true
LEGGINGS, Action(DAMAGE) { event ->
if (event.cause == DamageCause.DROWNING || (event is EntityDamageByEntityEvent && (event.damager is Guardian || event.damager is Dolphin))) event.isCancelled = true
}, ItemStack(Material.HEART_OF_THE_SEA, 2), Material.HEART_OF_THE_SEA
),

Expand Down Expand Up @@ -264,7 +268,7 @@ enum class PArtifacts(
.apply {
if (this !is LivingEntity) return@Action

addPotionEffect(PotionEffect(PotionEffectType.POISON, 3, 1, true))
addPotionEffect(PotionEffect(PotionEffectType.WITHER, 3, 1, true))
}
}, ItemStack(Material.WITHER_ROSE, 48), Material.WITHER_SKELETON_SKULL, ChatColor.LIGHT_PURPLE
),
Expand All @@ -288,7 +292,9 @@ enum class PArtifacts(
if (event.action != LEFT_CLICK_AIR && event.action != LEFT_CLICK_BLOCK) return@Action

val loc = event.player.eyeLocation
event.player.world.spawn(loc, SmallFireball::class.java)
event.player.world.spawn(loc, SmallFireball::class.java).apply {
shooter = event.player
}
}, ItemStack(Material.BLAZE_ROD, 64), Material.BLAZE_POWDER, ChatColor.GOLD
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ internal val CONFIG_MAP = ImmutableMap.builder<String, ConfigData>()

.putSection("enchantments.spawn.drops")
.put("enchantments.spawn.drops.blacklisted-mobs", FileConfiguration::isList, listOf<String>(),
{ value -> EntityType.values().map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) },
{ old -> old.filter { type -> EntityType.values().map { it.name.lowercase() }.contains(type.lowercase()) } }
{ value -> EntityType.entries.map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) },
{ old -> old.filter { type -> EntityType.entries.map { it.name.lowercase() }.contains(type.lowercase()) } }
)
.put("enchantments.spawn.drops.whitelisted-mobs", FileConfiguration::isList, listOf<String>(),
{ value -> EntityType.values().map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) },
{ old -> old.filter { type -> EntityType.values().map { it.name.lowercase() }.contains(type.lowercase()) } }
{ value -> EntityType.entries.map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) },
{ old -> old.filter { type -> EntityType.entries.map { it.name.lowercase() }.contains(type.lowercase()) } }
)
.put("enchantments.spawn.drops.min-level", FileConfiguration::isSet, "default",
{ value -> value.isChildLevel() }
Expand All @@ -59,11 +59,11 @@ internal val CONFIG_MAP = ImmutableMap.builder<String, ConfigData>()

.putSection("enchantments.spawn.loot")
.put("enchantments.spawn.loot.blacklisted-loottables", FileConfiguration::isList, listOf<String>(),
{ value -> LootTables.values().map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) })
{ old -> old.filter { type -> LootTables.values().map { it.name.lowercase() }.contains(type.lowercase()) } }
{ value -> LootTables.entries.map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) })
{ old -> old.filter { type -> LootTables.entries.map { it.name.lowercase() }.contains(type.lowercase()) } }
.put("enchantments.spawn.loot.whitelisted-loottables", FileConfiguration::isList, listOf<String>(),
{ value -> EntityType.values().map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) },
{ old -> old.filter { type -> EntityType.values().map { it.name.lowercase() }.contains(type.lowercase()) } }
{ value -> EntityType.entries.map { it.name.lowercase() }.containsAll(value.map { it.lowercase() }) },
{ old -> old.filter { type -> EntityType.entries.map { it.name.lowercase() }.contains(type.lowercase()) } }
)
.put("enchantments.spawn.loot.min-level", FileConfiguration::isSet, "default",
{ value -> value.isChildLevel() }
Expand All @@ -74,7 +74,7 @@ internal val CONFIG_MAP = ImmutableMap.builder<String, ConfigData>()
.putSection("enchantments.spawn.loot.chance")
.put("enchantments.spawn.loot.chance.global", isNumber, 0.3)
.put("enchantments.spawn.loot.chance.config", FileConfiguration::isList, listOf<Map<String, Any>>(),
{ value -> value.all { map -> map.keyNotNull("table") { table -> LootTables.values().map { it.name }.contains(table.toString().uppercase())}
{ value -> value.all { map -> map.keyNotNull("table") { table -> LootTables.entries.map { it.name }.contains(table.toString().uppercase())}
map.keyNotNull("chance") { it.isNumber() } &&
map.keyNotNull("min-level") { it.isChildLevel() } &&
map.keyNotNull("max-level") { it.isChildLevel() } &&
Expand Down Expand Up @@ -130,16 +130,16 @@ internal val CONFIG_MAP = ImmutableMap.builder<String, ConfigData>()
.putSection("enchantments.trades")
.put("enchantments.trades.include-wandering-traders", FileConfiguration::isBoolean, true)
.put("enchantments.trades.professions", FileConfiguration::isList, listOf<String>(),
{ value -> value.all { profession -> Villager.Profession.values().map { it.name.lowercase() }.contains(profession.lowercase()) } },
{ old -> old.filter { profession -> Villager.Profession.values().map { it.name.lowercase() }.contains(profession.lowercase()) } }
{ value -> value.all { profession -> Villager.Profession.entries.map { it.name.lowercase() }.contains(profession.lowercase()) } },
{ old -> old.filter { profession -> Villager.Profession.entries.map { it.name.lowercase() }.contains(profession.lowercase()) } }
)
.put("enchantments.trades.blacklisted-types", FileConfiguration::isList, listOf<String>(),
{ value -> value.all { type -> Villager.Type.values().map { it.name.lowercase() }.contains(type.lowercase()) } },
{ old -> old.filter { type -> Villager.Type.values().map { it.name.lowercase() }.contains(type.lowercase()) } }
{ value -> value.all { type -> Villager.Type.entries.map { it.name.lowercase() }.contains(type.lowercase()) } },
{ old -> old.filter { type -> Villager.Type.entries.map { it.name.lowercase() }.contains(type.lowercase()) } }
)
.put("enchantments.trades.whitelisted-types", FileConfiguration::isList, listOf<String>(),
{ value -> value.all { type -> Villager.Type.values().map { it.name.lowercase() }.contains(type.lowercase()) } },
{ old -> old.filter { type -> Villager.Type.values().map { it.name.lowercase() }.contains(type.lowercase()) } }
{ value -> value.all { type -> Villager.Type.entries.map { it.name.lowercase() }.contains(type.lowercase()) } },
{ old -> old.filter { type -> Villager.Type.entries.map { it.name.lowercase() }.contains(type.lowercase()) } }
)
.put("enchantments.trades.min-villager-level", FileConfiguration::isInt, 1)
.put("enchantments.trades.max-villager-level", FileConfiguration::isInt, 5)
Expand Down Expand Up @@ -216,8 +216,8 @@ internal val CONFIG_MAP = ImmutableMap.builder<String, ConfigData>()
.putSection("artifacts.trades")
.put("artifacts.trades.include-wandering-traders", FileConfiguration::isBoolean, true)
.put("artifacts.trades.professions", FileConfiguration::isList, listOf<String>(),
{ value -> value.all { profession -> Villager.Profession.values().map { it.name.lowercase() }.contains(profession.lowercase()) } },
{ old -> old.filter { profession -> Villager.Profession.values().map { it.name.lowercase() }.contains(profession.lowercase()) } }
{ value -> value.all { profession -> Villager.Profession.entries.map { it.name.lowercase() }.contains(profession.lowercase()) } },
{ old -> old.filter { profession -> Villager.Profession.entries.map { it.name.lowercase() }.contains(profession.lowercase()) } }
)
.put("artifacts.trades.min-villager-level", FileConfiguration::isInt, 1)
.put("artifacts.trades.max-villager-level", FileConfiguration::isInt, 5)
Expand All @@ -231,8 +231,8 @@ internal val CONFIG_MAP = ImmutableMap.builder<String, ConfigData>()
.putSection("artifacts.trades.craftable-artifacts")
.put("artifacts.trades.craftable-artifacts.enabled", FileConfiguration::isBoolean, true)
.put("artifacts.trades.craftable-artifacts.professions", FileConfiguration::isList, listOf<String>(),
{ value -> value.all { profession -> Villager.Profession.values().map { it.name.lowercase() }.contains(profession.lowercase()) } },
{ old -> old.filter { profession -> Villager.Profession.values().map { it.name.lowercase() }.contains(profession.lowercase()) } }
{ value -> value.all { profession -> Villager.Profession.entries.map { it.name.lowercase() }.contains(profession.lowercase()) } },
{ old -> old.filter { profession -> Villager.Profession.entries.map { it.name.lowercase() }.contains(profession.lowercase()) } }
)
.put("artifacts.trades.craftable-artifacts.blacklisted-artifacts", FileConfiguration::isList, listOf<String>(),
{ value -> value.all { it.isArtifact() } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,30 @@ enum class PEnchantments(
p.addPotionEffect(PotionEffect(PotionEffectType.INCREASE_DAMAGE, 40 * level, level - 1, true))
}),

CHAINING(
RANGED, 3, Action(ATTACKING) { event, level ->
val proj = event.damager as? Projectile ?: return@Action
val target = event.entity as? LivingEntity ?: return@Action

if (target.health - event.finalDamage > 0) return@Action

if (r.nextDouble() < 0.4)
for (i in 0 until level) {
val loc = target.eyeLocation
loc.pitch = 0F
loc.yaw = when (i) {
1 -> loc.yaw + 45F
2 -> loc.yaw - 45F
else -> loc.yaw
}

val newProj = target.world.spawn(loc, proj.javaClass)
newProj.velocity = proj.velocity.multiply(1.25).normalize()
newProj.shooter = proj.shooter
newProj.setBounce(proj.doesBounce())
}
}),

// Attacking Enchantments - Collectors

PLAYER_COLLECTOR(
Expand Down Expand Up @@ -857,7 +881,7 @@ enum class PEnchantments(
get() = info.type

override val conflicts
get() = values().filter { conflictsP.test(it) }.toList()
get() = entries.filter { it != this && conflictsP.test(it) }.toList()

override fun accept(e: Event, level: Int) = info.action(e, level)

Expand All @@ -880,7 +904,7 @@ enum class PEnchantments(
}

fun matchType(name: String): EntityType? {
for (type in EntityType.values())
for (type in EntityType.entries)
if (type.name.equals(name, ignoreCase = true)) return type

return null
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

val pGroup = "us.teaminceptus.plasmaenchants"
val pVersion = "1.0.0"
val pVersion = "1.0.1"
val pAuthor = "Team-Inceptus"

val jvmVersion: JavaVersion = JavaVersion.VERSION_11
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
kotlin.code.style=official
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2G -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class PlasmaEnchants : JavaPlugin(), PlasmaConfig, PlasmaRegistry {
}

private fun loadClasses() {
PEnchantments.values().forEach(::register)
PArtifacts.values().forEach(::register)
PEnchantments.entries.forEach(::register)
PArtifacts.entries.forEach(::register)
registerVersionClasses()

logger.info("Loaded ${artifacts.size} Artifacts")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class SpawnEvents(private val plugin: PlasmaEnchants) : Listener {

if (lootable.lootTable == null) return
val tableI = lootable.lootTable!!
val table = LootTables.values().firstOrNull { it.key == tableI.key } ?: return
val table = LootTables.entries.firstOrNull { it.key == tableI.key } ?: return

val artifactChance = plugin.artifactSpawnGlobalLootChance + (luckAmp * plugin.artifactSpawnLuckModifier)
if (r.nextDouble() < artifactChance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum class PEnchantments1_15(
get() = info.type

override val conflicts
get() = PEnchantments.values().filter { conflictsP.test(it) }.toList()
get() = PEnchantments.entries.filter { conflictsP.test(it) }.toList()

override fun accept(e: Event, level: Int) = info.action(e, level)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum class PEnchantments1_16(
get() = info.type

override val conflicts
get() = PEnchantments.values().filter { conflictsP.test(it) }.toList()
get() = PEnchantments.entries.filter { conflictsP.test(it) }.toList()

override fun accept(e: Event, level: Int) = info.action(e, level)

Expand Down
Loading