Permalink
Browse files

Add get|set_entity_silent(), get|set_entity_gravity(), and get|set_en…

…tity_invulnerable()
1 parent e508ad7 commit 395cfa521f44794bc816efa744e3e0799635eb5e @PseudoKnight PseudoKnight committed Jun 22, 2017
@@ -102,4 +102,12 @@
public boolean hasGravity();
public void setHasGravity(boolean gravity);
+
+ public boolean isSilent();
+
+ public void setSilent(boolean silent);
+
+ public boolean isInvulnerable();
+
+ public void setInvulnerable(boolean invulnerable);
}
@@ -12,14 +12,12 @@
import com.laytonsmith.abstraction.bukkit.BukkitMCServer;
import com.laytonsmith.abstraction.bukkit.BukkitMCWorld;
import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents;
-import com.laytonsmith.abstraction.enums.MCDamageCause;
import com.laytonsmith.abstraction.enums.MCEntityEffect;
import com.laytonsmith.abstraction.enums.MCEntityType;
import com.laytonsmith.abstraction.enums.MCTeleportCause;
import com.laytonsmith.abstraction.enums.MCVersion;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCEntityType;
import com.laytonsmith.abstraction.events.MCEntityDamageEvent;
-import com.laytonsmith.commandhelper.CommandHelperPlugin;
import com.laytonsmith.core.Static;
import org.bukkit.EntityEffect;
import org.bukkit.entity.Entity;
@@ -311,22 +309,78 @@ public MCLocation asyncGetLocation() {
@Override
public boolean isGlowing() {
- return e.isGlowing();
+ try {
+ return e.isGlowing();
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.9
+ return false;
+ }
}
@Override
public void setGlowing(Boolean glow) {
- e.setGlowing(glow);
+ try {
+ e.setGlowing(glow);
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.9
+ }
}
@Override
public boolean hasGravity() {
- return e.hasGravity();
+ try {
+ return e.hasGravity();
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.10
+ return true;
+ }
}
@Override
public void setHasGravity(boolean gravity) {
- e.setGravity(gravity);
+ try {
+ e.setGravity(gravity);
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.10
+ }
+ }
+
+ @Override
+ public boolean isSilent() {
+ try {
+ return e.isSilent();
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.9.4
+ return false;
+ }
+ }
+
+ @Override
+ public void setSilent(boolean silent) {
+ try {
+ e.setSilent(silent);
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.9.4
+ }
+ }
+
+ @Override
+ public boolean isInvulnerable() {
+ try {
+ return e.isInvulnerable();
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.9.2
+ return false;
+ }
+ }
+
+ @Override
+ public void setInvulnerable(boolean invulnerable) {
+ try {
+ e.setInvulnerable(invulnerable);
+ } catch(NoSuchMethodError ex){
+ // Probably before 1.9.2
+ }
}
}
@@ -4142,7 +4142,7 @@ public String getName() {
}
public String docs() {
- return "void {Entity ID, boolean} If true, applies glowing effect to the entity";
+ return "void {entityID, boolean} If true, applies glowing effect to the entity (MC 1.9)";
}
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -4162,7 +4162,7 @@ public String getName() {
}
public String docs() {
- return "boolean {Entity} Returns true if the entity is glowing";
+ return "boolean {entityID} Returns true if the entity is glowing (MC 1.9)";
}
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -4182,7 +4182,7 @@ public String getName() {
}
public String docs() {
- return "void {Entity, boolean} If possible, makes the entity glide";
+ return "void {entityID, boolean} If possible, makes the entity glide (MC 1.9)";
}
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -4206,7 +4206,7 @@ public String getName() {
}
public String docs() {
- return "boolean {Entity} Returns true if the given entity is gliding";
+ return "boolean {entityID} Returns true if the given entity is gliding (MC 1.9)";
}
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -4225,7 +4225,7 @@ public String getName() {
}
public String docs() {
- return "boolean {Entity} Returns true if the given entity has AI";
+ return "boolean {entityID} Returns true if the given entity has AI (MC 1.9.2)";
}
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -4244,7 +4244,7 @@ public String getName() {
}
public String docs() {
- return "void {Entity, boolean} enables or disables the entity AI";
+ return "void {entityID, boolean} enables or disables the entity AI (MC 1.9.2)";
}
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -4260,4 +4260,125 @@ public Version since() {
return CHVersion.V3_3_2;
}
}
+
+ @api
+ public static class get_entity_silent extends EntityGetterFunction {
+ public String getName() {
+ return "get_entity_silent";
+ }
+
+ public String docs() {
+ return "boolean {entityID} Returns true if the entity produces sounds (MC 1.9.4)";
+ }
+
+ public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
+ return CBoolean.GenerateCBoolean(Static.getEntity(args[0], t).isSilent(), t);
+ }
+
+ public Version since() {
+ return CHVersion.V3_3_2;
+ }
+ }
+
+ @api
+ public static class set_entity_silent extends EntitySetterFunction {
+ public String getName() {
+ return "set_entity_silent";
+ }
+
+ public String docs() {
+ return "void {entityID, boolean} Sets whether or not entity produces sounds (MC 1.9.4)";
+ }
+
+ public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
+ MCEntity e = Static.getEntity(args[0], t);
+ e.setSilent(Static.getBoolean(args[1]));
+ return CVoid.VOID;
+ }
+
+ public Version since() {
+ return CHVersion.V3_3_2;
+ }
+ }
+
+ @api
+ public static class get_entity_gravity extends EntityGetterFunction {
+ public String getName() {
+ return "get_entity_gravity";
+ }
+
+ public String docs() {
+ return "boolean {entityID} Returns true if gravity applies to the entity (MC 1.10)";
+ }
+
+ public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
+ return CBoolean.GenerateCBoolean(Static.getEntity(args[0], t).hasGravity(), t);
+ }
+
+ public Version since() {
+ return CHVersion.V3_3_2;
+ }
+ }
+
+ @api
+ public static class set_entity_gravity extends EntitySetterFunction {
+ public String getName() {
+ return "set_entity_gravity";
+ }
+
+ public String docs() {
+ return "void {entityID, boolean} Sets whether or not gravity applies to the entity (MC 1.10)";
+ }
+
+ public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
+ MCEntity e = Static.getEntity(args[0], t);
+ e.setHasGravity(Static.getBoolean(args[1]));
+ return CVoid.VOID;
+ }
+
+ public Version since() {
+ return CHVersion.V3_3_2;
+ }
+ }
+
+ @api
+ public static class get_entity_invulnerable extends EntityGetterFunction {
+ public String getName() {
+ return "get_entity_invulnerable";
+ }
+
+ public String docs() {
+ return "boolean {entityID} Returns true if the entity cannot be damaged (MC 1.9.2)";
+ }
+
+ public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
+ return CBoolean.GenerateCBoolean(Static.getEntity(args[0], t).isInvulnerable(), t);
+ }
+
+ public Version since() {
+ return CHVersion.V3_3_2;
+ }
+ }
+
+ @api
+ public static class set_entity_invulnerable extends EntitySetterFunction {
+ public String getName() {
+ return "set_entity_invulnerable";
+ }
+
+ public String docs() {
+ return "void {entityID, boolean} If set to true the entity cannot be damaged, except by players in"
+ + " creative mode (MC 1.9.2)";
+ }
+
+ public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
+ MCEntity e = Static.getEntity(args[0], t);
+ e.setInvulnerable(Static.getBoolean(args[1]));
+ return CVoid.VOID;
+ }
+
+ public Version since() {
+ return CHVersion.V3_3_2;
+ }
+ }
}

0 comments on commit 395cfa5

Please sign in to comment.