Cleaned up code

This commit is contained in:
Auxilor
2020-12-22 14:50:57 +00:00
parent f46016287d
commit 668db3ed12
67 changed files with 184 additions and 246 deletions

View File

@@ -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;
}
/**

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}
}
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -1,4 +1,4 @@
package com.willfp.eco.util.factory;
public interface AbstractFactory<T> {
public interface AbstractFactory {
}

View File

@@ -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);
}

View File

@@ -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("");