Skip to content

Commit

Permalink
[v1.0.3] Fixed a bug that caused an error when a projectile hits an e…
Browse files Browse the repository at this point in the history
…ntity. close #2
  • Loading branch information
yuttyann committed Jun 27, 2020
1 parent 1b6bfec commit 8337bc1
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import com.github.yuttyann.scriptblockplus.utils.Utils;
import com.github.yuttyann.scriptentityplus.Main;
import com.github.yuttyann.scriptentityplus.Permission;
import com.github.yuttyann.scriptentityplus.enums.ArmType;
import com.github.yuttyann.scriptentityplus.enums.ToolMode;
import com.github.yuttyann.scriptentityplus.item.ToolMode;
import com.github.yuttyann.scriptentityplus.json.ScriptEntity;
import com.github.yuttyann.scriptentityplus.json.ScriptEntityInfo;
import com.github.yuttyann.scriptentityplus.script.ScriptRead;
Expand Down Expand Up @@ -69,10 +68,10 @@ private void damageEvent(@NotNull Cancellable event, @NotNull Entity damager, @N
event.setCancelled(true);
}
if (info.isProjectile()) {
if (!(damager instanceof ThrowableProjectile)) {
if (!(damager instanceof Projectile)) {
return;
}
damager = (Entity) ((ThrowableProjectile) damager).getShooter();
damager = (Entity) ((Projectile) damager).getShooter();
}
if (damager instanceof Player) {
ToolMode toolMode = ToolMode.NORMAL_SCRIPT;
Expand Down Expand Up @@ -133,13 +132,11 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
ItemStack main = player.getInventory().getItemInMainHand();
ItemStack off = player.getInventory().getItemInOffHand();
if (ToolMode.has(main) && Permission.TOOL_SCRIPT_CONNECTION.has(player)) {
ArmType.MAIN_HAND.swingAnimation(player);
ItemAction.run(main, player, Action.RIGHT_CLICK_AIR, entity.getLocation(), true, player.isSneaking());
event.setCancelled(true);
} else if (ToolMode.has(off) && Permission.TOOL_SCRIPT_CONNECTION.has(player)) {
try {
objectMap.put(KEY_OFF, true);
ArmType.OFF_HAND.swingAnimation(player);
ItemAction.run(off, player, Action.RIGHT_CLICK_AIR, entity.getLocation(), true, player.isSneaking());
} finally {
objectMap.put(KEY_OFF, false);
Expand Down

0 comments on commit 8337bc1

Please sign in to comment.