Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 Panda-exclusive properties added. #2688

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,16 @@ public static void registerMainProperties() {
PropertyParser.registerProperty(EntityPowered.class, EntityTag.class);
PropertyParser.registerProperty(EntityProfession.class, EntityTag.class);
PropertyParser.registerProperty(EntityPumpkinHead.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_18)) {
PropertyParser.registerProperty(EntityOnBack.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityRiptide.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) {
PropertyParser.registerProperty(EntityRightRotation.class, EntityTag.class);
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_18)) {
PropertyParser.registerProperty(EntityRolling.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityRotation.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) {
PropertyParser.registerProperty(EntityScale.class, EntityTag.class);
Expand All @@ -164,6 +170,9 @@ public static void registerMainProperties() {
PropertyParser.registerProperty(EntitySitting.class, EntityTag.class);
PropertyParser.registerProperty(EntitySize.class, EntityTag.class);
PropertyParser.registerProperty(EntitySmall.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_18)) {
PropertyParser.registerProperty(EntitySneezing.class, EntityTag.class);
}
PropertyParser.registerProperty(EntitySpeed.class, EntityTag.class);
PropertyParser.registerProperty(EntitySpell.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.denizenscript.denizen.objects.properties.entity;

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.entity.Panda;

public class EntityOnBack extends EntityProperty<ElementTag> {

// <--[property]
// @object EntityTag
// @name is_on_back
// @input ElementTag(Boolean)
// @description
// Controls whether a panda is on its back.

public static boolean describes(EntityTag entity) {
return entity.getBukkitEntity() instanceof Panda;
}

mcmonkey4eva marked this conversation as resolved.
Show resolved Hide resolved
@Override
public ElementTag getPropertyValue() {
return new ElementTag(as(Panda.class).isOnBack());
}

@Override
public void setPropertyValue(ElementTag param, Mechanism mechanism) {
if (mechanism.requireBoolean()) {
as(Panda.class).setOnBack(param.asBoolean());
}
}

@Override
public String getPropertyId() {
return "is_on_back";
}

public static void register() {
autoRegister("is_on_back", EntityOnBack.class, ElementTag.class, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.denizenscript.denizen.objects.properties.entity;

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.entity.Panda;

public class EntityRolling extends EntityProperty<ElementTag> {

// <--[property]
// @object EntityTag
// @name is_rolling
// @input ElementTag(Boolean)
// @description
// Controls whether a panda is rolling on the ground.

public static boolean describes(EntityTag entity) {
return entity.getBukkitEntity() instanceof Panda;
}

@Override
public ElementTag getPropertyValue() {
return new ElementTag(as(Panda.class).isRolling());
}

@Override
public void setPropertyValue(ElementTag param, Mechanism mechanism) {
if (mechanism.requireBoolean()) {
as(Panda.class).setRolling(param.asBoolean());
}
}

@Override
public String getPropertyId() {
return "is_rolling";
}

public static void register() {
autoRegister("is_rolling", EntityRolling.class, ElementTag.class, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.denizenscript.denizen.objects.properties.entity;

import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.entity.Panda;

public class EntitySneezing extends EntityProperty<ElementTag> {

// <--[property]
// @object EntityTag
// @name is_sneezing
// @input ElementTag(Boolean)
// @description
// Controls whether a panda is sneezing.

public static boolean describes(EntityTag entity) {
return entity.getBukkitEntity() instanceof Panda;
}

@Override
public ElementTag getPropertyValue() {
return new ElementTag(as(Panda.class).isSneezing());
}

@Override
public void setPropertyValue(ElementTag param, Mechanism mechanism) {
if (mechanism.requireBoolean()) {
as(Panda.class).setSneezing(param.asBoolean());
}
}

@Override
public String getPropertyId() {
return "is_sneezing";
}

public static void register() {
autoRegister("is_sneezing", EntitySneezing.class, ElementTag.class, false);
}
}