Improved Codestyle (12/?)
This commit is contained in:
@@ -67,9 +67,7 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
this.getLog().info("&cNo extensions found");
|
||||
} else {
|
||||
this.getLog().info("Extensions Loaded:");
|
||||
this.getExtensionLoader().getLoadedExtensions().forEach((extension) -> {
|
||||
this.getLog().info("- " + extension.getName() + " v" + extension.getVersion());
|
||||
});
|
||||
this.getExtensionLoader().getLoadedExtensions().forEach(extension -> this.getLog().info("- " + extension.getName() + " v" + extension.getVersion()));
|
||||
}
|
||||
|
||||
this.getLog().info("");
|
||||
|
||||
@@ -71,9 +71,7 @@ public class CommandEnchantinfo extends AbstractCommand {
|
||||
}));
|
||||
|
||||
StringBuilder conflictNamesBuilder = new StringBuilder();
|
||||
conflictNames.forEach((name1) -> {
|
||||
conflictNamesBuilder.append(name1).append(", ");
|
||||
});
|
||||
conflictNames.forEach(name1 -> conflictNamesBuilder.append(name1).append(", "));
|
||||
String allConflicts = conflictNamesBuilder.toString();
|
||||
if (allConflicts.length() >= 2) {
|
||||
allConflicts = allConflicts.substring(0, allConflicts.length() - 2);
|
||||
@@ -104,9 +102,7 @@ public class CommandEnchantinfo extends AbstractCommand {
|
||||
}
|
||||
|
||||
StringBuilder targetNamesBuilder = new StringBuilder();
|
||||
applicableItemsSet.forEach((name1) -> {
|
||||
targetNamesBuilder.append(name1).append(", ");
|
||||
});
|
||||
applicableItemsSet.forEach(name1 -> targetNamesBuilder.append(name1).append(", "));
|
||||
String allTargets = targetNamesBuilder.toString();
|
||||
if (allTargets.length() >= 2) {
|
||||
allTargets = allTargets.substring(0, allTargets.length() - 2);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Target extends BaseConfig {
|
||||
|
||||
public Set<Material> getTargetMaterials(@NotNull final String target) {
|
||||
Set<Material> materials = new HashSet<>();
|
||||
this.getConfig().getStringList("targets." + target).forEach((materialName) -> {
|
||||
this.getConfig().getStringList("targets." + target).forEach(materialName -> {
|
||||
materials.add(Material.getMaterial(materialName.toUpperCase()));
|
||||
});
|
||||
|
||||
|
||||
@@ -35,12 +35,8 @@ public class EnchantDisplay implements Updatable {
|
||||
/**
|
||||
* The meta key to hide enchantments in lore
|
||||
* <p>
|
||||
* Only used for parity in {@link com.willfp.ecoenchants.display.packets.PacketSetCreativeSlot}.
|
||||
* More robust method to be introduced
|
||||
*
|
||||
* @deprecated Temporary fix
|
||||
* EcoEnchants packet lore implementation of HideEnchants.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final NamespacedKey KEY_SKIP = PLUGIN.getNamespacedKeyFactory().create("ecoenchantlore-skip");
|
||||
|
||||
/**
|
||||
@@ -75,7 +71,6 @@ public class EnchantDisplay implements Updatable {
|
||||
* It isn't recommended to mess with this unless you <b>really</b> know your way around EcoEnchants.
|
||||
*
|
||||
* @param item The item to modify
|
||||
*
|
||||
* @return The item, with KEY_V
|
||||
*/
|
||||
public static ItemStack addV(@Nullable final ItemStack item) {
|
||||
@@ -93,7 +88,6 @@ public class EnchantDisplay implements Updatable {
|
||||
* Revert display
|
||||
*
|
||||
* @param item The item to revert
|
||||
*
|
||||
* @return The item, updated
|
||||
*/
|
||||
public static ItemStack revertDisplay(@Nullable final ItemStack item) {
|
||||
@@ -140,7 +134,6 @@ public class EnchantDisplay implements Updatable {
|
||||
* Show all enchantments in item lore
|
||||
*
|
||||
* @param item The item to update
|
||||
*
|
||||
* @return The item, updated
|
||||
*/
|
||||
public static ItemStack displayEnchantments(@Nullable final ItemStack item,
|
||||
@@ -245,7 +238,7 @@ public class EnchantDisplay implements Updatable {
|
||||
if (OPTIONS.isUseShrink() && (enchantments.size() > OPTIONS.getShrinkThreshold())) {
|
||||
List<List<String>> partitionedCombinedLoreList = Lists.partition(lore, OPTIONS.getShrinkPerLine());
|
||||
List<String> newLore = new ArrayList<>();
|
||||
partitionedCombinedLoreList.forEach((list) -> {
|
||||
partitionedCombinedLoreList.forEach(list -> {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String s : list) {
|
||||
builder.append(s);
|
||||
|
||||
@@ -539,20 +539,16 @@ public final class EcoEnchants implements Updatable {
|
||||
|
||||
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) != null && 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);
|
||||
}
|
||||
item.getEnchantments().forEach((enchantment, integer) -> {
|
||||
if (getFromEnchantment(enchantment) != null && (getFromEnchantment(enchantment).getType().equals(type))) {
|
||||
hasOfType.set(true);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
return hasOfType.get();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Aerial extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
event.getProjectile().setMetadata("shot-in-air", new FixedMetadataValue(this.getPlugin(), true));
|
||||
event.getProjectile().setMetadata("shot-in-air", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Atmospheric extends EcoEnchant {
|
||||
@@ -25,7 +24,7 @@ public class Atmospheric extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
trident.setMetadata("shot-in-air", new FixedMetadataValue(this.getPlugin(), true));
|
||||
trident.setMetadata("shot-in-air", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,7 +71,7 @@ public class BlastMining extends EcoEnchant {
|
||||
}
|
||||
|
||||
toBreak.forEach((block1 -> {
|
||||
block1.setMetadata("block-ignore", new FixedMetadataValue(this.getPlugin(), true));
|
||||
block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
ProxyUtils.getProxy(BlockBreakProxy.class).breakBlock(player, block1);
|
||||
block1.removeMetadata("block-ignore", this.getPlugin());
|
||||
}));
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Cleave extends EcoEnchant {
|
||||
.filter(entity -> entity instanceof LivingEntity)
|
||||
.filter(entity -> !entity.equals(attacker))
|
||||
.forEach(entity -> {
|
||||
entity.setMetadata("cleaved", new FixedMetadataValue(this.getPlugin(), true));
|
||||
entity.setMetadata("cleaved", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
((LivingEntity) entity).damage(damage, attacker);
|
||||
this.getPlugin().getScheduler().runLater(() -> entity.removeMetadata("cleaved", this.getPlugin()), 5);
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Conclude extends EcoEnchant {
|
||||
}
|
||||
|
||||
double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level");
|
||||
if (!(victim.getHealth() <= level * minhealth)) {
|
||||
if (victim.getHealth() > level * minhealth) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Drill extends EcoEnchant {
|
||||
for (int i = 1; i <= blocks; i++) {
|
||||
Vector simplified = VectorUtils.simplifyVector(player.getLocation().getDirection().normalize()).multiply(i);
|
||||
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(simplified));
|
||||
block1.setMetadata("block-ignore", new FixedMetadataValue(this.getPlugin(), true));
|
||||
block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
|
||||
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
|
||||
continue;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Lumberjack extends EcoEnchant {
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
||||
for (Block treeBlock : treeBlocks) {
|
||||
treeBlock.setMetadata("block-ignore", new FixedMetadataValue(this.getPlugin(), true));
|
||||
treeBlock.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
if (!AntigriefManager.canBreakBlock(player, treeBlock)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -71,7 +70,7 @@ public class MagmaWalker extends EcoEnchant {
|
||||
|
||||
block.setType(Material.OBSIDIAN);
|
||||
|
||||
block.setMetadata("byMagmaWalker", new FixedMetadataValue(this.getPlugin(), true));
|
||||
block.setMetadata("byMagmaWalker", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
|
||||
long afterTicks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "remove-after-ticks");
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Marking extends EcoEnchant {
|
||||
int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
|
||||
int ticks = ticksPerLevel * level;
|
||||
|
||||
victim.setMetadata("marked", new FixedMetadataValue(this.getPlugin(), true));
|
||||
victim.setMetadata("marked", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
|
||||
this.getPlugin().getScheduler().runLater(() -> victim.removeMetadata("marked", this.getPlugin()), ticks);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Shockwave extends EcoEnchant {
|
||||
.filter(entity1 -> !entity1.hasMetadata("shockwaved"))
|
||||
.forEach((mob -> {
|
||||
((LivingEntity) mob).damage(finalDamage, player);
|
||||
mob.setMetadata("shockwaved", new FixedMetadataValue(this.getPlugin(), true));
|
||||
mob.setMetadata("shockwaved", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
this.getPlugin().getScheduler().runLater(() -> mob.removeMetadata("shockwaved", this.getPlugin()), 10);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Vein extends EcoEnchant {
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
||||
for (Block veinBlock : blockSet) {
|
||||
veinBlock.setMetadata("block-ignore", new FixedMetadataValue(this.getPlugin(), true));
|
||||
veinBlock.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
if (!AntigriefManager.canBreakBlock(player, veinBlock)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Weakening extends EcoEnchant {
|
||||
int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
|
||||
int ticks = ticksPerLevel * level;
|
||||
|
||||
victim.setMetadata("weak", new FixedMetadataValue(this.getPlugin(), true));
|
||||
victim.setMetadata("weak", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
|
||||
this.getPlugin().getScheduler().runLater(() -> victim.removeMetadata("weak", this.getPlugin()), ticks);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Carve extends EcoEnchant {
|
||||
.filter(entity -> entity instanceof LivingEntity)
|
||||
.filter(entity -> !entity.equals(attacker))
|
||||
.forEach(entity -> {
|
||||
entity.setMetadata("carved", new FixedMetadataValue(this.getPlugin(), true));
|
||||
entity.setMetadata("carved", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
((LivingEntity) entity).damage(damage, attacker);
|
||||
this.getPlugin().getScheduler().runLater(() -> entity.removeMetadata("carved", this.getPlugin()), 20);
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Soulbound extends EcoEnchant {
|
||||
soulboundItems.add(itemStack);
|
||||
}
|
||||
|
||||
if (itemStack.getItemMeta() instanceof EnchantmentStorageMeta && (((EnchantmentStorageMeta) itemStack.getItemMeta()).getStoredEnchants().containsKey(this))) {
|
||||
if (itemStack.getItemMeta() instanceof EnchantmentStorageMeta && (((EnchantmentStorageMeta) itemStack.getItemMeta()).getStoredEnchants().containsKey(this.getEnchantment()))) {
|
||||
soulboundItems.add(itemStack);
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -24,7 +23,7 @@ public class Ascend extends Spell {
|
||||
@NotNull final PlayerInteractEvent event) {
|
||||
int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level") * level;
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, ticks, this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "power") - 1, false, false));
|
||||
player.setMetadata(IGNORE_FALL_KEY, new FixedMetadataValue(this.getPlugin(), true));
|
||||
player.setMetadata(IGNORE_FALL_KEY, this.getPlugin().getMetadataValueFactory().create(true));
|
||||
this.getPlugin().getScheduler().runLater(() -> player.removeMetadata(IGNORE_FALL_KEY, this.getPlugin()), ticks * 4L);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Dynamite extends Spell {
|
||||
}
|
||||
|
||||
toBreak.forEach((block1 -> {
|
||||
block1.setMetadata("block-ignore", new FixedMetadataValue(this.getPlugin(), true));
|
||||
block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
ProxyUtils.getProxy(BlockBreakProxy.class).breakBlock(player, block1);
|
||||
block1.removeMetadata("block-ignore", this.getPlugin());
|
||||
}));
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Missile extends Spell {
|
||||
@@ -24,8 +23,8 @@ public class Missile extends Spell {
|
||||
WitherSkull skull = player.launchProjectile(WitherSkull.class, player.getEyeLocation().getDirection().multiply(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity")));
|
||||
skull.setCharged(true);
|
||||
skull.setIsIncendiary(false);
|
||||
skull.setMetadata("eco-damage", new FixedMetadataValue(this.getPlugin(), this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level));
|
||||
skull.setMetadata("nobreak", new FixedMetadataValue(this.getPlugin(), true));
|
||||
skull.setMetadata("eco-damage", this.getPlugin().getMetadataValueFactory().create(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level));
|
||||
skull.setMetadata("nobreak", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
skull.setShooter(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Firewand extends Spell {
|
||||
@@ -24,9 +23,9 @@ public class Firewand extends Spell {
|
||||
@NotNull final PlayerInteractEvent event) {
|
||||
SmallFireball fireball = player.launchProjectile(SmallFireball.class, player.getEyeLocation().getDirection().multiply(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity")));
|
||||
fireball.setIsIncendiary(this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "fire"));
|
||||
fireball.setMetadata("eco-damage", new FixedMetadataValue(this.getPlugin(), this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level));
|
||||
fireball.setMetadata("eco-damage", this.getPlugin().getMetadataValueFactory().create(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level));
|
||||
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "no-explode")) {
|
||||
fireball.setMetadata("nobreak", new FixedMetadataValue(this.getPlugin(), true));
|
||||
fireball.setMetadata("nobreak", this.getPlugin().getMetadataValueFactory().create(true));
|
||||
}
|
||||
fireball.setShooter(player);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class SummoningEnchantment extends EcoEnchant {
|
||||
@@ -111,8 +110,7 @@ public abstract class SummoningEnchantment extends EcoEnchant {
|
||||
health = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||
}
|
||||
entity.setHealth(health);
|
||||
entity.setMetadata("eco-target", new FixedMetadataValue(this.getPlugin(), victim));
|
||||
|
||||
entity.setMetadata("eco-target", this.getPlugin().getMetadataValueFactory().create(victim));
|
||||
this.getPlugin().getScheduler().runLater(entity::remove, ticksToLive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
||||
Object object = null;
|
||||
try {
|
||||
cls = cl.loadClass(mainClass);
|
||||
object = cls.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
|
||||
object = cls.getConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user