summaryrefslogtreecommitdiff
path: root/src/main/java/com/encrox/zombie/Mob.java
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2022-04-25 18:50:36 +0200
committerLeonard Kugis <leonard@kug.is>2022-04-25 18:50:36 +0200
commit9e2ddeb55321b09086a5a27254197d783847e6e3 (patch)
tree620e4a7b326df2a77fff51aff390e0a6bef43631 /src/main/java/com/encrox/zombie/Mob.java
Initial commitHEADmaster
Diffstat (limited to 'src/main/java/com/encrox/zombie/Mob.java')
-rwxr-xr-xsrc/main/java/com/encrox/zombie/Mob.java41
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;
+ }
+
+}