diff options
Diffstat (limited to 'src/main/java/com/encrox/zombie/Mob.java')
-rwxr-xr-x | src/main/java/com/encrox/zombie/Mob.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/com/encrox/zombie/Mob.java b/src/main/java/com/encrox/zombie/Mob.java new file mode 100755 index 0000000..82958a3 --- /dev/null +++ b/src/main/java/com/encrox/zombie/Mob.java @@ -0,0 +1,41 @@ +package com.encrox.zombie;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.bukkit.entity.EntityType;
+import org.bukkit.util.BlockVector;
+
+import com.encrox.zombie.interactable.Lever;
+
+public class Mob {
+
+ public EntityType type;
+ public BlockVector bv;
+ public String rounds;
+ public Lever[] levers;
+
+ public Mob(EntityType type, BlockVector bv, String rounds, Lever[] levers) {
+ this.type = type;
+ this.bv = bv;
+ this.rounds = rounds;
+ this.levers = levers;
+ }
+
+ public boolean spawn(int round) {
+ for(int i = 0; i<levers.length; i++) {
+ if(!levers[i].isToggled())
+ return false;
+ }
+ ScriptEngineManager factory = new ScriptEngineManager();
+ ScriptEngine engine = factory.getEngineByName("JavaScript");
+ try {
+ return (boolean)engine.eval(rounds.replace("%round%", ""+round));
+ } catch (ScriptException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
|