Optimized most mining enchantments
This commit is contained in:
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings({"unchecked", "deprecation"})
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CommandDebug extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new /ecoenchants debug command handler.
|
||||
|
||||
@@ -53,7 +53,7 @@ public class Arborist extends EcoEnchant {
|
||||
|
||||
List<Material> materials = new ArrayList<>();
|
||||
|
||||
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items")) {
|
||||
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items", false)) {
|
||||
Material material = Material.getMaterial(materialName.toUpperCase());
|
||||
if (material != null) {
|
||||
materials.add(material);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Drill extends EcoEnchant {
|
||||
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(simplified));
|
||||
block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
|
||||
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
|
||||
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks", false).contains(block1.getType().name().toLowerCase())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Instantaneous extends EcoEnchant {
|
||||
|
||||
List<Material> blacklist = new ArrayList<>();
|
||||
|
||||
for (String s : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks")) {
|
||||
for (String s : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks", false)) {
|
||||
blacklist.add(Material.getMaterial(s));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,25 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Lumberjack extends EcoEnchant {
|
||||
private final List<Material> materials = new ArrayList<>();
|
||||
|
||||
public Lumberjack() {
|
||||
super(
|
||||
"lumberjack", EnchantmentType.NORMAL
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postUpdate() {
|
||||
materials.clear();
|
||||
for (String string : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks", false)) {
|
||||
Material match = Material.getMaterial(string.toUpperCase());
|
||||
if (match != null) {
|
||||
materials.add(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(@NotNull final Player player,
|
||||
@NotNull final Block block,
|
||||
@@ -37,9 +50,6 @@ public class Lumberjack extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Material> materials = new ArrayList<>();
|
||||
this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks").forEach(name -> materials.add(Material.getMaterial(name.toUpperCase())));
|
||||
|
||||
if (!materials.contains(block.getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class Spearfishing extends EcoEnchant {
|
||||
}
|
||||
|
||||
List<Material> potentialDrops = new ArrayList<>();
|
||||
this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "drops").forEach(material -> {
|
||||
this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "drops", false).forEach(material -> {
|
||||
potentialDrops.add(Material.getMaterial(material.toUpperCase()));
|
||||
});
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Transfuse extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "works-on").contains(block.getType().toString().toLowerCase())) {
|
||||
if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "works-on", false).contains(block.getType().toString().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ public class Transfuse extends EcoEnchant {
|
||||
|
||||
Material material;
|
||||
double random = NumberUtils.randFloat(0, 1);
|
||||
double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size();
|
||||
double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size();
|
||||
int selectedIndex = (int) Math.floor(random / band);
|
||||
selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1);
|
||||
String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex);
|
||||
selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size() - 1);
|
||||
String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).get(selectedIndex);
|
||||
material = Material.getMaterial(materialName.toUpperCase());
|
||||
if (material == null) {
|
||||
material = Material.COBBLESTONE;
|
||||
|
||||
@@ -39,7 +39,9 @@ public class Vein extends EcoEnchant {
|
||||
|
||||
List<Material> materials = Collections.singletonList(block.getType());
|
||||
|
||||
if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks").contains(block.getType().toString().toLowerCase())) {
|
||||
if (!this.getConfig()
|
||||
.getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks", false)
|
||||
.contains(block.getType().toString().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,10 @@ public class WoodSwitcher extends EcoEnchant {
|
||||
|
||||
Material material;
|
||||
double random = NumberUtils.randFloat(0, 1);
|
||||
double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size();
|
||||
double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size();
|
||||
int selectedIndex = (int) Math.floor(random / band);
|
||||
selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1);
|
||||
String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex);
|
||||
selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size() - 1);
|
||||
String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).get(selectedIndex);
|
||||
material = Material.getMaterial(materialName.toUpperCase());
|
||||
|
||||
if (material == null) {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Dynamite extends Spell {
|
||||
}
|
||||
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z));
|
||||
|
||||
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
|
||||
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks", false).contains(block1.getType().name().toLowerCase())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Rainbow extends EcoEnchant {
|
||||
|
||||
List<Material> materials = new ArrayList<>();
|
||||
|
||||
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items")) {
|
||||
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items", false)) {
|
||||
Material material = Material.getMaterial(materialName.toUpperCase());
|
||||
if (material != null) {
|
||||
materials.add(material);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SoftTouch extends EcoEnchant {
|
||||
name = name.replace("[", "").replace("]", "");
|
||||
meta.setDisplayName(name);
|
||||
|
||||
List<String> lore = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "lore");
|
||||
List<String> lore = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "lore", false);
|
||||
lore.replaceAll(s -> s.replace("%type%", entityName));
|
||||
meta.setLore(lore);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Xray extends Spell {
|
||||
|
||||
List<Material> materials = new ArrayList<>();
|
||||
|
||||
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks")) {
|
||||
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false)) {
|
||||
Material material = Material.getMaterial(materialName.toUpperCase());
|
||||
if (material != null) {
|
||||
materials.add(material);
|
||||
|
||||
Reference in New Issue
Block a user