Skip to content

Commit

Permalink
Oops... Java has 0-based arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Mar 26, 2016
1 parent d170c80 commit 43696c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 124 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/effects/EffHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public boolean init(final Expression<?>[] vars, final int matchedPattern, final
damage = (Expression<Number>) vars[1];
heal = (matchedPattern >= 1);

if (vars.length >= 2) dmgCause = (Expression<DamageCause>) vars[2];
if (vars.length >= 3) dmgCause = (Expression<DamageCause>) vars[2];
return true;
}

Expand Down
124 changes: 1 addition & 123 deletions src/main/java/ch/njol/skript/events/EvtClick.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,126 +338,4 @@ public static boolean checkUseOffHand(Player player, int clickType, @Nullable Bl
return false; // Both hands are AIR material!
}

private boolean checkOffHandUse2(@Nullable ItemStack mainHand, @Nullable ItemStack offHand, int clickType, Player player, @Nullable Block target) {
boolean mainUsable = false;
boolean offUsable = false;

if (mainHand == null) mainHand = new ItemStack(Material.AIR);

if (clickType == RIGHT) {
if (offHand == null) return false;
switch (offHand.getType()) {
case BOW:
case EGG:
case SPLASH_POTION:
case SNOW_BALL:
case BUCKET:
case FISHING_ROD:
case FLINT_AND_STEEL:
case WOOD_HOE:
case STONE_HOE:
case IRON_HOE:
case GOLD_HOE:
case DIAMOND_HOE:
case LEASH:
case SHEARS:
case WOOD_SPADE:
case STONE_SPADE:
case IRON_SPADE:
case GOLD_SPADE:
case DIAMOND_SPADE:
case SHIELD:
case ENDER_PEARL:
offUsable = true;
break;
//$CASES-OMITTED$
default:
offUsable = false;
}

if (offHand.getType().isBlock() || offHand.getType().isEdible()) {
offUsable = true;
}

switch (mainHand.getType()) {
case BOW:
case EGG:
case SPLASH_POTION:
case SNOW_BALL:
case BUCKET:
case FISHING_ROD:
case FLINT_AND_STEEL:
case WOOD_HOE:
case STONE_HOE:
case IRON_HOE:
case GOLD_HOE:
case DIAMOND_HOE:
case LEASH:
case SHEARS:
case WOOD_SPADE:
case STONE_SPADE:
case IRON_SPADE:
case GOLD_SPADE:
case DIAMOND_SPADE:
case ENDER_PEARL:
mainUsable = true;
break;
//$CASES-OMITTED$
default:
mainUsable = false;
}

if (mainHand.getType().isBlock() || mainHand.getType().isEdible()) {
mainUsable = true;
}

if (target != null) {
switch (target.getType()) {
case ANVIL:
case BEACON:
case BED:
case BREWING_STAND:
case CAKE:
case CAULDRON:
case CHEST:
case TRAPPED_CHEST:
case ENDER_CHEST:
case WORKBENCH:
case ENCHANTMENT_TABLE:
case FURNACE:
case WOOD_DOOR:
case ACACIA_DOOR:
case JUNGLE_DOOR:
case DARK_OAK_DOOR:
case SPRUCE_DOOR:
case BIRCH_DOOR:
case IRON_DOOR:
case TRAP_DOOR:
case IRON_TRAPDOOR:
case FENCE_GATE:
case ACACIA_FENCE_GATE:
case JUNGLE_FENCE_GATE:
case DARK_OAK_FENCE_GATE:
case SPRUCE_FENCE_GATE:
case BIRCH_FENCE_GATE:
case HOPPER:
case DISPENSER:
case DROPPER:
case LEVER:
case WOOD_BUTTON:
case STONE_BUTTON:
case COMMAND:
if (player.isSneaking()) {
if (offHand.getType() == Material.AIR && mainHand.getType() != Material.AIR) return true;
} else {
mainUsable = true;
}
}
}
}

if (mainUsable) return false;
else if (offUsable) return true;
else return false;
}
}
}

0 comments on commit 43696c2

Please sign in to comment.