|
@@ -9,6 +9,7 @@ import java.util.function.Consumer;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import me.hammerle.code.Code;
|
|
import me.hammerle.code.Code;
|
|
import me.hammerle.code.Script;
|
|
import me.hammerle.code.Script;
|
|
|
|
+import me.hammerle.code.ScriptUtils;
|
|
import me.hammerle.code.SnuviParser;
|
|
import me.hammerle.code.SnuviParser;
|
|
import me.hammerle.exceptions.SnuviException;
|
|
import me.hammerle.exceptions.SnuviException;
|
|
import me.km.KajetansMod;
|
|
import me.km.KajetansMod;
|
|
@@ -138,9 +139,11 @@ public class ScriptEvents extends ModuleListener
|
|
public void onPlayerMove(PlayerMoveEvent e)
|
|
public void onPlayerMove(PlayerMoveEvent e)
|
|
{
|
|
{
|
|
EntityPlayer p = e.getEntityPlayer();
|
|
EntityPlayer p = e.getEntityPlayer();
|
|
|
|
+ Location l = new Location(p);
|
|
|
|
+ l.round();
|
|
parser.getScripts().stream().filter(sc -> sc.isLoadedEvent("player_move")).forEach(sc ->
|
|
parser.getScripts().stream().filter(sc -> sc.isLoadedEvent("player_move")).forEach(sc ->
|
|
{
|
|
{
|
|
- if(((MinecraftScript) sc).removeLocation(new Location(p)))
|
|
|
|
|
|
+ if(((MinecraftScript) sc).removeLocation(l))
|
|
{
|
|
{
|
|
ScriptVars.setPlayerVars(sc, p);
|
|
ScriptVars.setPlayerVars(sc, p);
|
|
parser.callEvent("player_move", sc, null, null);
|
|
parser.callEvent("player_move", sc, null, null);
|
|
@@ -148,7 +151,7 @@ public class ScriptEvents extends ModuleListener
|
|
});
|
|
});
|
|
|
|
|
|
PlayerScript sc = KajetansMod.scripts.getScript(p);
|
|
PlayerScript sc = KajetansMod.scripts.getScript(p);
|
|
- if(sc != null && sc.isLoadedEvent("player_move") && sc.removeLocation(new Location(p)))
|
|
|
|
|
|
+ if(sc != null && sc.isLoadedEvent("player_move") && sc.removeLocation(l))
|
|
{
|
|
{
|
|
ScriptVars.setPlayerVars(sc, p);
|
|
ScriptVars.setPlayerVars(sc, p);
|
|
parser.callEvent("player_move", sc, null, null);
|
|
parser.callEvent("player_move", sc, null, null);
|
|
@@ -160,9 +163,9 @@ public class ScriptEvents extends ModuleListener
|
|
parser.callEvent("inv_click", qd, sc ->
|
|
parser.callEvent("inv_click", qd, sc ->
|
|
{
|
|
{
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
- qd.setEventVar("inv_id", inv.getId());
|
|
|
|
|
|
+ qd.setEventVar("inv_id", (double) inv.getId());
|
|
qd.setEventVar("inv_name", inv.getName());
|
|
qd.setEventVar("inv_name", inv.getName());
|
|
- qd.setEventVar("inv_slot", slot);
|
|
|
|
|
|
+ qd.setEventVar("inv_slot", (double) slot);
|
|
ScriptVars.setItemVars(qd, inv.getStackInSlot(slot));
|
|
ScriptVars.setItemVars(qd, inv.getStackInSlot(slot));
|
|
qd.setVar("cancel", false);
|
|
qd.setVar("cancel", false);
|
|
}, null);
|
|
}, null);
|
|
@@ -174,7 +177,7 @@ public class ScriptEvents extends ModuleListener
|
|
parser.callEvent("inv_close", qd, sc ->
|
|
parser.callEvent("inv_close", qd, sc ->
|
|
{
|
|
{
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
- qd.setEventVar("inv_id", inv.getId());
|
|
|
|
|
|
+ qd.setEventVar("inv_id", (double) inv.getId());
|
|
qd.setEventVar("inv_name", inv.getName());
|
|
qd.setEventVar("inv_name", inv.getName());
|
|
qd.setVar("cancel", false);
|
|
qd.setVar("cancel", false);
|
|
}, null);
|
|
}, null);
|
|
@@ -186,8 +189,8 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(e.getEntityPlayer(), "player_respawn", (qd) ->
|
|
handleEvent(e.getEntityPlayer(), "player_respawn", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("keep_inventory", e.isInventoryKeepingForced());
|
|
|
|
- qd.setVar("respawn_loc", new Location(e.getWorld(), e.getRespawnLoc()));
|
|
|
|
|
|
+ qd.setEventVar("keep_inventory", e.isInventoryKeepingForced());
|
|
|
|
+ qd.setEventVar("respawn_loc", new Location(e.getWorld(), e.getRespawnLoc()));
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -212,23 +215,23 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
if(p.getHealth() <= e.getAmount())
|
|
if(p.getHealth() <= e.getAmount())
|
|
{
|
|
{
|
|
- qd.setVar("player_killed", true);
|
|
|
|
|
|
+ qd.setEventVar("player_killed", true);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- qd.setVar("player_killed", false);
|
|
|
|
|
|
+ qd.setEventVar("player_killed", false);
|
|
}
|
|
}
|
|
- qd.setVar("player_damage", e.getAmount());
|
|
|
|
- qd.setVar("player_damage_cause", e.getSource().getDamageType());
|
|
|
|
|
|
+ qd.setEventVar("player_damage", (double) e.getAmount());
|
|
|
|
+ qd.setEventVar("player_damage_cause", e.getSource().getDamageType());
|
|
EntityPlayer ent = Utils.getDamager(e.getSource());
|
|
EntityPlayer ent = Utils.getDamager(e.getSource());
|
|
if(ent != null)
|
|
if(ent != null)
|
|
{
|
|
{
|
|
- qd.setVar("player_involved", true);
|
|
|
|
|
|
+ qd.setEventVar("player_involved", true);
|
|
ScriptVars.setSecPlayer(qd, ent);
|
|
ScriptVars.setSecPlayer(qd, ent);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- qd.setVar("player_involved", false);
|
|
|
|
|
|
+ qd.setEventVar("player_involved", false);
|
|
}
|
|
}
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -249,12 +252,12 @@ public class ScriptEvents extends ModuleListener
|
|
EntityPlayer p = Utils.getDamager(e.getSource());
|
|
EntityPlayer p = Utils.getDamager(e.getSource());
|
|
if(p != null)
|
|
if(p != null)
|
|
{
|
|
{
|
|
- qd.setVar("player_involved", true);
|
|
|
|
|
|
+ qd.setEventVar("player_involved", true);
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- qd.setVar("player_involved", false);
|
|
|
|
|
|
+ qd.setEventVar("player_involved", false);
|
|
}
|
|
}
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -266,8 +269,8 @@ public class ScriptEvents extends ModuleListener
|
|
EntityPlayer p = (EntityPlayer) e.getEntity();
|
|
EntityPlayer p = (EntityPlayer) e.getEntity();
|
|
handleEvent(p, "player_death", (qd) ->
|
|
handleEvent(p, "player_death", (qd) ->
|
|
{
|
|
{
|
|
- //qd.setVar("message", e.getDeathMessage());
|
|
|
|
- qd.setVar("clear", false);
|
|
|
|
|
|
+ //qd.setEventVar("message", e.getDeathMessage());
|
|
|
|
+ qd.setEventVar("clear", false);
|
|
EntityPlayer ent = Utils.getDamager(e.getSource());
|
|
EntityPlayer ent = Utils.getDamager(e.getSource());
|
|
if(ent != null)
|
|
if(ent != null)
|
|
{
|
|
{
|
|
@@ -295,10 +298,10 @@ public class ScriptEvents extends ModuleListener
|
|
}
|
|
}
|
|
handleEvent(p, "entity_hurt", (qd) ->
|
|
handleEvent(p, "entity_hurt", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("entity_killed", e.getEntityLiving().getHealth() <= e.getAmount());
|
|
|
|
|
|
+ qd.setEventVar("entity_killed", e.getEntityLiving().getHealth() <= e.getAmount());
|
|
ScriptVars.setEntityVars(qd, e.getEntity());
|
|
ScriptVars.setEntityVars(qd, e.getEntity());
|
|
- qd.setVar("entity_damage", e.getAmount());
|
|
|
|
- qd.setVar("entity_damage_cause", e.getSource().getDamageType());
|
|
|
|
|
|
+ qd.setEventVar("entity_damage", (double) e.getAmount());
|
|
|
|
+ qd.setEventVar("entity_damage_cause", e.getSource().getDamageType());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
@@ -313,17 +316,17 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(null, "entity_drop", (qd) ->
|
|
handleEvent(null, "entity_drop", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("drops", e.getDrops());
|
|
|
|
|
|
+ qd.setEventVar("drops", e.getDrops());
|
|
ScriptVars.setEntityVars(qd, e.getEntityLiving());
|
|
ScriptVars.setEntityVars(qd, e.getEntityLiving());
|
|
EntityPlayer p = Utils.getDamager(e.getSource());
|
|
EntityPlayer p = Utils.getDamager(e.getSource());
|
|
if(p != null)
|
|
if(p != null)
|
|
{
|
|
{
|
|
- qd.setVar("player_involved", true);
|
|
|
|
|
|
+ qd.setEventVar("player_involved", true);
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
ScriptVars.setPlayerVars(qd, p);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- qd.setVar("player_involved", false);
|
|
|
|
|
|
+ qd.setEventVar("player_involved", false);
|
|
}
|
|
}
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -359,12 +362,12 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
if(e.getRayTraceResult().entityHit != null)
|
|
if(e.getRayTraceResult().entityHit != null)
|
|
{
|
|
{
|
|
- qd.setVar("is_entity_hit", true);
|
|
|
|
- qd.setVar("entity_hit", e.getRayTraceResult().entityHit);
|
|
|
|
|
|
+ qd.setEventVar("is_entity_hit", true);
|
|
|
|
+ qd.setEventVar("entity_hit", e.getRayTraceResult().entityHit);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- qd.setVar("is_entity_hit", false);
|
|
|
|
|
|
+ qd.setEventVar("is_entity_hit", false);
|
|
}
|
|
}
|
|
ScriptVars.setEntityVars(qd, e.getEntityThrowable());
|
|
ScriptVars.setEntityVars(qd, e.getEntityThrowable());
|
|
});
|
|
});
|
|
@@ -376,7 +379,7 @@ public class ScriptEvents extends ModuleListener
|
|
handleEvent(p, "item_hit", (qd) ->
|
|
handleEvent(p, "item_hit", (qd) ->
|
|
{
|
|
{
|
|
ScriptVars.setItemVars(qd, stack);
|
|
ScriptVars.setItemVars(qd, stack);
|
|
- qd.setVar("entities", ents);
|
|
|
|
|
|
+ qd.setEventVar("entities", ents);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -396,8 +399,8 @@ public class ScriptEvents extends ModuleListener
|
|
handleEvent(p, "entity_shear", (qd) ->
|
|
handleEvent(p, "entity_shear", (qd) ->
|
|
{
|
|
{
|
|
ScriptVars.setEntityVars(qd, sheep);
|
|
ScriptVars.setEntityVars(qd, sheep);
|
|
- qd.setVar("entity_sheared", sheep.getSheared());
|
|
|
|
- qd.setVar("entity_color", sheep.getFleeceColor().toString());
|
|
|
|
|
|
+ qd.setEventVar("entity_sheared", sheep.getSheared());
|
|
|
|
+ qd.setEventVar("entity_color", sheep.getFleeceColor().toString());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
@@ -429,10 +432,10 @@ public class ScriptEvents extends ModuleListener
|
|
}
|
|
}
|
|
handleEvent(p, "player_login", (qd) ->
|
|
handleEvent(p, "player_login", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("first_join", Utils.hasPlayedBefore(p));
|
|
|
|
|
|
+ qd.setEventVar("first_join", Utils.hasPlayedBefore(p));
|
|
PlayerList list = KajetansMod.server.getPlayerList();
|
|
PlayerList list = KajetansMod.server.getPlayerList();
|
|
- qd.setVar("is_banned", list.getBannedPlayers().isBanned(p.getGameProfile()));
|
|
|
|
- qd.setVar("is_whitelisted", list.getWhitelistedPlayers().isWhitelisted(p.getGameProfile()));
|
|
|
|
|
|
+ qd.setEventVar("is_banned", list.getBannedPlayers().isBanned(p.getGameProfile()));
|
|
|
|
+ qd.setEventVar("is_whitelisted", list.getWhitelistedPlayers().isWhitelisted(p.getGameProfile()));
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -442,8 +445,8 @@ public class ScriptEvents extends ModuleListener
|
|
EntityPlayer p = e.getEntityPlayer();
|
|
EntityPlayer p = e.getEntityPlayer();
|
|
handleEvent(p, "player_join_server", (qd) ->
|
|
handleEvent(p, "player_join_server", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("message", e.getMessage());
|
|
|
|
- qd.setVar("changed_name", e.hasNameChanged());
|
|
|
|
|
|
+ qd.setEventVar("message", e.getMessage());
|
|
|
|
+ qd.setEventVar("changed_name", e.hasNameChanged());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
@@ -458,7 +461,7 @@ public class ScriptEvents extends ModuleListener
|
|
EntityPlayer p = e.getEntityPlayer();
|
|
EntityPlayer p = e.getEntityPlayer();
|
|
handleEvent(p, "player_leave", (qd) ->
|
|
handleEvent(p, "player_leave", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("message", e.getMessage());
|
|
|
|
|
|
+ qd.setEventVar("message", e.getMessage());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
@@ -478,17 +481,17 @@ public class ScriptEvents extends ModuleListener
|
|
BlockPos pos = ray.getBlockPos();
|
|
BlockPos pos = ray.getBlockPos();
|
|
if(pos != null)
|
|
if(pos != null)
|
|
{
|
|
{
|
|
- qd.setVar("has_block", true);
|
|
|
|
|
|
+ qd.setEventVar("has_block", true);
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), pos);
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), pos);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- qd.setVar("has_block", false);
|
|
|
|
|
|
+ qd.setEventVar("has_block", false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- qd.setVar("has_block", false);
|
|
|
|
|
|
+ qd.setEventVar("has_block", false);
|
|
}
|
|
}
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -502,7 +505,7 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(e.getPlayer(), "block_place", (qd) ->
|
|
handleEvent(e.getPlayer(), "block_place", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("block_type_after", e.getPlacedBlock().getBlock().getRegistryName());
|
|
|
|
|
|
+ qd.setEventVar("block_type_after", e.getPlacedBlock().getBlock().getRegistryName());
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), e.getPos());
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), e.getPos());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -520,7 +523,7 @@ public class ScriptEvents extends ModuleListener
|
|
}
|
|
}
|
|
handleEvent(e.getEntityPlayer(), "block_click", (qd) ->
|
|
handleEvent(e.getEntityPlayer(), "block_click", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("action", "right");
|
|
|
|
|
|
+ qd.setEventVar("action", "right");
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), e.getPos());
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), e.getPos());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -538,7 +541,7 @@ public class ScriptEvents extends ModuleListener
|
|
}
|
|
}
|
|
handleEvent(e.getEntityPlayer(), "block_click", (qd) ->
|
|
handleEvent(e.getEntityPlayer(), "block_click", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("action", "left");
|
|
|
|
|
|
+ qd.setEventVar("action", "left");
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), e.getPos());
|
|
ScriptVars.setBlockVars(qd, e.getWorld(), e.getPos());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -568,7 +571,7 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(e.getEntityPlayer(), "fishing", (qd) ->
|
|
handleEvent(e.getEntityPlayer(), "fishing", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("drops", e.getDrops());
|
|
|
|
|
|
+ qd.setEventVar("drops", e.getDrops());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
@@ -582,7 +585,7 @@ public class ScriptEvents extends ModuleListener
|
|
handleEvent(e.getEntityPlayer(), "item_air_click", (qd) ->
|
|
handleEvent(e.getEntityPlayer(), "item_air_click", (qd) ->
|
|
{
|
|
{
|
|
ScriptVars.setItemVars(qd, e.getItemStack());
|
|
ScriptVars.setItemVars(qd, e.getItemStack());
|
|
- qd.setVar("hand", e.getHand().toString());
|
|
|
|
|
|
+ qd.setEventVar("hand", e.getHand().toString());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
@@ -594,7 +597,7 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(p, "arm_swing", (qd) ->
|
|
handleEvent(p, "arm_swing", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("hand", hand);
|
|
|
|
|
|
+ qd.setEventVar("hand", hand);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -607,14 +610,14 @@ public class ScriptEvents extends ModuleListener
|
|
}
|
|
}
|
|
handleEvent((EntityPlayer) e.getEntityLiving(), "item_use_start", (qd) ->
|
|
handleEvent((EntityPlayer) e.getEntityLiving(), "item_use_start", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("duration", e.getDuration());
|
|
|
|
|
|
+ qd.setEventVar("duration", (double) e.getDuration());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
e.setCanceled(qd.getBooleanVar("cancel"));
|
|
e.setCanceled(qd.getBooleanVar("cancel"));
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- e.setDuration((int) qd.getVar("duration"));
|
|
|
|
|
|
+ e.setDuration(ScriptUtils.getInt(qd.getVar("duration")));
|
|
}
|
|
}
|
|
catch(Exception ex)
|
|
catch(Exception ex)
|
|
{
|
|
{
|
|
@@ -632,7 +635,7 @@ public class ScriptEvents extends ModuleListener
|
|
}
|
|
}
|
|
handleEvent((EntityPlayer) e.getEntityLiving(), "item_use_finish", (qd) ->
|
|
handleEvent((EntityPlayer) e.getEntityLiving(), "item_use_finish", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("result_stack", e.getResultStack());
|
|
|
|
|
|
+ qd.setEventVar("result_stack", e.getResultStack());
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -681,7 +684,7 @@ public class ScriptEvents extends ModuleListener
|
|
EntityPlayer p = (EntityPlayer) e.getEntityMounting();
|
|
EntityPlayer p = (EntityPlayer) e.getEntityMounting();
|
|
handleEvent(p, "entity_mount", (qd) ->
|
|
handleEvent(p, "entity_mount", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("mounting", e.isMounting());
|
|
|
|
|
|
+ qd.setEventVar("mounting", e.isMounting());
|
|
ScriptVars.setEntityVars(qd, e.getEntityBeingMounted());
|
|
ScriptVars.setEntityVars(qd, e.getEntityBeingMounted());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
@@ -695,8 +698,8 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(e.player, "portal", (qd) ->
|
|
handleEvent(e.player, "portal", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("from", ModDimensions.getWorldName(e.fromDim));
|
|
|
|
- qd.setVar("to", ModDimensions.getWorldName(e.toDim));
|
|
|
|
|
|
+ qd.setEventVar("from", ModDimensions.getWorldName(e.fromDim));
|
|
|
|
+ qd.setEventVar("to", ModDimensions.getWorldName(e.toDim));
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -707,8 +710,8 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent((EntityPlayer) e.getSender(), "command", (qd) ->
|
|
handleEvent((EntityPlayer) e.getSender(), "command", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("command", e.getCommand().getName());
|
|
|
|
- qd.setVar("args", Arrays.stream(e.getParameters()).map(s -> Code.convertInput(s, false)).collect(Collectors.toList()));
|
|
|
|
|
|
+ qd.setEventVar("command", e.getCommand().getName());
|
|
|
|
+ qd.setEventVar("args", Arrays.stream(e.getParameters()).map(s -> Code.convertInput(s, false)).collect(Collectors.toList()));
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
@@ -721,13 +724,13 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(p, "custom_command", (qd) ->
|
|
handleEvent(p, "custom_command", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("command", command);
|
|
|
|
|
|
+ qd.setEventVar("command", command);
|
|
if(args.length() == 0)
|
|
if(args.length() == 0)
|
|
{
|
|
{
|
|
- qd.setVar("args", new ArrayList<>());
|
|
|
|
|
|
+ qd.setEventVar("args", new ArrayList<>());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- qd.setVar("args", Arrays.stream(args.trim().split(" ")).map(s -> Code.convertInput(s, false)).collect(Collectors.toList()));
|
|
|
|
|
|
+ qd.setEventVar("args", Arrays.stream(args.trim().split(" ")).map(s -> Code.convertInput(s, false)).collect(Collectors.toList()));
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -735,16 +738,16 @@ public class ScriptEvents extends ModuleListener
|
|
{
|
|
{
|
|
handleEvent(e.getPlayer(), "player_use_effect", (qd) ->
|
|
handleEvent(e.getPlayer(), "player_use_effect", (qd) ->
|
|
{
|
|
{
|
|
- qd.setVar("power", e.getPower());
|
|
|
|
- qd.setVar("mana_cost", e.getMana());
|
|
|
|
- qd.setVar("cause", e.getCause().toString());
|
|
|
|
- qd.setVar("effect", e.getEffect());
|
|
|
|
|
|
+ qd.setEventVar("power", (double) e.getPower());
|
|
|
|
+ qd.setEventVar("mana_cost", (double) e.getMana());
|
|
|
|
+ qd.setEventVar("cause", e.getCause().toString());
|
|
|
|
+ qd.setEventVar("effect", e.getEffect());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
qd.setVar("cancel", e.isCanceled());
|
|
}, (qd) ->
|
|
}, (qd) ->
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- int power = (int) qd.getVar("power");
|
|
|
|
|
|
+ int power = ScriptUtils.getInt(qd.getVar("power"));
|
|
if(power < 1 || power > 20)
|
|
if(power < 1 || power > 20)
|
|
{
|
|
{
|
|
throw new IllegalArgumentException();
|
|
throw new IllegalArgumentException();
|
|
@@ -757,7 +760,7 @@ public class ScriptEvents extends ModuleListener
|
|
}
|
|
}
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- int mana = (int) qd.getVar("mana_cost");
|
|
|
|
|
|
+ int mana = ScriptUtils.getInt(qd.getVar("mana_cost"));
|
|
if(mana < 0)
|
|
if(mana < 0)
|
|
{
|
|
{
|
|
throw new IllegalArgumentException();
|
|
throw new IllegalArgumentException();
|
|
@@ -801,8 +804,8 @@ public class ScriptEvents extends ModuleListener
|
|
data.setVar("event", "villager_give");
|
|
data.setVar("event", "villager_give");
|
|
ScriptVars.setPlayerVars(data, p);
|
|
ScriptVars.setPlayerVars(data, p);
|
|
ScriptVars.setItemVars(data, itemEnt.getItem());
|
|
ScriptVars.setItemVars(data, itemEnt.getItem());
|
|
- data.setVar("villager_loc", new Location(v));
|
|
|
|
- data.setVar("villager_prof", v.getProfessionForge().getRegistryName());
|
|
|
|
|
|
+ data.setEventVar("villager_loc", new Location(v));
|
|
|
|
+ data.setEventVar("villager_prof", v.getProfessionForge().getRegistryName());
|
|
data.setVar("cancel", e.isCanceled());
|
|
data.setVar("cancel", e.isCanceled());
|
|
data.runCode();
|
|
data.runCode();
|
|
if(data.getBooleanVar("cancel"))
|
|
if(data.getBooleanVar("cancel"))
|