Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0025442
commit 4f17f4e
Showing
6 changed files
with
527 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
98 changes: 98 additions & 0 deletions
98
.../main/java/com/denizenscript/denizen/objects/properties/entity/EntityCannotEnterHive.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,98 @@ | ||
package com.denizenscript.denizen.objects.properties.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.DurationTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
import com.denizenscript.denizencore.tags.Attribute; | ||
import org.bukkit.entity.Bee; | ||
import org.bukkit.entity.Entity; | ||
|
||
public class EntityCannotEnterHive implements Property { | ||
|
||
public static boolean describes(ObjectTag entity) { | ||
if (!(entity instanceof EntityTag)) { | ||
return false; | ||
} | ||
Entity bukkitEntity = ((EntityTag) entity).getBukkitEntity(); | ||
return bukkitEntity instanceof Bee; | ||
} | ||
|
||
public static EntityCannotEnterHive getFrom(ObjectTag entity) { | ||
if (!describes(entity)) { | ||
return null; | ||
} | ||
else { | ||
return new EntityCannotEnterHive((EntityTag) entity); | ||
} | ||
} | ||
|
||
public static final String[] handledTags = new String[] { | ||
"cannot_enter_hive" | ||
}; | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"cannot_enter_hive" | ||
}; | ||
|
||
private EntityCannotEnterHive(EntityTag entity) { | ||
this.entity = entity; | ||
} | ||
|
||
EntityTag entity; | ||
|
||
public Bee getBee() { | ||
return (Bee) entity.getBukkitEntity(); | ||
} | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return new DurationTag((long) getBee().getCannotEnterHiveTicks()).identify(); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "flower"; | ||
} | ||
|
||
@Override | ||
public ObjectTag getObjectAttribute(Attribute attribute) { | ||
|
||
if (attribute == null) { | ||
return null; | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <EntityTag.cannot_enter_hive> | ||
// @returns DurationTag | ||
// @mechanism EntityTag.cannot_enter_hive | ||
// @group properties | ||
// @description | ||
// Returns the minimum duration until a Bee entity is allowed to enter a hive. | ||
// --> | ||
if (attribute.startsWith("cannot_enter_hive")) { | ||
return new DurationTag((long) getBee().getCannotEnterHiveTicks()) | ||
.getObjectAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object EntityTag | ||
// @name cannot_enter_hive | ||
// @input DurationTag | ||
// @description | ||
// Changes the minimum duration until a Bee entity is allowed to enter a hive. | ||
// @tags | ||
// <EntityTag.cannot_enter_hive> | ||
// --> | ||
if (mechanism.matches("cannot_enter_hive") && mechanism.requireObject(DurationTag.class)) { | ||
getBee().setCannotEnterHiveTicks(mechanism.valueAsType(DurationTag.class).getTicksAsInt()); | ||
} | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
plugin/src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityFlower.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,110 @@ | ||
package com.denizenscript.denizen.objects.properties.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizen.objects.LocationTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
import com.denizenscript.denizencore.tags.Attribute; | ||
import org.bukkit.entity.Bee; | ||
import org.bukkit.entity.Entity; | ||
|
||
public class EntityFlower implements Property { | ||
|
||
public static boolean describes(ObjectTag entity) { | ||
if (!(entity instanceof EntityTag)) { | ||
return false; | ||
} | ||
Entity bukkitEntity = ((EntityTag) entity).getBukkitEntity(); | ||
return bukkitEntity instanceof Bee; | ||
} | ||
|
||
public static EntityFlower getFrom(ObjectTag entity) { | ||
if (!describes(entity)) { | ||
return null; | ||
} | ||
else { | ||
return new EntityFlower((EntityTag) entity); | ||
} | ||
} | ||
|
||
public static final String[] handledTags = new String[] { | ||
"flower" | ||
}; | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"flower" | ||
}; | ||
|
||
private EntityFlower(EntityTag entity) { | ||
this.entity = entity; | ||
} | ||
|
||
EntityTag entity; | ||
|
||
public Bee getBee() { | ||
return (Bee) entity.getBukkitEntity(); | ||
} | ||
|
||
@Override | ||
public String getPropertyString() { | ||
if (getBee().getFlower() == null) { | ||
return null; | ||
} | ||
return new LocationTag(getBee().getFlower()).identify(); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "flower"; | ||
} | ||
|
||
@Override | ||
public ObjectTag getObjectAttribute(Attribute attribute) { | ||
|
||
if (attribute == null) { | ||
return null; | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <EntityTag.flower> | ||
// @returns LocationTag | ||
// @mechanism EntityTag.flower | ||
// @group properties | ||
// @description | ||
// Returns the location of a bee's flower (if any). | ||
// --> | ||
if (attribute.startsWith("flower")) { | ||
if (getBee().getFlower() == null) { | ||
return null; | ||
} | ||
return new LocationTag(getBee().getFlower()) | ||
.getObjectAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object EntityTag | ||
// @name flower | ||
// @input LocationTag | ||
// @description | ||
// Changes the location of a bee's flower. | ||
// Give no input to unset the bee's flower. | ||
// @tags | ||
// <EntityTag.flower> | ||
// --> | ||
if (mechanism.matches("flower")) { | ||
if (mechanism.hasValue() && mechanism.requireObject(LocationTag.class)) { | ||
getBee().setFlower(mechanism.valueAsType(LocationTag.class)); | ||
} | ||
else { | ||
getBee().setFlower(null); | ||
} | ||
} | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
...in/src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityHasNectar.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,98 @@ | ||
package com.denizenscript.denizen.objects.properties.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
import com.denizenscript.denizencore.tags.Attribute; | ||
import org.bukkit.entity.Bee; | ||
import org.bukkit.entity.Entity; | ||
|
||
public class EntityHasNectar implements Property { | ||
|
||
public static boolean describes(ObjectTag entity) { | ||
if (!(entity instanceof EntityTag)) { | ||
return false; | ||
} | ||
Entity bukkitEntity = ((EntityTag) entity).getBukkitEntity(); | ||
return bukkitEntity instanceof Bee; | ||
} | ||
|
||
public static EntityHasNectar getFrom(ObjectTag entity) { | ||
if (!describes(entity)) { | ||
return null; | ||
} | ||
else { | ||
return new EntityHasNectar((EntityTag) entity); | ||
} | ||
} | ||
|
||
public static final String[] handledTags = new String[] { | ||
"has_nectar" | ||
}; | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"has_nectar" | ||
}; | ||
|
||
private EntityHasNectar(EntityTag entity) { | ||
this.entity = entity; | ||
} | ||
|
||
EntityTag entity; | ||
|
||
public Bee getBee() { | ||
return (Bee) entity.getBukkitEntity(); | ||
} | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return getBee().hasNectar() ? "true" : "false"; | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "has_nectar"; | ||
} | ||
|
||
@Override | ||
public ObjectTag getObjectAttribute(Attribute attribute) { | ||
|
||
if (attribute == null) { | ||
return null; | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <EntityTag.has_nectar> | ||
// @returns ElementTag(Boolean) | ||
// @mechanism EntityTag.has_nectar | ||
// @group properties | ||
// @description | ||
// Returns whether a bee entity has nectar on it. | ||
// --> | ||
if (attribute.startsWith("has_nectar")) { | ||
return new ElementTag(getBee().hasNectar()) | ||
.getObjectAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object EntityTag | ||
// @name has_nectar | ||
// @input ElementTag(Boolean) | ||
// @description | ||
// Changes whether a bee entity has nectar on it. | ||
// @tags | ||
// <EntityTag.has_nectar> | ||
// --> | ||
if (mechanism.matches("has_nectar") && mechanism.requireBoolean()) { | ||
getBee().setHasNectar(mechanism.getValue().asBoolean()); | ||
} | ||
} | ||
} |
Oops, something went wrong.