Added baby arg parser
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.willfp.eco.internal.entities
|
||||
|
||||
import com.willfp.eco.core.entities.args.EntityArgParseResult
|
||||
import com.willfp.eco.core.entities.args.EntityArgParser
|
||||
import org.bukkit.entity.Animals
|
||||
|
||||
class EntityArgParserBaby : EntityArgParser {
|
||||
override fun parseArguments(args: Array<out String>): EntityArgParseResult? {
|
||||
var baby = false
|
||||
|
||||
for (arg in args) {
|
||||
if (arg.equals("baby", true)) {
|
||||
baby = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!baby) {
|
||||
return null
|
||||
}
|
||||
|
||||
return EntityArgParseResult(
|
||||
{
|
||||
if (it !is Animals) {
|
||||
return@EntityArgParseResult false
|
||||
}
|
||||
|
||||
!it.isAdult
|
||||
},
|
||||
{
|
||||
(it as? Animals)?.setBaby()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.internal.entities
|
||||
|
||||
import com.willfp.eco.core.entities.args.EntityArgParseResult
|
||||
import com.willfp.eco.core.entities.args.EntityArgParser
|
||||
import org.bukkit.entity.Phantom
|
||||
import org.bukkit.entity.Slime
|
||||
|
||||
class EntityArgParserSize : EntityArgParser {
|
||||
@@ -23,18 +24,17 @@ class EntityArgParserSize : EntityArgParser {
|
||||
|
||||
return EntityArgParseResult(
|
||||
{
|
||||
if (it !is Slime) {
|
||||
return@EntityArgParseResult false
|
||||
when (it) {
|
||||
is Slime -> it.size == size
|
||||
is Phantom -> it.size == size
|
||||
else -> false
|
||||
}
|
||||
|
||||
it.size == size
|
||||
},
|
||||
{
|
||||
if (it !is Slime) {
|
||||
return@EntityArgParseResult
|
||||
when (it) {
|
||||
is Slime -> it.size == size
|
||||
is Phantom -> it.size == size
|
||||
}
|
||||
|
||||
it.size = size
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.willfp.eco.internal.display.EcoDisplayHandler
|
||||
import com.willfp.eco.internal.drops.DropManager
|
||||
import com.willfp.eco.internal.entities.EntityArgParserAttackDamage
|
||||
import com.willfp.eco.internal.entities.EntityArgParserAttackSpeed
|
||||
import com.willfp.eco.internal.entities.EntityArgParserBaby
|
||||
import com.willfp.eco.internal.entities.EntityArgParserFlySpeed
|
||||
import com.willfp.eco.internal.entities.EntityArgParserFollowRange
|
||||
import com.willfp.eco.internal.entities.EntityArgParserHealth
|
||||
@@ -132,6 +133,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
Entities.registerArgParser(EntityArgParserSize())
|
||||
Entities.registerArgParser(EntityArgParserSpawnReinforcements())
|
||||
Entities.registerArgParser(EntityArgParserSpeed())
|
||||
Entities.registerArgParser(EntityArgParserBaby())
|
||||
|
||||
val skullProxy = getProxy(SkullProxy::class.java)
|
||||
SkullUtils.initialize(
|
||||
|
||||
Reference in New Issue
Block a user