diff --git a/src/main/java/net/gravitydevelopment/anticheat/util/Utilities.java b/src/main/java/net/gravitydevelopment/anticheat/util/Utilities.java
index 59746cb..7a344b6 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/util/Utilities.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/util/Utilities.java
@@ -335,6 +335,21 @@ public final class Utilities {
}
}
+ /**
+ * Determine whether a String can be cast to a Double
+ *
+ * @param string text to check
+ * @return true if double
+ */
+ public static boolean isDouble(String string) {
+ try {
+ Double.parseDouble(string);
+ return true;
+ } catch (Exception ex) {
+ return false;
+ }
+ }
+
/**
* Calculate the time in milliseconds that it should take to break the given block with the given tool
*
diff --git a/src/main/java/net/gravitydevelopment/anticheat/util/rule/Rule.java b/src/main/java/net/gravitydevelopment/anticheat/util/rule/Rule.java
index 62261a9..75d10d4 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/util/rule/Rule.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/util/rule/Rule.java
@@ -23,6 +23,7 @@ import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Group;
import net.gravitydevelopment.anticheat.util.Utilities;
+import org.bukkit.GameMode;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
@@ -40,9 +41,26 @@ import java.util.TreeMap;
*
*
* Types of variables:
- * - Check: Contains all valid checks as listed in {@link net.gravitydevelopment.anticheat.check.CheckType}, and will return the number of times this user has failed the given check
- * - Player: Contains LEVEL, the player's current level and CHECK, the check that was just failed
- *
+ *
+ * - Check
+ *
+ * - Contains all valid checks as listed in {@link net.gravitydevelopment.anticheat.check.CheckType}
+ * - Will return the number of times this user has failed the given check
+ * - Example: Check_SPRINT
+ *
+ *
+ * - Player
+ *
+ * - Contains NAME, the name of the player
+ * - Contains LEVEL, the player's current level
+ * - Contains GROUP, the name of the player's current hack group
+ * - Contains CHECK, the check that was just failed
+ * - Contains GAMEMODE, the player's current Game Mode (Survival, Creative, Adventure)/li>
+ *
- Contains WORLD, the name of the world the player is in/li>
+ *
- Contains HEALTH, the player's current health/li>
+ *
+ *
+ *
*
* There are also functions you can use to execute an action within AntiCheat
* Functions are denoted with the type followed by a period followed by the function name.
@@ -142,6 +160,9 @@ public class Rule {
map.put("player_level", user.getLevel());
map.put("player_group", user.getGroup() != null ? user.getGroup().getName().toLowerCase() : "low");
map.put("player_name", user.getName().toLowerCase());
+ map.put("player_gamemode", user.getPlayer().getGameMode().toString());
+ map.put("player_world", user.getPlayer().getWorld().getName());
+ map.put("player_health", user.getPlayer().getHealth());
for (CheckType t : CheckType.values()) {
map.put("check_" + t.name().toLowerCase(), t.getUses(user.getName()));
}
@@ -157,6 +178,14 @@ public class Rule {
user.setLevel(group.getLevel());
}
}
+ } else if (variable.equals("player_gamemode")) {
+ try {
+ GameMode mode = GameMode.valueOf(value);
+ user.getPlayer().setGameMode(mode);
+ } catch (IllegalArgumentException ex) {
+ }
+ } else if (variable.equals("player_health") && Utilities.isDouble(value)) {
+ user.getPlayer().setHealth(Double.parseDouble(value));
}
}