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
ac0a885
commit c36332a
Showing
4 changed files
with
250 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
77 changes: 77 additions & 0 deletions
77
.../src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityCanJoinRaid.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,77 @@ | ||
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.objects.properties.PropertyParser; | ||
import org.bukkit.entity.Raider; | ||
|
||
public class EntityCanJoinRaid implements Property { | ||
|
||
public static boolean describes(ObjectTag entity) { | ||
return entity instanceof EntityTag && ((EntityTag) entity).getBukkitEntity() instanceof Raider; | ||
} | ||
|
||
public static EntityCanJoinRaid getFrom(ObjectTag entity) { | ||
if (!describes(entity)) { | ||
return null; | ||
} | ||
else { | ||
return new EntityCanJoinRaid((EntityTag) entity); | ||
} | ||
} | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"can_join_raid" | ||
}; | ||
|
||
private EntityCanJoinRaid(EntityTag entity) { | ||
this.entity = entity; | ||
} | ||
|
||
EntityTag entity; | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return ((Raider) entity.getBukkitEntity()).isCanJoinRaid() ? "true" : "false"; | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "can_join_raid"; | ||
} | ||
|
||
public static void registerTags() { | ||
|
||
// <--[tag] | ||
// @attribute <EntityTag.can_join_raid> | ||
// @returns ElementTag(Boolean) | ||
// @mechanism EntityTag.can_join_raid | ||
// @group properties | ||
// @description | ||
// If the entity is raider mob (like a pillager), returns whether the entity is allowed to join active raids. | ||
// --> | ||
PropertyParser.<EntityCanJoinRaid>registerTag("can_join_raid", (attribute, object) -> { | ||
return new ElementTag(((Raider) object.entity.getBukkitEntity()).isCanJoinRaid()); | ||
}); | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object EntityTag | ||
// @name can_join_raid | ||
// @input ElementTag(Boolean) | ||
// @description | ||
// If the entity is raider mob (like a pillager), changes whether the entity is allowed to join active raids. | ||
// @tags | ||
// <EntityTag.can_join_raid> | ||
// --> | ||
if (mechanism.matches("can_join_raid") && mechanism.requireBoolean()) { | ||
((Raider) entity.getBukkitEntity()).setCanJoinRaid(mechanism.getValue().asBoolean()); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityPatrolLeader.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,77 @@ | ||
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.objects.properties.PropertyParser; | ||
import org.bukkit.entity.Raider; | ||
|
||
public class EntityPatrolLeader implements Property { | ||
|
||
public static boolean describes(ObjectTag entity) { | ||
return entity instanceof EntityTag && ((EntityTag) entity).getBukkitEntity() instanceof Raider; | ||
} | ||
|
||
public static EntityPatrolLeader getFrom(ObjectTag entity) { | ||
if (!describes(entity)) { | ||
return null; | ||
} | ||
else { | ||
return new EntityPatrolLeader((EntityTag) entity); | ||
} | ||
} | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"is_patrol_leader" | ||
}; | ||
|
||
private EntityPatrolLeader(EntityTag entity) { | ||
this.entity = entity; | ||
} | ||
|
||
EntityTag entity; | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return ((Raider) entity.getBukkitEntity()).isPatrolLeader() ? "true" : "false"; | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "is_patrol_leader"; | ||
} | ||
|
||
public static void registerTags() { | ||
|
||
// <--[tag] | ||
// @attribute <EntityTag.is_patrol_leader> | ||
// @returns ElementTag(Boolean) | ||
// @mechanism EntityTag.is_patrol_leader | ||
// @group properties | ||
// @description | ||
// If the entity is raider mob (like a pillager), returns whether the entity is a patrol leader. | ||
// --> | ||
PropertyParser.<EntityPatrolLeader>registerTag("is_patrol_leader", (attribute, object) -> { | ||
return new ElementTag(((Raider) object.entity.getBukkitEntity()).isPatrolLeader()); | ||
}); | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object EntityTag | ||
// @name is_patrol_leader | ||
// @input ElementTag(Boolean) | ||
// @description | ||
// If the entity is raider mob (like a pillager), changes whether the entity is a patrol leader. | ||
// @tags | ||
// <EntityTag.is_patrol_leader> | ||
// --> | ||
if (mechanism.matches("is_patrol_leader") && mechanism.requireBoolean()) { | ||
((Raider) entity.getBukkitEntity()).setPatrolLeader(mechanism.getValue().asBoolean()); | ||
} | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityPatrolTarget.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,91 @@ | ||
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.objects.properties.PropertyParser; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Raider; | ||
|
||
public class EntityPatrolTarget implements Property { | ||
|
||
public static boolean describes(ObjectTag entity) { | ||
return entity instanceof EntityTag && ((EntityTag) entity).getBukkitEntity() instanceof Raider; | ||
} | ||
|
||
public static EntityPatrolTarget getFrom(ObjectTag entity) { | ||
if (!describes(entity)) { | ||
return null; | ||
} | ||
else { | ||
return new EntityPatrolTarget((EntityTag) entity); | ||
} | ||
} | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"patrol_target" | ||
}; | ||
|
||
private EntityPatrolTarget(EntityTag entity) { | ||
this.entity = entity; | ||
} | ||
|
||
EntityTag entity; | ||
|
||
@Override | ||
public String getPropertyString() { | ||
Block target = ((Raider) entity.getBukkitEntity()).getPatrolTarget(); | ||
if (target == null) { | ||
return null; | ||
} | ||
return new LocationTag(target.getLocation()).identify(); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "patrol_target"; | ||
} | ||
|
||
public static void registerTags() { | ||
|
||
// <--[tag] | ||
// @attribute <EntityTag.patrol_target> | ||
// @returns LocationTag | ||
// @mechanism EntityTag.patrol_target | ||
// @group properties | ||
// @description | ||
// If the entity is raider mob (like a pillager), returns whether the entity is allowed to join active raids. | ||
// --> | ||
PropertyParser.<EntityPatrolTarget>registerTag("patrol_target", (attribute, object) -> { | ||
Block target = ((Raider) object.entity.getBukkitEntity()).getPatrolTarget(); | ||
if (target == null) { | ||
return null; | ||
} | ||
return new LocationTag(target.getLocation()); | ||
}); | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object EntityTag | ||
// @name patrol_target | ||
// @input LocationTag | ||
// @description | ||
// If the entity is raider mob (like a pillager), changes whether the entity is allowed to join active raids. | ||
// @tags | ||
// <EntityTag.patrol_target> | ||
// --> | ||
if (mechanism.matches("patrol_target")) { | ||
if (mechanism.hasValue() && mechanism.requireObject(LocationTag.class)) { | ||
((Raider) entity.getBukkitEntity()).setPatrolTarget(mechanism.valueAsType(LocationTag.class).getBlock()); | ||
} | ||
else { | ||
((Raider) entity.getBukkitEntity()).setPatrolTarget(null); | ||
} | ||
} | ||
} | ||
} |