Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
egg_lay_time
mech & tag bundle (#2562)
* Adds egg lay time!!!!!!!!!!!!!! * Update PaperModule.java
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
paper/src/main/java/com/denizenscript/denizen/paper/properties/EntityEggLayTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.denizenscript.denizen.paper.properties; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizen.objects.properties.entity.EntityProperty; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import org.bukkit.entity.Chicken; | ||
|
||
public class EntityEggLayTime extends EntityProperty<ElementTag> { | ||
|
||
// <--[property] | ||
// @object EntityTag | ||
// @name egg_lay_time | ||
// @input ElementTag(Number) | ||
// @plugin Paper | ||
// @description | ||
// If the entity is a chicken, controls the number of ticks until it lays an egg. | ||
// --> | ||
|
||
public static boolean describes(EntityTag entity) { | ||
return entity.getBukkitEntity() instanceof Chicken; | ||
} | ||
|
||
@Override | ||
public ElementTag getPropertyValue() { | ||
return new ElementTag(as(Chicken.class).getEggLayTime()); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "egg_lay_time"; | ||
} | ||
|
||
@Override | ||
public void setPropertyValue(ElementTag param, Mechanism mechanism) { | ||
if (mechanism.requireInteger()) { | ||
as(Chicken.class).setEggLayTime(param.asInt()); | ||
} | ||
} | ||
|
||
public static void register() { | ||
autoRegister("egg_lay_time", EntityEggLayTime.class, ElementTag.class, false); | ||
} | ||
} |