diff --git a/.gitignore b/.gitignore
index cfc519678..d82c2f66d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -229,7 +229,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs
-# Including strong name files can present a security risk
+# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
@@ -324,7 +324,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/
-# Azure Stream Analytics local run output
+# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
@@ -343,4 +343,4 @@ persistence.json
src/main/resources/apps.methodscript.com/tsp-output
# VSCode
-.vscode
+.vscode/*
\ No newline at end of file
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 000000000..fdcbe4550
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,14 @@
+{
+ "recommendations": [
+ "redhat.java",
+ "shengchen.vscode-checkstyle",
+ "vscjava.vscode-java-debug",
+ "vscjava.vscode-java-dependency",
+ "vscjava.vscode-java-pack",
+ "vscjava.vscode-java-test",
+ "vscjava.vscode-maven",
+ ],
+ "unwantedRecommendations": [
+
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/java-formatter.xml b/.vscode/java-formatter.xml
new file mode 100644
index 000000000..a6dbda7f6
--- /dev/null
+++ b/.vscode/java-formatter.xml
@@ -0,0 +1,382 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 000000000..07efae992
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,13 @@
+{
+ "java.compile.nullAnalysis.mode": "automatic",
+ "java.checkstyle.configuration": "${workspaceFolder}/checkstyle.xml",
+ "java.checkstyle.properties": {
+ "config_loc": "${workspaceFolder}",
+ },
+ "java.checkstyle.autocheck": true,
+ "java.format.settings.url": ".vscode/java-formatter.xml",
+ "[java]": {
+ "editor.insertSpaces": false
+ },
+ "files.trimTrailingWhitespace": true,
+}
\ No newline at end of file
diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitEntityEvents.java b/src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitEntityEvents.java
index c79bddaf7..d5ec808a7 100644
--- a/src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitEntityEvents.java
+++ b/src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitEntityEvents.java
@@ -62,6 +62,7 @@
import com.laytonsmith.abstraction.events.MCEntityRegainHealthEvent;
import com.laytonsmith.abstraction.events.MCEntityTargetEvent;
import com.laytonsmith.abstraction.events.MCEntityToggleGlideEvent;
+import com.laytonsmith.abstraction.events.MCEntityToggleSwimEvent;
import com.laytonsmith.abstraction.events.MCEntityUnleashEvent;
import com.laytonsmith.abstraction.events.MCEntityPotionEffectEvent;
import com.laytonsmith.abstraction.events.MCFireworkExplodeEvent;
@@ -102,6 +103,7 @@
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent;
+import org.bukkit.event.entity.EntityToggleSwimEvent;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.ItemDespawnEvent;
@@ -917,6 +919,36 @@ public MCEntityType getEntityType() {
}
}
+ @abstraction(type = Implementation.Type.BUKKIT)
+ public static class BukkitMCEntityToggleSwimEvent implements MCEntityToggleSwimEvent {
+
+ EntityToggleSwimEvent e;
+
+ public BukkitMCEntityToggleSwimEvent(Event e) {
+ this.e = (EntityToggleSwimEvent) e;
+ }
+
+ @Override
+ public Object _GetObject() {
+ return e;
+ }
+
+ @Override
+ public boolean isSwimming() {
+ return e.isSwimming();
+ }
+
+ @Override
+ public MCEntity getEntity() {
+ return BukkitConvertor.BukkitGetCorrectEntity(e.getEntity());
+ }
+
+ @Override
+ public MCEntityType getEntityType() {
+ return BukkitConvertor.BukkitGetCorrectEntity(e.getEntity()).getType();
+ }
+ }
+
@abstraction(type = Implementation.Type.BUKKIT)
public static class BukkitMCFireworkExplodeEvent implements MCFireworkExplodeEvent {
diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/events/drivers/BukkitEntityListener.java b/src/main/java/com/laytonsmith/abstraction/bukkit/events/drivers/BukkitEntityListener.java
index 963834f0d..b0f649b2d 100644
--- a/src/main/java/com/laytonsmith/abstraction/bukkit/events/drivers/BukkitEntityListener.java
+++ b/src/main/java/com/laytonsmith/abstraction/bukkit/events/drivers/BukkitEntityListener.java
@@ -12,6 +12,7 @@
import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents.BukkitMCEntityPortalEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents.BukkitMCEntityRegainHealthEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents.BukkitMCEntityToggleGlideEvent;
+import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents.BukkitMCEntityToggleSwimEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents.BukkitMCEntityUnleashEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents.BukkitMCFireworkExplodeEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitEntityEvents.BukkitMCHangingBreakEvent;
@@ -48,6 +49,7 @@
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent;
+import org.bukkit.event.entity.EntityToggleSwimEvent;
import org.bukkit.event.entity.EntityUnleashEvent;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.FireworkExplodeEvent;
@@ -200,6 +202,12 @@ public void onEntityToggleGlide(EntityToggleGlideEvent event) {
EventUtils.TriggerListener(Driver.ENTITY_TOGGLE_GLIDE, "entity_toggle_glide", etge);
}
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onEntityToggleSwim(EntityToggleSwimEvent event) {
+ BukkitMCEntityToggleSwimEvent etse = new BukkitMCEntityToggleSwimEvent(event);
+ EventUtils.TriggerListener(Driver.ENTITY_TOGGLE_SWIM, "entity_toggle_swim", etse);
+ }
+
@EventHandler(priority = EventPriority.LOWEST)
public void onFireworkExplode(FireworkExplodeEvent event) {
BukkitMCFireworkExplodeEvent fee = new BukkitMCFireworkExplodeEvent(event);
diff --git a/src/main/java/com/laytonsmith/abstraction/events/MCEntityEvent.java b/src/main/java/com/laytonsmith/abstraction/events/MCEntityEvent.java
new file mode 100644
index 000000000..9547bf113
--- /dev/null
+++ b/src/main/java/com/laytonsmith/abstraction/events/MCEntityEvent.java
@@ -0,0 +1,12 @@
+package com.laytonsmith.abstraction.events;
+
+import com.laytonsmith.abstraction.MCEntity;
+import com.laytonsmith.abstraction.enums.MCEntityType;
+import com.laytonsmith.core.events.BindableEvent;
+
+public interface MCEntityEvent extends BindableEvent {
+
+ MCEntity getEntity();
+
+ MCEntityType getEntityType();
+}
diff --git a/src/main/java/com/laytonsmith/abstraction/events/MCEntityToggleSwimEvent.java b/src/main/java/com/laytonsmith/abstraction/events/MCEntityToggleSwimEvent.java
new file mode 100644
index 000000000..7d9a553f2
--- /dev/null
+++ b/src/main/java/com/laytonsmith/abstraction/events/MCEntityToggleSwimEvent.java
@@ -0,0 +1,7 @@
+package com.laytonsmith.abstraction.events;
+
+
+public interface MCEntityToggleSwimEvent extends MCEntityEvent {
+
+ boolean isSwimming();
+}
diff --git a/src/main/java/com/laytonsmith/core/events/Driver.java b/src/main/java/com/laytonsmith/core/events/Driver.java
index b2ae7b853..752816833 100644
--- a/src/main/java/com/laytonsmith/core/events/Driver.java
+++ b/src/main/java/com/laytonsmith/core/events/Driver.java
@@ -54,6 +54,7 @@ public enum Driver {
PROJECTILE_LAUNCH,
TARGET_ENTITY,
ENTITY_TOGGLE_GLIDE,
+ ENTITY_TOGGLE_SWIM,
FIREWORK_EXPLODE,
/**
* Inventory events
diff --git a/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java
index 1b251cc25..847535e33 100644
--- a/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java
+++ b/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java
@@ -39,6 +39,7 @@
import com.laytonsmith.abstraction.events.MCEntityRegainHealthEvent;
import com.laytonsmith.abstraction.events.MCEntityTargetEvent;
import com.laytonsmith.abstraction.events.MCEntityToggleGlideEvent;
+import com.laytonsmith.abstraction.events.MCEntityToggleSwimEvent;
import com.laytonsmith.abstraction.events.MCEntityUnleashEvent;
import com.laytonsmith.abstraction.events.MCEntityPotionEffectEvent;
import com.laytonsmith.abstraction.events.MCFireworkExplodeEvent;
@@ -68,6 +69,7 @@
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.environments.Environment;
import com.laytonsmith.core.events.AbstractEvent;
+import com.laytonsmith.core.events.AbstractGenericEvent;
import com.laytonsmith.core.events.BindableEvent;
import com.laytonsmith.core.events.BoundEvent;
import com.laytonsmith.core.events.BoundEvent.ActiveEvent;
@@ -75,6 +77,9 @@
import com.laytonsmith.core.events.EventBuilder;
import com.laytonsmith.core.events.Prefilters;
import com.laytonsmith.core.events.Prefilters.PrefilterType;
+import com.laytonsmith.core.events.prefilters.OptionalPlayerPrefilterMatcher;
+import com.laytonsmith.core.events.prefilters.PrefilterBuilder;
+import com.laytonsmith.core.events.prefilters.StringICPrefilterMatcher;
import com.laytonsmith.core.exceptions.CRE.CREBadEntityException;
import com.laytonsmith.core.exceptions.CRE.CREBindException;
import com.laytonsmith.core.exceptions.CRE.CRECastException;
@@ -2053,6 +2058,99 @@ public Driver driver() {
}
}
+ @api
+ public static class entity_toggle_swim extends AbstractGenericEvent {
+
+ @Override
+ public String getName() {
+ return "entity_toggle_swim";
+ }
+
+ @Override
+ public String docs() {
+ return "{type: The entity type of the entity | id: The entity id of the entity"
+ + " | player: The player triggering the event}"
+ + " This event is called when an entity's swimming status is toggled"
+ + " {id: The entityID of the entity | type: The entity type of the entity |"
+ + " swimming: true if the entity is entering swimming mode, false if the entity is leaving it |"
+ + " player: If the entity is a player, this will contain their name, otherwise null}" + " {}"
+ + " {}";
+ }
+
+
+ @Override
+ protected PrefilterBuilder getPrefilterBuilder() {
+ return new PrefilterBuilder()
+ .set("player", "The player that toggled swimming", new OptionalPlayerPrefilterMatcher<>())
+ .set("type", "The entity type of the entity that toggled swimming", new StringICPrefilterMatcher<>() {
+ @Override
+ protected String getProperty(MCEntityToggleSwimEvent event) {
+ return event.getEntityType().name();
+ }
+ })
+ .set("id", "The ID of the entity that toggled swimming", new StringICPrefilterMatcher<>() {
+ @Override
+ protected String getProperty(MCEntityToggleSwimEvent event) {
+ return event.getEntity().getUniqueId().toString();
+ }
+ });
+ }
+
+ @Override
+ public MCEntityToggleSwimEvent convert(CArray manualObject, Target t) {
+ return null;
+ }
+
+ @Override
+ public Map evaluate(MCEntityToggleSwimEvent e) throws EventException {
+ Map ret = evaluate_helper(e);
+ Target t = Target.UNKNOWN;
+
+ ret.put("swimming", CBoolean.GenerateCBoolean(e.isSwimming(), t));
+ ret.put("id", new CString(e.getEntity().getUniqueId().toString(), t));
+ ret.put("type", new CString(e.getEntityType().name(), t));
+
+ if(e.getEntity() instanceof MCPlayer) {
+ ret.put("player", new CString(((MCPlayer) e.getEntity()).getName(), t));
+ } else {
+ ret.put("player", CNull.NULL);
+ }
+
+ return ret;
+ }
+
+ @Override
+ public boolean modifyEvent(String key, Mixed value, MCEntityToggleSwimEvent event) throws ConfigRuntimeException {
+ return false;
+ }
+
+ @Override
+ public Version since() {
+ return MSVersion.V3_3_5;
+ }
+
+ @Override
+ public Driver driver() {
+ return Driver.ENTITY_TOGGLE_SWIM;
+ }
+
+ @Override
+ public void cancel(MCEntityToggleSwimEvent o, boolean state) {
+ }
+
+ @Override
+ public boolean isCancellable(MCEntityToggleSwimEvent o) {
+ // Deprecated
+ // https://jd.papermc.io/paper/1.21.5/org/bukkit/event/entity/EntityToggleSwimEvent.html#setCancelled(boolean)
+ return false;
+ }
+
+ @Override
+ public boolean isCancelled(MCEntityToggleSwimEvent o) {
+ return false;
+ }
+ }
+
@api
public static class firework_explode extends AbstractEvent {
diff --git a/src/main/java/com/laytonsmith/core/events/prefilters/OptionalPlayerPrefilterMatcher.java b/src/main/java/com/laytonsmith/core/events/prefilters/OptionalPlayerPrefilterMatcher.java
new file mode 100644
index 000000000..bdc14fd06
--- /dev/null
+++ b/src/main/java/com/laytonsmith/core/events/prefilters/OptionalPlayerPrefilterMatcher.java
@@ -0,0 +1,62 @@
+package com.laytonsmith.core.events.prefilters;
+
+import com.laytonsmith.abstraction.MCEntity;
+import com.laytonsmith.abstraction.MCPlayer;
+import com.laytonsmith.abstraction.events.MCEntityEvent;
+import com.laytonsmith.core.ParseTree;
+import com.laytonsmith.core.compiler.CompilerEnvironment;
+import com.laytonsmith.core.compiler.CompilerWarning;
+import com.laytonsmith.core.constructs.CClassType;
+import com.laytonsmith.core.constructs.CNull;
+import com.laytonsmith.core.constructs.CString;
+import com.laytonsmith.core.constructs.Target;
+import com.laytonsmith.core.environments.Environment;
+import com.laytonsmith.core.events.prefilters.PlayerPrefilterMatcher.PlayerPrefilterDocs;
+import com.laytonsmith.core.exceptions.ConfigCompileException;
+import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
+import com.laytonsmith.core.exceptions.ConfigRuntimeException;
+import com.laytonsmith.core.natives.interfaces.Mixed;
+
+/**
+ * A OptionalPlayerPrefilterMatcher is a relatively specialized PrefilterMatcher which only works with MCEntityEvent subtypes.
+ * It simply checks that entity is a player and matches the player name against the specified input.
+ *
+ * @param
+ */
+public class OptionalPlayerPrefilterMatcher extends MacroICPrefilterMatcher {
+
+ @Override
+ public PrefilterDocs getDocsObject() {
+ return new PlayerPrefilterDocs();
+ }
+
+ @Override
+ public void validate(ParseTree node, CClassType nodeType, Environment env)
+ throws ConfigCompileException, ConfigCompileGroupException, ConfigRuntimeException {
+ if(!nodeType.doesExtend(CString.TYPE)) {
+ env.getEnv(CompilerEnvironment.class).addCompilerWarning(node.getFileOptions(),
+ new CompilerWarning("Expected a string (player) here, this may not perform as expected.",
+ node.getTarget(), null));
+ }
+ }
+
+ @Override
+ public boolean matches(String key, Mixed value, T event, Target t) {
+ Object prop = getProperty(event);
+ if(prop == null) {
+ return CNull.NULL.equals(value);
+ }
+
+ return super.matches(key, value, event, t);
+ }
+
+ @Override
+ protected Object getProperty(T event) {
+ MCEntity entity = event.getEntity();
+ if(entity instanceof MCPlayer player) {
+ return player.getName();
+ }
+
+ return null;
+ }
+}