Cleaned up code
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package com.willfp.eco.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class NumberUtils {
|
||||
|
||||
private final static TreeMap<Integer, String> NUMERALS = new TreeMap<>();
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final TreeMap<Integer, String> NUMERALS = new TreeMap<>();
|
||||
|
||||
static {
|
||||
|
||||
@@ -107,8 +108,7 @@ public class NumberUtils {
|
||||
* @return Random double
|
||||
*/
|
||||
public static double randFloat(double min, double max) {
|
||||
java.util.Random rand = new java.util.Random();
|
||||
return rand.nextFloat() * (max - min) + min;
|
||||
return RANDOM.nextFloat() * (max - min) + min;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.willfp.eco.util.factory.PluginDependentFactory;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
public class NamespacedKeyFactory extends PluginDependentFactory<NamespacedKey> {
|
||||
public class NamespacedKeyFactory extends PluginDependentFactory {
|
||||
public NamespacedKeyFactory(AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.willfp.eco.util.factory.PluginDependentFactory;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class MetadataValueFactory extends PluginDependentFactory<FixedMetadataValue> {
|
||||
public class MetadataValueFactory extends PluginDependentFactory {
|
||||
public MetadataValueFactory(AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@@ -14,14 +14,12 @@ public class DispenserArmorListener implements Listener {
|
||||
@EventHandler
|
||||
public void dispenseArmorEvent(BlockDispenseArmorEvent event) {
|
||||
ArmorType type = ArmorType.matchType(event.getItem());
|
||||
if (type != null) {
|
||||
if (event.getTargetEntity() instanceof Player) {
|
||||
Player p = (Player) event.getTargetEntity();
|
||||
ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, ArmorEquipEvent.EquipMethod.DISPENSER, type, null, event.getItem());
|
||||
Bukkit.getPluginManager().callEvent(armorEquipEvent);
|
||||
if (armorEquipEvent.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (type != null && event.getTargetEntity() instanceof Player) {
|
||||
Player p = (Player) event.getTargetEntity();
|
||||
ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, ArmorEquipEvent.EquipMethod.DISPENSER, type, null, event.getItem());
|
||||
Bukkit.getPluginManager().callEvent(armorEquipEvent);
|
||||
if (armorEquipEvent.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,6 @@ class EntityDeathByEntityBuilder {
|
||||
|
||||
private List<ItemStack> drops;
|
||||
private int xp = 0;
|
||||
private boolean dropItems;
|
||||
|
||||
public EntityDeathByEntityBuilder() {
|
||||
|
||||
}
|
||||
|
||||
public LivingEntity getVictim() {
|
||||
return this.victim;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
||||
}
|
||||
}
|
||||
|
||||
private void loadExtension(File extensionJar) throws MalformedExtensionException {
|
||||
private void loadExtension(File extensionJar) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = extensionJar.toURI().toURL();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.willfp.eco.util.factory;
|
||||
|
||||
public interface AbstractFactory<T> {
|
||||
public interface AbstractFactory {
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.willfp.eco.util.factory;
|
||||
import com.willfp.eco.util.injection.PluginDependent;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
|
||||
public abstract class PluginDependentFactory<T> extends PluginDependent implements AbstractFactory<T> {
|
||||
public abstract class PluginDependentFactory extends PluginDependent implements AbstractFactory {
|
||||
protected PluginDependentFactory(AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@@ -109,15 +109,15 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet());
|
||||
|
||||
this.getDefaultIntegrations().forEach((integrationLoader -> {
|
||||
StringBuilder log = new StringBuilder();
|
||||
log.append(integrationLoader.getPluginName()).append(": ");
|
||||
StringBuilder infoBuilder = new StringBuilder();
|
||||
infoBuilder.append(integrationLoader.getPluginName()).append(": ");
|
||||
if (enabledPlugins.contains(integrationLoader.getPluginName())) {
|
||||
integrationLoader.load();
|
||||
log.append("&aENABLED");
|
||||
infoBuilder.append("&aENABLED");
|
||||
} else {
|
||||
log.append("&9DISABLED");
|
||||
infoBuilder.append("&9DISABLED");
|
||||
}
|
||||
this.getLog().info(log.toString());
|
||||
this.getLog().info(infoBuilder.toString());
|
||||
}));
|
||||
this.getLog().info("");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user