As a semi-temporary measure, lets move 1.8 specific objects into their own classes, so we can be 1.7 and 1.8 compatable.

This commit is contained in:
t00thpick1 2014-12-19 13:48:06 -05:00
parent 429a7d926a
commit bfff5682b5
4 changed files with 52 additions and 24 deletions

View File

@ -15,6 +15,7 @@ import org.bukkit.material.SmoothBrick;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.util.temp.DualSupport;
public final class BlockUtils { public final class BlockUtils {
private BlockUtils() {} private BlockUtils() {}
@ -63,22 +64,11 @@ public final class BlockUtils {
case DROPPER: case DROPPER:
case HOPPER: case HOPPER:
case TRAPPED_CHEST: case TRAPPED_CHEST:
case IRON_TRAPDOOR:
case ACACIA_DOOR:
case SPRUCE_DOOR:
case BIRCH_DOOR:
case JUNGLE_DOOR:
case DARK_OAK_DOOR:
case IRON_DOOR: case IRON_DOOR:
case ACACIA_FENCE:
case DARK_OAK_FENCE:
case BIRCH_FENCE:
case JUNGLE_FENCE:
case ARMOR_STAND:
return false; return false;
default: default:
return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState); return DualSupport.canActivateAbilities(blockState) && !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
} }
} }
@ -173,12 +163,10 @@ public final class BlockUtils {
case SANDSTONE: case SANDSTONE:
case STAINED_CLAY: case STAINED_CLAY:
case STONE: case STONE:
case RED_SANDSTONE:
case PRISMARINE:
return true; return true;
default: default:
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState); return DualSupport.affectedBySuperBreaker(blockState) || isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
} }
} }

View File

@ -48,6 +48,7 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.MobHealthbarUtils; import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.temp.CompatableGuardianXP;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
public final class CombatUtils { public final class CombatUtils {
@ -466,7 +467,6 @@ public final class CombatUtils {
switch (type) { switch (type) {
case BAT: case BAT:
case SQUID: case SQUID:
case RABBIT:
baseXP = ExperienceConfig.getInstance().getAnimalsXP(); baseXP = ExperienceConfig.getInstance().getAnimalsXP();
break; break;
@ -489,14 +489,6 @@ public final class CombatUtils {
baseXP = ExperienceConfig.getInstance().getCombatXP(type); baseXP = ExperienceConfig.getInstance().getCombatXP(type);
break; break;
case GUARDIAN:
if (((Guardian) target).isElder()) {
baseXP = ExperienceConfig.getInstance().getElderGuardianXP();
} else {
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
break;
case SKELETON: case SKELETON:
switch (((Skeleton) target).getSkeletonType()) { switch (((Skeleton) target).getSkeletonType()) {
case WITHER: case WITHER:
@ -515,6 +507,18 @@ public final class CombatUtils {
break; break;
default: default:
if (type.name().equals("RABBIT")) {
baseXP = ExperienceConfig.getInstance().getAnimalsXP();
break;
}
if (type.name().equals("ENDERMITE")) {
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
break;
}
if (type.name().equals("GUARDIAN")) {
baseXP = CompatableGuardianXP.get(target);
break;
}
baseXP = 1.0; baseXP = 1.0;
mcMMO.getModManager().addCustomEntity(target); mcMMO.getModManager().addCustomEntity(target);
break; break;

View File

@ -0,0 +1,17 @@
package com.gmail.nossr50.util.temp;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import com.gmail.nossr50.config.experience.ExperienceConfig;
public class CompatableGuardianXP {
public static double get(Entity target) {
if (((Guardian) target).isElder()) {
return ExperienceConfig.getInstance().getElderGuardianXP();
} else {
return ExperienceConfig.getInstance().getCombatXP(EntityType.GUARDIAN);
}
}
}

View File

@ -0,0 +1,19 @@
package com.gmail.nossr50.util.temp;
import org.bukkit.block.BlockState;
public class DualSupport {
public static boolean canActivateAbilities(BlockState blockState) {
String mat = blockState.getType().name();
return !mat.equals("IRON_TRAPDOOR") && !mat.equals("ACACIA_DOOR") && !mat.equals("SPRUCE_DOOR") && !mat.equals("BIRCH_DOOR")
&& !mat.equals("JUNGLE_DOOR") && !mat.equals("DARK_OAK_DOOR") && !mat.equals("ACACIA_FENCE") && !mat.equals("DARK_OAK_FENCE")
&& !mat.equals("BIRCH_FENCE") && !mat.equals("JUNGLE_FENCE") && !mat.equals("ARMOR_STAND");
}
public static boolean affectedBySuperBreaker(BlockState blockState) {
String mat = blockState.getType().name();
return mat.equals("PRISMARINE") || mat.equals("RED_SANDSTONE");
}
}