Multiple items can be specified as a detonator

This commit is contained in:
nossr50 2019-04-06 06:28:56 -07:00
parent abda53641f
commit ee90780d7b
7 changed files with 101 additions and 3 deletions

View File

@ -84,6 +84,7 @@ Version 2.2.0
Super Ability conifg options will now be found in "skill_super_abilities.conf"
Super Abilities now have a default max length cap of one minute
Blast Mining default cooldown increased from 60 seconds to 120 seconds
You can now configure multiple items as detonators for Blast Mining
Exploit related config options will now be found in "exploit-prevention"
Exploit Prevention's "EndermanEndermiteFarms" renamed -> "Endermen-Endermite-Fix"

View File

@ -48,7 +48,24 @@ public class ConfigMining {
"\nUse Minecraft friendly names for entries, not Bukkit material names.")
private ArrayList<String> bonusDrops = DEFAULT_BONUS_DROPS;
@Setting(value = "Sub-Skills")
private ConfigMiningSubskills miningSubskills = new ConfigMiningSubskills();
public ConfigMiningSubskills getMiningSubskills() {
return miningSubskills;
}
public ConfigMiningBlastMining getBlastMining() {
return miningSubskills.getBlastMining();
}
public ArrayList<String> getDetonators() {
return getBlastMining().getDetonators();
}
public ArrayList<String> getBonusDrops() {
return bonusDrops;
}
}

View File

@ -0,0 +1,29 @@
package com.gmail.nossr50.config.hocon.skills.mining;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.bukkit.Material;
import java.util.ArrayList;
@ConfigSerializable
public class ConfigMiningBlastMining {
public static final ArrayList<String> DETONATORS_DEFAULT;
static {
DETONATORS_DEFAULT = new ArrayList<>();
DETONATORS_DEFAULT.add(Material.FLINT_AND_STEEL.getKey().toString());
DETONATORS_DEFAULT.add(Material.DIAMOND_PICKAXE.getKey().toString());
DETONATORS_DEFAULT.add(Material.GOLDEN_PICKAXE.getKey().toString());
DETONATORS_DEFAULT.add(Material.IRON_PICKAXE.getKey().toString());
DETONATORS_DEFAULT.add(Material.WOODEN_PICKAXE.getKey().toString());
}
@Setting(value = "Detonators", comment = "Items that can be used to activate Blast-Mining")
private ArrayList<String> detonators = DETONATORS_DEFAULT;
public ArrayList<String> getDetonators() {
return detonators;
}
}

View File

@ -0,0 +1,15 @@
package com.gmail.nossr50.config.hocon.skills.mining;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigMiningSubskills {
@Setting(value = "Blast-Mining", comment = "Settings for Blast Mining")
public ConfigMiningBlastMining blastMining = new ConfigMiningBlastMining();
public ConfigMiningBlastMining getBlastMining() {
return blastMining;
}
}

View File

@ -41,8 +41,6 @@ public class BlastMining {
}*/
public static Material detonator = MainConfig.getInstance().getDetonatorItem();
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
public static double getBlastRadiusModifier(int rank) {

View File

@ -2,13 +2,51 @@ package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import net.royawesome.jlibnoise.module.combiner.Min;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class Mining {
private List<Material> detonators;
private static Mining instance;
public static Mining getInstance() {
if(instance == null)
instance = new Mining();
return instance;
}
public Mining() {
//Init detonators
this.detonators = ItemUtils.matchMaterials(mcMMO.getConfigManager().getConfigMining().getDetonators());
}
/**
* Retrieve a list of Blast Mining detonator types
* @return blast mining detonator materials
*/
public List<Material> getDetonators() {
return detonators;
}
/**
* Check if an itemStack is a valid blast mining detonator
* @param itemStack target itemstack
* @return true if valid blast mining detonator
*/
public Boolean isDetonator(ItemStack itemStack)
{
return getDetonators().contains(itemStack.getType());
}
/**
* Calculate XP gain for Mining.
*

View File

@ -43,7 +43,7 @@ public class MiningManager extends SkillManager {
Player player = getPlayer();
return canUseBlastMining() && player.isSneaking()
&& (ItemUtils.isPickaxe(getPlayer().getInventory().getItemInMainHand()) || player.getInventory().getItemInMainHand().getType() == Config.getInstance().getDetonatorItem())
&& Mining.getInstance().isDetonator(player.getInventory().getItemInMainHand())
&& Permissions.remoteDetonation(player);
}