|
@@ -1,574 +1,451 @@
|
|
|
package me.hammerle.kp.snuviscript;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.function.Consumer;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent;
|
|
|
+import org.bukkit.block.Block;
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
+import org.bukkit.entity.Entity;
|
|
|
+import org.bukkit.entity.Item;
|
|
|
+import org.bukkit.entity.LivingEntity;
|
|
|
import org.bukkit.entity.Player;
|
|
|
+import org.bukkit.event.Cancellable;
|
|
|
+import org.bukkit.event.block.*;
|
|
|
+import org.bukkit.event.entity.*;
|
|
|
+import org.bukkit.event.inventory.*;
|
|
|
+import org.bukkit.event.player.*;
|
|
|
+import org.bukkit.inventory.EquipmentSlot;
|
|
|
+import org.bukkit.inventory.Inventory;
|
|
|
+import org.bukkit.inventory.ItemStack;
|
|
|
+import org.spigotmc.event.entity.EntityMountEvent;
|
|
|
+import io.papermc.paper.event.player.PlayerArmSwingEvent;
|
|
|
import me.hammerle.kp.KajetansPlugin;
|
|
|
+import me.hammerle.kp.NMS;
|
|
|
+import me.hammerle.snuviscript.code.Script;
|
|
|
+import me.hammerle.snuviscript.code.SnuviUtils;
|
|
|
+import me.hammerle.snuviscript.inputprovider.Variable;
|
|
|
+import net.kyori.adventure.text.Component;
|
|
|
|
|
|
public class ScriptEvents {
|
|
|
- /*private static class WrappedBool {
|
|
|
- public boolean wrapped;
|
|
|
+ private static class WrappedBool {
|
|
|
+ public boolean wrapped = false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private static void setEntity(Script sc, Entity ent) {
|
|
|
+ sc.setVar("entity", ent);
|
|
|
+ }
|
|
|
+
|
|
|
private static void setLiving(Script sc, LivingEntity ent) {
|
|
|
sc.setVar("living_entity", ent);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private static void setItem(Script sc, ItemStack stack) {
|
|
|
sc.setVar("item", stack);
|
|
|
}
|
|
|
-
|
|
|
- private static void setPlayer(Script sc, PlayerEntity p) {
|
|
|
- sc.setVar("player", p);
|
|
|
+
|
|
|
+ private static void setItem(Script sc, Item stack) {
|
|
|
+ sc.setVar("item_entity", stack);
|
|
|
}
|
|
|
-
|
|
|
- @SuppressWarnings("")
|
|
|
- private static void setBlock(Script sc, World w, BlockPos pos, BlockState state) {
|
|
|
- sc.setVar("block_loc", new Location(w, pos));
|
|
|
- sc.setVar("block_type", state.getBlock().getRegistryName().toString());
|
|
|
- sc.setVar("block", state.getBlock());
|
|
|
+
|
|
|
+ private static void setPlayer(Script sc, Player p) {
|
|
|
+ sc.setVar("player", p);
|
|
|
}
|
|
|
-
|
|
|
- @SuppressWarnings("")
|
|
|
- private static void setBlock(Script sc, World w, BlockPos pos) {
|
|
|
- BlockState state = w.getBlockState(pos);
|
|
|
- sc.setVar("block_loc", new Location(w, pos));
|
|
|
- sc.setVar("block_type", state.getBlock().getRegistryName().toString());
|
|
|
- sc.setVar("block", state.getBlock());
|
|
|
+
|
|
|
+ private static void setCancel(Script sc, boolean b) {
|
|
|
+ sc.setVar("cancel", b);
|
|
|
}
|
|
|
-
|
|
|
- private static void setEntity(Script sc, Entity ent) {
|
|
|
- sc.setVar("entity", ent);
|
|
|
+
|
|
|
+ private static void setHand(Script sc, EquipmentSlot hand) {
|
|
|
+ sc.setVar("hand", hand);
|
|
|
}
|
|
|
-
|
|
|
- private static void nothing(Script sc) {}
|
|
|
-
|
|
|
- private void handleEvent(Event e, String event, Consumer<Script> before,
|
|
|
- Consumer<Script> after) {
|
|
|
- if(e.isCancelable()) {
|
|
|
- scripts.getScriptManager().callEvent(event, sc -> {
|
|
|
- before.accept(sc);
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, sc -> {
|
|
|
- after.accept(sc);
|
|
|
- handleVar(sc, event, "cancel", v -> e.setCanceled(v.getBoolean(sc)));
|
|
|
- });
|
|
|
- } else {
|
|
|
- scripts.getScriptManager().callEvent(event, before, after);
|
|
|
+
|
|
|
+ private static void setCancelled(Cancellable c, Script sc) {
|
|
|
+ Variable v = sc.getVar("cancel");
|
|
|
+ if(v == null) {
|
|
|
+ return;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- private void handleEvent(Event e, String event, Consumer<Script> before) {
|
|
|
- handleEvent(e, event, before, ScriptEvents::nothing);
|
|
|
- }
|
|
|
-
|
|
|
- private void handleEvent(String event, Consumer<Script> before, Consumer<Script> after) {
|
|
|
- scripts.getScriptManager().callEvent(event, before, after);
|
|
|
- }
|
|
|
-
|
|
|
- private void handleEvent(String event, Consumer<Script> before) {
|
|
|
- handleEvent(event, before, ScriptEvents::nothing);
|
|
|
- }
|
|
|
-
|
|
|
- private void handleVar(Script sc, String event, String name, Consumer<Variable> c) {
|
|
|
try {
|
|
|
- ifVarNotNull(sc, name, c);
|
|
|
+ c.setCancelled(v.getBoolean(sc));
|
|
|
} catch(Exception ex) {
|
|
|
- scripts.getLogger().print(String.format("invalid var in '%s' event", event), ex, null,
|
|
|
- sc.getName(), sc, sc.getStackTrace());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private void ifVarNotNull(Script sc, String name, Consumer<Variable> c) {
|
|
|
- Variable v = sc.getVar(name);
|
|
|
- if(v != null) {
|
|
|
- c.accept(v);
|
|
|
- }
|
|
|
+
|
|
|
+ private static void setBlock(Script sc, Block b) {
|
|
|
+ sc.setVar("block", b);
|
|
|
}
|
|
|
-
|
|
|
- private void simpleCancel(Script sc, Event e, String name) {
|
|
|
+
|
|
|
+ private static void nothing(Script sc) {}
|
|
|
+
|
|
|
+ private static void handleEvent(Cancellable e, String name, Consumer<Script> c) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent(name, sc -> {
|
|
|
+ c.accept(sc);
|
|
|
+ setCancel(sc, e.isCancelled());
|
|
|
+ }, sc -> {
|
|
|
+ setCancelled(e, sc);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void handleEvent(String name, Consumer<Script> c) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent(name, c, ScriptEvents::nothing);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void handleVar(Script sc, String event, String name, Consumer<Variable> c) {
|
|
|
try {
|
|
|
- ifVarNotNull(sc, "cancel", v -> e.setCanceled(v.getBoolean(sc)));
|
|
|
+ Variable v = sc.getVar(name);
|
|
|
+ if(v != null) {
|
|
|
+ c.accept(v);
|
|
|
+ }
|
|
|
} catch(Exception ex) {
|
|
|
- scripts.getLogger().print(String.format("invalid var in '%s' event", name), ex, null,
|
|
|
+ KajetansPlugin.logger.print(String.format("invalid var in '%s' event", event), ex, null,
|
|
|
sc.getName(), sc, sc.getStackTrace());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public void onPlayerDataTick(PlayerEntity p, String var) {
|
|
|
- handleEvent("player_data_tick", sc -> {
|
|
|
+
|
|
|
+ public static void onPlayerDataTick(Player p, String var) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent("player_data_tick", sc -> {
|
|
|
setPlayer(sc, p);
|
|
|
sc.setVar("var", var);
|
|
|
- });
|
|
|
+ }, ScriptEvents::nothing);
|
|
|
}
|
|
|
-
|
|
|
- public void onPlayerStartElytra(PlayerEntity p) {
|
|
|
- handleEvent("player_elytra_start", sc -> {
|
|
|
+
|
|
|
+ public static void onGlideToggle(EntityToggleGlideEvent e) {
|
|
|
+ if(!(e.getEntity() instanceof Player)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Player p = (Player) e.getEntity();
|
|
|
+ if(e.isGliding()) {
|
|
|
+ handleEvent("player_elytra_start", sc -> {
|
|
|
+ setPlayer(sc, p);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ handleEvent("player_elytra_stop", sc -> {
|
|
|
+ setPlayer(sc, p);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void onPlayerMove(Player p, int id) {
|
|
|
+ handleEvent("player_move", sc -> {
|
|
|
setPlayer(sc, p);
|
|
|
+ sc.setVar("id", (double) id);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- public void onPlayerStopElytra(PlayerEntity p) {
|
|
|
- handleEvent("player_elytra_stop", sc -> {
|
|
|
+
|
|
|
+ private static void onSnuviClick(Player p, Inventory inv, Component title, int slot) {
|
|
|
+ handleEvent("snuvi_click", sc -> {
|
|
|
setPlayer(sc, p);
|
|
|
+ sc.setVar("inv", inv);
|
|
|
+ sc.setVar("inv_title", title);
|
|
|
+ sc.setVar("inv_slot", (double) slot);
|
|
|
});
|
|
|
- }*/
|
|
|
-
|
|
|
- public static void onPlayerMove(Player p, int id) {
|
|
|
- //handleEvent("player_move", sc -> {
|
|
|
- // setPlayer(sc, p);
|
|
|
- // sc.setVar("id", (double) id);
|
|
|
- //});
|
|
|
}
|
|
|
|
|
|
- /*public boolean onInventoryClick(Script script, ITextComponent text, ModInventory inv, int slot,
|
|
|
- ClickType click, PlayerEntity p) {
|
|
|
- scripts.getScriptManager().callEvent("inv_click", script, sc -> {
|
|
|
+ public static void onInventoryClick(InventoryClickEvent e) {
|
|
|
+ if(!(e.getWhoClicked() instanceof Player)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Player p = (Player) e.getWhoClicked();
|
|
|
+ Inventory clicked = e.getClickedInventory();
|
|
|
+ int slot = e.getSlot();
|
|
|
+
|
|
|
+ if(clicked != null && clicked.getHolder() instanceof SnuviInventoryHolder) {
|
|
|
+ SnuviInventoryHolder holder = (SnuviInventoryHolder) clicked.getHolder();
|
|
|
+ switch(holder.getSlotType(slot)) {
|
|
|
+ case BLOCKED:
|
|
|
+ e.setCancelled(true);
|
|
|
+ return;
|
|
|
+ case NORMAL:
|
|
|
+ break;
|
|
|
+ case CLICK_EVENT_1:
|
|
|
+ case CLICK_EVENT_2:
|
|
|
+ e.setCancelled(true);
|
|
|
+ onSnuviClick(p, e.getClickedInventory(), e.getView().title(), slot);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String click = e.getClick().toString();
|
|
|
+ String action = e.getAction().toString();
|
|
|
+ handleEvent(e, "inv_click", sc -> {
|
|
|
setPlayer(sc, p);
|
|
|
- sc.setVar("inv", inv);
|
|
|
- sc.setVar("inv_id", (double) inv.getModId());
|
|
|
- sc.setVar("inv_name", text.getString());
|
|
|
+ sc.setVar("inv", e.getInventory());
|
|
|
+ sc.setVar("inv_clicked", e.getClickedInventory());
|
|
|
+ sc.setVar("inv_name", e.getView().title());
|
|
|
sc.setVar("inv_slot", (double) slot);
|
|
|
- sc.setVar("click_type", click.toString());
|
|
|
- setItem(sc, inv.getStackInSlot(slot));
|
|
|
- sc.setVar("cancel", false);
|
|
|
- }, ScriptEvents::nothing);
|
|
|
- Variable v = script.getVar("cancel");
|
|
|
- return v != null && v.getBoolean(script);
|
|
|
+ sc.setVar("click", click);
|
|
|
+ sc.setVar("action", action);
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
- public void onInventoryClose(Script script, ITextComponent text, ModInventory inv,
|
|
|
- PlayerEntity p) {
|
|
|
- scripts.getScriptManager().callEvent("inv_close", script, sc -> {
|
|
|
+
|
|
|
+ public static void onInventoryClose(InventoryCloseEvent e) {
|
|
|
+ if(!(e.getPlayer() instanceof Player)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Player p = (Player) e.getPlayer();
|
|
|
+ handleEvent("inv_close", sc -> {
|
|
|
setPlayer(sc, p);
|
|
|
- sc.setVar("inv", inv);
|
|
|
- sc.setVar("inv_id", (double) inv.getModId());
|
|
|
- sc.setVar("inv_name", text.getString());
|
|
|
- }, ScriptEvents::nothing);
|
|
|
+ sc.setVar("inv", e.getInventory());
|
|
|
+ sc.setVar("inv_name", e.getView().title());
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
- public void onHumanHurt(Entity attacker, EntityHuman h) {
|
|
|
+
|
|
|
+ /*public void onHumanHurt(Entity attacker, EntityHuman h) {
|
|
|
handleEvent("human_hurt", sc -> {
|
|
|
setEntity(sc, attacker);
|
|
|
sc.setVar("human", h);
|
|
|
});
|
|
|
- }
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onPlayerPostRespawn(PlayerEvent.PlayerRespawnEvent e) {
|
|
|
+ }*/
|
|
|
+
|
|
|
+ public static void onPlayerPreRespawn(PlayerRespawnEvent e) {
|
|
|
handleEvent("player_post_respawn", sc -> setPlayer(sc, e.getPlayer()));
|
|
|
}
|
|
|
-
|
|
|
- public void onPlayerPreRespawn(PlayerEntity p) {
|
|
|
- handleEvent("player_pre_respawn", sc -> setPlayer(sc, p));
|
|
|
- }
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLivingDamage(LivingDamageEvent e) {
|
|
|
- handleEvent(e, "living_damage", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- sc.setVar("damage_source", e.getSource());
|
|
|
- sc.setVar("damage_amount", (double) e.getAmount());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "living_damage", "damage_amount", v -> e.setAmount(v.getFloat(sc)));
|
|
|
- });
|
|
|
+
|
|
|
+ public static void onPlayerPostRespawn(PlayerPostRespawnEvent e) {
|
|
|
+ handleEvent("player_pre_respawn", sc -> setPlayer(sc, e.getPlayer()));
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLivingHurt(LivingHurtEvent e) {
|
|
|
- if(e.getSource().getDamageType().equals("fireworks")) {
|
|
|
- e.setCanceled(true);
|
|
|
+
|
|
|
+ private static Block getBlock(EntityDamageEvent e) {
|
|
|
+ if(e instanceof EntityDamageByBlockEvent) {
|
|
|
+ EntityDamageByBlockEvent eb = (EntityDamageByBlockEvent) e;
|
|
|
+ return eb.getDamager();
|
|
|
}
|
|
|
- handleEvent(e, "living_hurt", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- sc.setVar("damage_source", e.getSource());
|
|
|
- sc.setVar("damage_amount", (double) e.getAmount());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "living_hurt", "damage_amount", v -> e.setAmount(v.getFloat(sc)));
|
|
|
- });
|
|
|
+ return null;
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLivingAttacked(LivingAttackEvent e) {
|
|
|
- handleEvent(e, "living_pre_hurt", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- sc.setVar("damage_source", e.getSource());
|
|
|
- sc.setVar("damage_amount", (double) e.getAmount());
|
|
|
- });
|
|
|
+
|
|
|
+ private static Entity getEntity(EntityDamageEvent e) {
|
|
|
+ if(e instanceof EntityDamageByEntityEvent) {
|
|
|
+ EntityDamageByEntityEvent ee = (EntityDamageByEntityEvent) e;
|
|
|
+ return ee.getDamager();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLivingHeal(LivingHealEvent e) {
|
|
|
- handleEvent(e, "living_heal", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- sc.setVar("heal_amount", (double) e.getAmount());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "living_heal", "heal_amount", v -> e.setAmount(v.getFloat(sc)));
|
|
|
+
|
|
|
+ public static void onEntityDamage(EntityDamageEvent e) {
|
|
|
+ String cause = e.getCause().toString();
|
|
|
+ Block damagerBlock = getBlock(e);
|
|
|
+ Entity damagerEntity = getEntity(e);
|
|
|
+ handleEvent("entity_damage", (sc) -> {
|
|
|
+ setEntity(sc, e.getEntity());
|
|
|
+ sc.setVar("vanilla_cause", NMS.getCurrentDamageSource());
|
|
|
+ sc.setVar("cause", cause);
|
|
|
+ sc.setVar("damager_block", damagerBlock);
|
|
|
+ sc.setVar("damager_entity", damagerEntity);
|
|
|
+ sc.setVar("raw_damage", e.getDamage());
|
|
|
+ sc.setVar("damage", e.getFinalDamage());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLivingDeath(LivingDeathEvent e) {
|
|
|
- handleEvent(e, "living_death", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- sc.setVar("damage_source", e.getSource());
|
|
|
+
|
|
|
+ public static void onEntityRegainHealth(EntityRegainHealthEvent e) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent("entity_heal", sc -> {
|
|
|
+ setEntity(sc, e.getEntity());
|
|
|
+ sc.setVar("heal_amount", e.getAmount());
|
|
|
+ sc.setVar("heal_reason", e.getRegainReason().toString());
|
|
|
+ setCancel(sc, e.isCancelled());
|
|
|
+ }, sc -> {
|
|
|
+ setCancelled(e, sc);
|
|
|
+ handleVar(sc, "entity_heal", "heal_amount", v -> e.setAmount(v.getDouble(sc)));
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLivingDrop(LivingDropsEvent e) {
|
|
|
- handleEvent(e, "living_drop", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
+
|
|
|
+ public static void onEntityDeath(EntityDeathEvent e) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent("living_death", sc -> {
|
|
|
+ setLiving(sc, e.getEntity());
|
|
|
+ sc.setVar("vanilla_cause", NMS.getCurrentDamageSource());
|
|
|
sc.setVar("drops", e.getDrops());
|
|
|
- sc.setVar("damage_source", e.getSource());
|
|
|
- sc.setVar("looting", (double) e.getLootingLevel());
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLivingExperienceDrop(LivingExperienceDropEvent e) {
|
|
|
- handleEvent(e, "living_experience_drop", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- sc.setVar("experience", (double) e.getDroppedExperience());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "living_experience_drop", "experience",
|
|
|
- v -> e.setDroppedExperience(v.getInt(sc)));
|
|
|
+ sc.setVar("experience", e.getDrops());
|
|
|
+ setCancel(sc, e.isCancelled());
|
|
|
+ }, sc -> {
|
|
|
+ setCancelled(e, sc);
|
|
|
+ handleVar(sc, "living_death", "experience", v -> e.setDroppedExp(v.getInt(sc)));
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onProjectileHit(ProjectileImpactEvent e) {
|
|
|
- final Entity hitEntity;
|
|
|
- final Location loc;
|
|
|
-
|
|
|
- RayTraceResult ray = e.getRayTraceResult();
|
|
|
- switch(ray.getType()) {
|
|
|
- case ENTITY:
|
|
|
- hitEntity = ((EntityRayTraceResult) e.getRayTraceResult()).getEntity();
|
|
|
- loc = null;
|
|
|
- break;
|
|
|
- case BLOCK:
|
|
|
- loc = new Location(e.getEntity().world,
|
|
|
- ((BlockRayTraceResult) e.getRayTraceResult()).getPos());
|
|
|
- hitEntity = null;
|
|
|
- break;
|
|
|
- default:
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ public static void onProjectileHit(ProjectileHitEvent e) {
|
|
|
handleEvent(e, "projectile_hit", (sc) -> {
|
|
|
sc.setVar("projectile", e.getEntity());
|
|
|
- sc.setVar("entity_hit", hitEntity);
|
|
|
- sc.setVar("loc_hit", loc);
|
|
|
- sc.setVar("shooter", Utils.getEntityFromProjectile(e.getEntity()));
|
|
|
+ sc.setVar("entity_hit", e.getHitEntity());
|
|
|
+ sc.setVar("block_hit", e.getHitBlock());
|
|
|
+ sc.setVar("shooter", e.getEntity().getShooter());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- public void onEntityItemProjectileHit(EntityItemProjectile ent, LivingEntity liv,
|
|
|
- ItemStack stack, Entity hitEntity, BlockPos pos) {
|
|
|
- Location loc = (pos == null) ? null : new Location(ent.world, pos);
|
|
|
- handleEvent("item_hit", (sc) -> {
|
|
|
- sc.setVar("projectile", ent);
|
|
|
- setItem(sc, stack);
|
|
|
- sc.setVar("entity_hit", hitEntity);
|
|
|
- sc.setVar("loc_hit", loc);
|
|
|
- sc.setVar("shooter", liv);
|
|
|
+
|
|
|
+ public static void onBlockDropItemEvent(BlockDropItemEvent e) {
|
|
|
+ final Block b = e.getBlockState().getBlock();
|
|
|
+ handleEvent(e, "block_drop", sc -> {
|
|
|
+ setPlayer(sc, e.getPlayer());
|
|
|
+ sc.setVar("drops", e.getItems());
|
|
|
+ setBlock(sc, b);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ItemStack> onBlockHarvest(BlockState state, ServerWorld w, BlockPos pos,
|
|
|
- TileEntity tileEnt, Entity ent, ItemStack stack) {
|
|
|
- LootContext.Builder loot = new LootContext.Builder(w).withRandom(w.getRandom())
|
|
|
- .withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(pos))
|
|
|
- .withParameter(LootParameters.TOOL, stack == null ? ItemStack.EMPTY : stack)
|
|
|
- .withNullableParameter(LootParameters.THIS_ENTITY, ent)
|
|
|
- .withNullableParameter(LootParameters.BLOCK_ENTITY, tileEnt);
|
|
|
- List<ItemStack> list = state.getDrops(loot);
|
|
|
- try {
|
|
|
- final Block b = state.getBlock();
|
|
|
- final String name = b.getRegistryName().toString();
|
|
|
- scripts.getScriptManager().callEvent("block_drop", sc -> {
|
|
|
- sc.setVar("drops", list);
|
|
|
- sc.setVar("block_type", name);
|
|
|
- sc.setVar("block", b);
|
|
|
- sc.setVar("location", new Location(w, pos));
|
|
|
- setEntity(sc, ent);
|
|
|
- setItem(sc, stack);
|
|
|
- }, ScriptEvents::nothing);
|
|
|
- } catch(Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onBlockBreak(BlockEvent.BreakEvent e) {
|
|
|
- handleEvent("block_break", (sc) -> {
|
|
|
+
|
|
|
+ public static void onBlockBreak(BlockBreakEvent e) {
|
|
|
+ handleEvent(e, "block_break", (sc) -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- setBlock(sc, (World) e.getWorld(), e.getPos(), e.getState());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "block_break");
|
|
|
+ setBlock(sc, e.getBlock());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
|
|
|
- if(!(e.getEntity() instanceof PlayerEntity)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- PlayerEntity p = (PlayerEntity) e.getEntity();
|
|
|
- handleEvent("block_place", (sc) -> {
|
|
|
- setPlayer(sc, p);
|
|
|
- sc.setVar("block_type_after", e.getPlacedBlock().getBlock().getRegistryName());
|
|
|
- setBlock(sc, (World) e.getWorld(), e.getPos(), e.getState());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "block_place");
|
|
|
+
|
|
|
+ public static void onBlockPlace(BlockPlaceEvent e) {
|
|
|
+ handleEvent(e, "block_place", (sc) -> {
|
|
|
+ setPlayer(sc, e.getPlayer());
|
|
|
+ setBlock(sc, e.getBlockPlaced());
|
|
|
+ setHand(sc, e.getHand());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent e) {
|
|
|
- PlayerEntity p = e.getPlayer();
|
|
|
- if(p == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- PlayerList list = server.getPlayerList();
|
|
|
- boolean banned = list.getBannedPlayers().isBanned(p.getGameProfile());
|
|
|
- boolean whitelisted = list.getWhitelistedPlayers().isWhitelisted(p.getGameProfile());
|
|
|
+
|
|
|
+ public static void onPlayerLogin(PlayerLoginEvent e) {
|
|
|
+ String result = e.getResult().toString();
|
|
|
handleEvent("player_login", (sc) -> {
|
|
|
- setPlayer(sc, p);
|
|
|
- sc.setVar("is_banned", banned);
|
|
|
- sc.setVar("is_whitelisted", whitelisted);
|
|
|
+ setPlayer(sc, e.getPlayer());
|
|
|
+ sc.setVar("result", result);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent e) {
|
|
|
- PlayerEntity p = e.getPlayer();
|
|
|
- if(p == null || e.getPlayer().ticksExisted < 20) {
|
|
|
- return;
|
|
|
- }
|
|
|
- handleEvent("player_logout", sc -> setPlayer(sc, p));
|
|
|
+
|
|
|
+ public static void onPlayerJoin(PlayerJoinEvent e) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent("player_join", sc -> {
|
|
|
+ setPlayer(sc, e.getPlayer());
|
|
|
+ sc.setVar("message", e.joinMessage());
|
|
|
+ }, sc -> {
|
|
|
+ handleVar(sc, "player_join", "message", v -> e.joinMessage((Component) v.get(sc)));
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onBucketFill(FillBucketEvent e) {
|
|
|
- handleEvent("bucket_use", (sc) -> {
|
|
|
+
|
|
|
+ public static void onPlayerQuit(PlayerQuitEvent e) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent("player_quit", sc -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- RayTraceResult ray = e.getTarget();
|
|
|
- if(ray != null && ray instanceof BlockRayTraceResult
|
|
|
- && ray.getType() == RayTraceResult.Type.BLOCK) {
|
|
|
- sc.setVar("has_block", true);
|
|
|
- ScriptEvents.setBlock(sc, e.getWorld(), ((BlockRayTraceResult) ray).getPos());
|
|
|
- } else {
|
|
|
- sc.setVar("has_block", false);
|
|
|
- }
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "bucket_use");
|
|
|
+ sc.setVar("message", e.quitMessage());
|
|
|
+ }, sc -> {
|
|
|
+ handleVar(sc, "player_quit", "message", v -> e.quitMessage((Component) v.get(sc)));
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onRightClickBlock(PlayerInteractEvent.RightClickBlock e) {
|
|
|
- handleEvent("block_click", (sc) -> {
|
|
|
+
|
|
|
+ public static void onPlayerBucket(PlayerBucketEvent e) {
|
|
|
+ handleEvent(e, "bucket_use", (sc) -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- sc.setVar("action", "right");
|
|
|
- sc.setVar("hand", e.getHand().name());
|
|
|
- ScriptEvents.setBlock(sc, e.getWorld(), e.getPos());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "block_click", "cancel", v -> {
|
|
|
- boolean b = v.getBoolean(sc);
|
|
|
- e.setCanceled(b);
|
|
|
- if(!b) {
|
|
|
- e.setUseBlock(Result.DEFAULT);
|
|
|
- e.setUseItem(Result.DEFAULT);
|
|
|
- }
|
|
|
- });
|
|
|
+ setBlock(sc, e.getBlockClicked());
|
|
|
+ sc.setVar("bucket", e.getBucket());
|
|
|
+ setHand(sc, e.getHand());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock e) {
|
|
|
+
|
|
|
+ public static void onPlayerInteract(PlayerInteractEvent e) {
|
|
|
handleEvent("block_click", (sc) -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- sc.setVar("action", "left");
|
|
|
- sc.setVar("hand", e.getHand().name());
|
|
|
- ScriptEvents.setBlock(sc, e.getWorld(), e.getPos());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "block_click", "cancel", v -> {
|
|
|
- boolean b = v.getBoolean(sc);
|
|
|
- e.setCanceled(b);
|
|
|
- if(!b) {
|
|
|
- e.setUseBlock(Result.DEFAULT);
|
|
|
- e.setUseItem(Result.DEFAULT);
|
|
|
- }
|
|
|
- });
|
|
|
+ setBlock(sc, e.getClickedBlock());
|
|
|
+ setHand(sc, e.getHand());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onEntityClick(PlayerInteractEvent.EntityInteract e) {
|
|
|
+
|
|
|
+ public static void onPlayerInteractEntity(PlayerInteractEntityEvent e) {
|
|
|
handleEvent("entity_click", (sc) -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- sc.setVar("hand", e.getHand().name());
|
|
|
- setEntity(sc, e.getTarget());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "entity_click");
|
|
|
+ setEntity(sc, e.getRightClicked());
|
|
|
+ setHand(sc, e.getHand());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- public void onEmptyLeftClick(PlayerEntity p) {
|
|
|
- handleEvent("left_click_air", sc -> setPlayer(sc, p));
|
|
|
- }
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onItemClick(PlayerInteractEvent.RightClickItem e) {
|
|
|
- handleEvent("item_air_click", (sc) -> {
|
|
|
+
|
|
|
+ public static void onPlayerArmSwing(PlayerArmSwingEvent e) {
|
|
|
+ handleEvent("arm_swing", sc -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- setItem(sc, e.getItemStack());
|
|
|
- sc.setVar("hand", e.getHand().toString());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "item_air_click");
|
|
|
+ setHand(sc, e.getHand());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onItemUseStart(LivingEntityUseItemEvent.Start e) {
|
|
|
- handleEvent(e, "item_use_start", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- sc.setVar("duration", (double) e.getDuration());
|
|
|
+
|
|
|
+ public static void onPlayerItemConsume(PlayerItemConsumeEvent e) {
|
|
|
+ handleEvent(e, "item_consume", (sc) -> {
|
|
|
+ setPlayer(sc, e.getPlayer());
|
|
|
setItem(sc, e.getItem());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "item_use_start", "duration", v -> e.setDuration(v.getInt(sc)));
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onConsuming(LivingEntityUseItemEvent.Finish e) {
|
|
|
- handleEvent(e, "item_use_finish", (sc) -> {
|
|
|
- setLiving(sc, e.getEntityLiving());
|
|
|
- setItem(sc, e.getItem());
|
|
|
- sc.setVar("result", e.getResultStack());
|
|
|
- }, (sc) -> {
|
|
|
- handleVar(sc, "item_use_finish", "result", v -> {
|
|
|
- ItemStack stack = (ItemStack) v.get(sc);
|
|
|
- if(stack == null) {
|
|
|
- e.setResultStack(ItemStack.EMPTY);
|
|
|
- } else {
|
|
|
- e.setResultStack(stack);
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+ public static void onPlayerFish(PlayerFishEvent e) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent("fishing", sc -> {
|
|
|
+ setPlayer(sc, e.getPlayer());
|
|
|
+ setEntity(sc, e.getCaught());
|
|
|
+ sc.setVar("experience", e.getExpToDrop());
|
|
|
+ setCancel(sc, e.isCancelled());
|
|
|
+ }, sc -> {
|
|
|
+ setCancelled(e, sc);
|
|
|
+ handleVar(sc, "fishing", "experience", v -> e.setExpToDrop(v.getInt(sc)));
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onFishing(ItemFishedEvent e) {
|
|
|
- handleEvent("fishing", (sc) -> {
|
|
|
- setPlayer(sc, e.getPlayer());
|
|
|
- sc.setVar("drops", e.getDrops());
|
|
|
- sc.setVar("hook", e.getHookEntity());
|
|
|
- sc.setVar("rod_damage", (double) e.getRodDamage());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "fishing");
|
|
|
- handleVar(sc, "fishing", "rod_damage", v -> e.damageRodBy(v.getInt(sc)));
|
|
|
+
|
|
|
+ public static void onCraftItem(CraftItemEvent e) {
|
|
|
+ if(!(e.getWhoClicked() instanceof Player)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Player p = (Player) e.getWhoClicked();
|
|
|
+ handleEvent(e, "craft", sc -> {
|
|
|
+ setPlayer(sc, p);
|
|
|
+ setItem(sc, e.getInventory().getResult());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onCrafting(PlayerEvent.ItemCraftedEvent e) {
|
|
|
- handleEvent("craft", (sc) -> {
|
|
|
- setPlayer(sc, e.getPlayer());
|
|
|
- setItem(sc, e.getCrafting());
|
|
|
+
|
|
|
+ public static void onPrepareItemCraft(PrepareItemCraftEvent e) {
|
|
|
+ KajetansPlugin.scriptManager.callEvent("pre_craft", sc -> {
|
|
|
+ sc.setVar("players", e.getViewers());
|
|
|
+ setItem(sc, e.getInventory().getResult());
|
|
|
+ }, sc -> {
|
|
|
+ handleVar(sc, "pre_craft", "item",
|
|
|
+ v -> e.getInventory().setResult((ItemStack) v.get(sc)));
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onItemDrop(ItemTossEvent e) {
|
|
|
- handleEvent("player_toss", (sc) -> {
|
|
|
+
|
|
|
+ public static void onPlayerDropItem(PlayerDropItemEvent e) {
|
|
|
+ handleEvent(e, "player_toss", (sc) -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- setItem(sc, e.getEntityItem().getItem());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "player_toss");
|
|
|
+ setItem(sc, e.getItemDrop());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onItemPickup(EntityItemPickupEvent e) {
|
|
|
- handleEvent("player_pickup", (sc) -> {
|
|
|
- setPlayer(sc, e.getPlayer());
|
|
|
- setEntity(sc, e.getItem());
|
|
|
- setItem(sc, e.getItem().getItem());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
- }, (sc) -> {
|
|
|
- simpleCancel(sc, e, "player_pickup");
|
|
|
+
|
|
|
+ public static void onEntityPickupItem(EntityPickupItemEvent e) {
|
|
|
+ handleEvent(e, "living_pickup", (sc) -> {
|
|
|
+ setLiving(sc, e.getEntity());
|
|
|
+ setItem(sc, e.getItem());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onEntityMount(EntityMountEvent e) {
|
|
|
- Entity ent = e.getEntityBeingMounted();
|
|
|
- if(ent instanceof AbstractHorseEntity) {
|
|
|
- for(PlayerEntity p : ent.getEntityWorld().getPlayers()) {
|
|
|
- if(p.openContainer == null
|
|
|
- || !(p.openContainer instanceof HorseInventoryContainer)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- p.closeScreen();
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ public static void onEntityMount(EntityMountEvent e) {
|
|
|
handleEvent(e, "entity_mount", (sc) -> {
|
|
|
- sc.setVar("mounting", e.isMounting());
|
|
|
- setEntity(sc, ent);
|
|
|
- sc.setVar("rider", e.getEntityMounting());
|
|
|
+ setEntity(sc, e.getEntity());
|
|
|
+ sc.setVar("mount", e.getMount());
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- @SubscribeEvent(receiveCanceled = true)
|
|
|
- public void onPlayerUsePortal(PlayerEvent.PlayerChangedDimensionEvent e) {
|
|
|
- handleEvent("portal", (sc) -> {
|
|
|
+
|
|
|
+ public static void onPlayerChangedWorl(PlayerChangedWorldEvent e) {
|
|
|
+ handleEvent("player_change_world", (sc) -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
- sc.setVar("from", e.getFrom().getRegistryName().getPath());
|
|
|
- sc.setVar("to", e.getTo().getRegistryName().getPath());
|
|
|
+ sc.setVar("from", e.getFrom());
|
|
|
});
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
public static boolean onCommand(Player p, String command) {
|
|
|
- //handleEvent("command", (sc) -> {
|
|
|
- // setPlayer(sc, e.getPlayer());
|
|
|
- // sc.setVar("command", e.getName());
|
|
|
- // sc.setVar("cancel", e.isCanceled());
|
|
|
- //}, (sc) -> {
|
|
|
- // handleVar(sc, "command", "cancel", v -> e.setCanceled(v.getBoolean(sc)));
|
|
|
- //});
|
|
|
- return false;
|
|
|
+ WrappedBool wr = new WrappedBool();
|
|
|
+ KajetansPlugin.scriptManager.callEvent("command", sc -> {
|
|
|
+ sc.setVar("player", p);
|
|
|
+ sc.setVar("command", command);
|
|
|
+ setCancel(sc, wr.wrapped);
|
|
|
+ }, sc -> {
|
|
|
+ Variable v = sc.getVar("cancel");
|
|
|
+ if(v == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ wr.wrapped = v.getBoolean(sc);
|
|
|
+ } catch(Exception ex) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return wr.wrapped;
|
|
|
}
|
|
|
|
|
|
public static void onCustomCommand(Player p, String command, String[] args) {
|
|
|
- KajetansPlugin.log("Custom Command: " + command);
|
|
|
- for(String s : args) {
|
|
|
- KajetansPlugin.log(s);
|
|
|
- }
|
|
|
- //handleEvent("custom_command", (sc) -> {
|
|
|
- // setPlayer(sc, p);
|
|
|
- // sc.setVar("command", command);
|
|
|
- // if(args.length == 0) {
|
|
|
- // sc.setVar("args", new ArrayList<>());
|
|
|
- // sc.setVar("text_args", new ArrayList<>());
|
|
|
- // } else {
|
|
|
- // sc.setVar("args", Arrays.stream(args).map(s -> SnuviUtils.convert(s))
|
|
|
- // .collect(Collectors.toList()));
|
|
|
- // sc.setVar("text_args", Arrays.stream(args).collect(Collectors.toList()));
|
|
|
- // }
|
|
|
- //});
|
|
|
+ handleEvent("custom_command", (sc) -> {
|
|
|
+ setPlayer(sc, p);
|
|
|
+ sc.setVar("command", command);
|
|
|
+ sc.setVar("args", Arrays.stream(args).map(s -> SnuviUtils.convert(s))
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ sc.setVar("text_args", Arrays.stream(args).collect(Collectors.toList()));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/*public void onFunctionKey(ServerPlayerEntity p, int key) {
|
|
@@ -583,7 +460,7 @@ public class ScriptEvents {
|
|
|
handleEvent("chat", (sc) -> {
|
|
|
setPlayer(sc, e.getPlayer());
|
|
|
sc.setVar("message", e.getMessage());
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
+ setCancel(sc, e.isCanceled());
|
|
|
}, (sc) -> {
|
|
|
handleVar(sc, "chat", "message",
|
|
|
v -> e.setComponent(new StringTextComponent(v.getString(sc))));
|
|
@@ -738,7 +615,7 @@ public class ScriptEvents {
|
|
|
} else {
|
|
|
System.out.println("Entity is null");
|
|
|
}
|
|
|
- sc.setVar("cancel", b);
|
|
|
+ setCancel(sc, b);
|
|
|
}, (sc) -> {
|
|
|
handleVar(sc, "mob_griefing", "cancel", (v) -> {
|
|
|
e.setResult(v.getBoolean(sc) ? Result.DENY : Result.ALLOW);
|
|
@@ -810,7 +687,7 @@ public class ScriptEvents {
|
|
|
sc.setVar("type", name);
|
|
|
sc.setVar("drag_type", (double) dragType);
|
|
|
sc.setVar("click_type", ct.toString());
|
|
|
- sc.setVar("cancel", b.wrapped);
|
|
|
+ setCancel(sc, b.wrapped);
|
|
|
}, sc -> {
|
|
|
handleVar(sc, "container_click", "cancel", v -> b.wrapped = v.getBoolean(sc));
|
|
|
});
|
|
@@ -823,7 +700,7 @@ public class ScriptEvents {
|
|
|
setLiving(sc, e.getEntityLiving());
|
|
|
sc.setVar("location", new Location(e.getEntityLiving().getEntityWorld(), e.getTargetX(),
|
|
|
e.getTargetY(), e.getTargetZ(), 0.0f, 0.0f));
|
|
|
- sc.setVar("cancel", e.isCanceled());
|
|
|
+ setCancel(sc, e.isCanceled());
|
|
|
}, (sc) -> {
|
|
|
simpleCancel(sc, e, "ender_teleport");
|
|
|
});
|