mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-25 15:35:11 +01:00
Continued improving codestyle
This commit is contained in:
parent
c387f06cfc
commit
25d6231e44
@ -86,7 +86,8 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
this.getLog().info(EcoEnchants.values().size() + " Enchantments Loaded:");
|
||||
this.getLog().info(EcoEnchants.values().stream().map(ecoEnchant -> ecoEnchant.getType().getColor() + ecoEnchant.getName()).collect(Collectors.joining(", ")));
|
||||
|
||||
Bukkit.getServicesManager().load(TelekinesisTests.class).registerTest(player -> ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(player.getInventory().getItemInMainHand(), EcoEnchants.TELEKINESIS) > 0);
|
||||
Bukkit.getServicesManager().load(TelekinesisTests.class)
|
||||
.registerTest(player -> ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(player.getInventory().getItemInMainHand(), EcoEnchants.TELEKINESIS) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +125,9 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
HandlerList.unregisterAll(ecoEnchant);
|
||||
|
||||
this.getScheduler().runLater(() -> {
|
||||
if (ecoEnchant.isEnabled()) this.getEventManager().registerListener(ecoEnchant);
|
||||
if (ecoEnchant.isEnabled()) {
|
||||
this.getEventManager().registerListener(ecoEnchant);
|
||||
}
|
||||
}, 1);
|
||||
}));
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ public class EcoEnchantsConfigs implements Updatable {
|
||||
/**
|
||||
* target.yml.
|
||||
*/
|
||||
public final Target TARGET = new Target();
|
||||
public static final Target TARGET = new Target();
|
||||
|
||||
/**
|
||||
* rarity.yml.
|
||||
*/
|
||||
public final Rarity RARITY = new Rarity();
|
||||
public static final Rarity RARITY = new Rarity();
|
||||
|
||||
/**
|
||||
* All enchantment-specific configs.
|
||||
|
@ -227,11 +227,11 @@ import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Missile;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Quake;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Vitalize;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -242,7 +242,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* Contains general methods for EcoEnchants
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@UtilityClass
|
||||
public class EcoEnchants implements Updatable {
|
||||
public static final String CONFIG_LOCATION = "config.";
|
||||
public static final String OBTAINING_LOCATION = "obtaining.";
|
||||
@ -498,7 +497,7 @@ public class EcoEnchants implements Updatable {
|
||||
*
|
||||
* @return The matching {@link EcoEnchant}, or null if not found.
|
||||
*/
|
||||
public static EcoEnchant getByName(String name) {
|
||||
public static EcoEnchant getByName(@NotNull final String name) {
|
||||
Optional<EcoEnchant> matching = values().stream().filter(enchant -> enchant.getName().equalsIgnoreCase(name)).findFirst();
|
||||
return matching.orElse(null);
|
||||
}
|
||||
@ -510,7 +509,7 @@ public class EcoEnchants implements Updatable {
|
||||
*
|
||||
* @return The matching {@link EcoEnchant}, or null if not found.
|
||||
*/
|
||||
public static EcoEnchant getByPermission(String permissionName) {
|
||||
public static EcoEnchant getByPermission(@NotNull final String permissionName) {
|
||||
Optional<EcoEnchant> matching = values().stream().filter(enchant -> enchant.getPermissionName().equalsIgnoreCase(permissionName)).findFirst();
|
||||
return matching.orElse(null);
|
||||
}
|
||||
@ -522,7 +521,7 @@ public class EcoEnchants implements Updatable {
|
||||
*
|
||||
* @return The matching {@link EcoEnchant}, or null if not found.
|
||||
*/
|
||||
public static EcoEnchant getByKey(NamespacedKey key) {
|
||||
public static EcoEnchant getByKey(@NotNull final NamespacedKey key) {
|
||||
return BY_KEY.get(key);
|
||||
}
|
||||
|
||||
@ -534,21 +533,24 @@ public class EcoEnchants implements Updatable {
|
||||
*
|
||||
* @return True if has, false if doesn't have.
|
||||
*/
|
||||
public static boolean hasAnyOfType(ItemStack item, EnchantmentType type) {
|
||||
if (item == null) return false;
|
||||
|
||||
public static boolean hasAnyOfType(@NotNull final ItemStack item,
|
||||
@NotNull final EnchantmentType type) {
|
||||
AtomicBoolean hasOfType = new AtomicBoolean(false);
|
||||
|
||||
if (item.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
((EnchantmentStorageMeta) item.getItemMeta()).getStoredEnchants().forEach(((enchantment, integer) -> {
|
||||
if (getFromEnchantment(enchantment) != null) {
|
||||
if (getFromEnchantment(enchantment).getType().equals(type)) hasOfType.set(true);
|
||||
if (getFromEnchantment(enchantment).getType().equals(type)) {
|
||||
hasOfType.set(true);
|
||||
}
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
item.getEnchantments().forEach(((enchantment, integer) -> {
|
||||
if (getFromEnchantment(enchantment) != null) {
|
||||
if (getFromEnchantment(enchantment).getType().equals(type)) hasOfType.set(true);
|
||||
if (getFromEnchantment(enchantment).getType().equals(type)) {
|
||||
hasOfType.set(true);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -572,7 +574,7 @@ public class EcoEnchants implements Updatable {
|
||||
*
|
||||
* @param enchant The {@link EcoEnchant} to add
|
||||
*/
|
||||
public static void addNewEcoEnchant(EcoEnchant enchant) {
|
||||
public static void addNewEcoEnchant(@NotNull final EcoEnchant enchant) {
|
||||
BY_KEY.remove(enchant.getKey());
|
||||
BY_KEY.put(enchant.getKey(), enchant);
|
||||
}
|
||||
@ -582,7 +584,11 @@ public class EcoEnchants implements Updatable {
|
||||
*
|
||||
* @param enchant The {@link EcoEnchant} to remove
|
||||
*/
|
||||
public static void removeEcoEnchant(EcoEnchant enchant) {
|
||||
public static void removeEcoEnchant(@NotNull final EcoEnchant enchant) {
|
||||
BY_KEY.remove(enchant.getKey());
|
||||
}
|
||||
|
||||
private EcoEnchants() {
|
||||
throw new UnsupportedOperationException("Utility class cannot be instantiated!");
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Economical extends EcoEnchant {
|
||||
public Economical() {
|
||||
@ -17,7 +18,7 @@ public class Economical extends EcoEnchant {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onElytraBoost(PlayerElytraBoostEvent event) {
|
||||
public void onElytraBoost(@NotNull final PlayerElytraBoostEvent event) {
|
||||
if(!EnchantChecks.chestplate(event.getPlayer(), this))
|
||||
return;
|
||||
if(!EnchantmentUtils.passedChance(this, EnchantChecks.getArmorPoints(event.getPlayer(), this)))
|
||||
|
@ -49,11 +49,14 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
||||
|
||||
File[] extensionJars = dir.listFiles();
|
||||
|
||||
if (extensionJars == null)
|
||||
if (extensionJars == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File extensionJar : extensionJars) {
|
||||
if (!extensionJar.isFile()) continue;
|
||||
if (!extensionJar.isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
loadExtension(extensionJar);
|
||||
@ -63,7 +66,7 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
||||
}
|
||||
}
|
||||
|
||||
private void loadExtension(File extensionJar) {
|
||||
private void loadExtension(@NotNull final File extensionJar) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = extensionJar.toURI().toURL();
|
||||
@ -102,8 +105,9 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!(object instanceof Extension))
|
||||
if (!(object instanceof Extension)) {
|
||||
throw new MalformedExtensionException(extensionJar.getName() + " is invalid");
|
||||
}
|
||||
|
||||
Extension extension = (Extension) object;
|
||||
extension.setMetadata(metadata);
|
||||
|
Loading…
Reference in New Issue
Block a user