mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-23 00:31:20 +01:00
Cleaned up code
This commit is contained in:
parent
f46016287d
commit
668db3ed12
@ -73,11 +73,11 @@ public class ChatComponent implements ChatComponentProxy {
|
||||
}
|
||||
|
||||
private static ItemStack getFromTag(String jsonTag, String id) {
|
||||
id = id.replaceAll("minecraft:", "");
|
||||
id = id.replace("minecraft:", "");
|
||||
id = id.toUpperCase();
|
||||
id = id.replaceAll("\"", "");
|
||||
id = id.replace("\"", "");
|
||||
jsonTag = jsonTag.substring(1, jsonTag.length() - 1);
|
||||
jsonTag = jsonTag.replaceAll("id:", "\"id\":");
|
||||
jsonTag = jsonTag.replace("id:", "\"id\":");
|
||||
jsonTag = jsonTag.replace("\\", "");
|
||||
Material material = Material.getMaterial(id);
|
||||
|
||||
|
@ -73,11 +73,11 @@ public class ChatComponent implements ChatComponentProxy {
|
||||
}
|
||||
|
||||
private static ItemStack getFromTag(String jsonTag, String id) {
|
||||
id = id.replaceAll("minecraft:", "");
|
||||
id = id.replace("minecraft:", "");
|
||||
id = id.toUpperCase();
|
||||
id = id.replaceAll("\"", "");
|
||||
id = id.replace("\"", "");
|
||||
jsonTag = jsonTag.substring(1, jsonTag.length() - 1);
|
||||
jsonTag = jsonTag.replaceAll("id:", "\"id\":");
|
||||
jsonTag = jsonTag.replace("id:", "\"id\":");
|
||||
jsonTag = jsonTag.replace("\\", "");
|
||||
Material material = Material.getMaterial(id);
|
||||
|
||||
|
@ -73,11 +73,11 @@ public class ChatComponent implements ChatComponentProxy {
|
||||
}
|
||||
|
||||
private static ItemStack getFromTag(String jsonTag, String id) {
|
||||
id = id.replaceAll("minecraft:", "");
|
||||
id = id.replace("minecraft:", "");
|
||||
id = id.toUpperCase();
|
||||
id = id.replaceAll("\"", "");
|
||||
id = id.replace("\"", "");
|
||||
jsonTag = jsonTag.substring(1, jsonTag.length() - 1);
|
||||
jsonTag = jsonTag.replaceAll("id:", "\"id\":");
|
||||
jsonTag = jsonTag.replace("id:", "\"id\":");
|
||||
jsonTag = jsonTag.replace("\\", "");
|
||||
Material material = Material.getMaterial(id);
|
||||
|
||||
|
@ -56,9 +56,9 @@ public class CommandEnchantinfo extends AbstractCommand {
|
||||
Set<Enchantment> conflicts = enchantment.getConflicts();
|
||||
|
||||
new HashSet<>(conflicts).forEach(enchantment1 -> {
|
||||
if (EcoEnchants.getFromEnchantment(enchantment1) != null) {
|
||||
if (!EcoEnchants.getFromEnchantment(enchantment1).isEnabled())
|
||||
conflicts.remove(enchantment1);
|
||||
EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment1);
|
||||
if (ecoEnchant != null && !ecoEnchant.isEnabled()) {
|
||||
conflicts.remove(enchantment1);
|
||||
}
|
||||
});
|
||||
|
||||
@ -89,7 +89,7 @@ public class CommandEnchantinfo extends AbstractCommand {
|
||||
enchantment.getRawTargets().forEach(target -> {
|
||||
String targetName = target.getName();
|
||||
targetName = targetName.toLowerCase();
|
||||
targetName = targetName.replaceAll("_", " ");
|
||||
targetName = targetName.replace("_", " ");
|
||||
targetName = WordUtils.capitalize(targetName);
|
||||
applicableItemsSet.add(targetName);
|
||||
});
|
||||
@ -97,7 +97,7 @@ public class CommandEnchantinfo extends AbstractCommand {
|
||||
targets.forEach(material -> {
|
||||
String matName = material.toString();
|
||||
matName = matName.toLowerCase();
|
||||
matName = matName.replaceAll("_", " ");
|
||||
matName = matName.replace("_", " ");
|
||||
matName = WordUtils.capitalize(matName);
|
||||
applicableItemsSet.add(matName);
|
||||
});
|
||||
@ -122,11 +122,11 @@ public class CommandEnchantinfo extends AbstractCommand {
|
||||
final String finalConflicts = allConflicts;
|
||||
final String finalMaxLevel = maxLevel;
|
||||
Arrays.asList(Configs.LANG.getMessage("enchantinfo").split("\\r?\\n")).forEach((string -> {
|
||||
string = string.replaceAll("%name%", finalName)
|
||||
.replaceAll("%description%", finalDescription)
|
||||
.replaceAll("%target%", finalTargets)
|
||||
.replaceAll("%conflicts%", finalConflicts)
|
||||
.replaceAll("%maxlevel%", finalMaxLevel);
|
||||
string = string.replace("%name%", finalName)
|
||||
.replace("%description%", finalDescription)
|
||||
.replace("%target%", finalTargets)
|
||||
.replace("%conflicts%", finalConflicts)
|
||||
.replace("%maxlevel%", finalMaxLevel);
|
||||
sender.sendMessage(string);
|
||||
}));
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public abstract class EnchantmentYamlConfig extends PluginDependent {
|
||||
* @param source The class of the main class of source or extension
|
||||
* @param type The enchantment type
|
||||
*/
|
||||
public EnchantmentYamlConfig(String name, Class<?> source, EnchantmentType type) {
|
||||
protected EnchantmentYamlConfig(String name, Class<?> source, EnchantmentType type) {
|
||||
super(AbstractEcoPlugin.getInstance());
|
||||
this.name = name;
|
||||
this.source = source;
|
||||
|
@ -88,7 +88,7 @@ public class EnchantmentConfig extends EnchantmentYamlConfig {
|
||||
|
||||
public Set<EnchantmentTarget> getTargets() {
|
||||
List<String> targetNames = config.getStringList(EcoEnchants.GENERAL_LOCATION + "targets");
|
||||
if (targetNames == null || targetNames.isEmpty()) return new HashSet<>();
|
||||
if (targetNames.isEmpty()) return new HashSet<>();
|
||||
Set<EnchantmentTarget> targets = new HashSet<>();
|
||||
|
||||
targetNames.forEach((s -> {
|
||||
|
@ -134,9 +134,8 @@ public class EnchantDisplay {
|
||||
if (item == null || item.getItemMeta() == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType()))
|
||||
return item;
|
||||
|
||||
if (item.getItemMeta().getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) {
|
||||
if (hideEnchants)
|
||||
hideEnchants = false;
|
||||
if (item.getItemMeta().getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER) && hideEnchants) {
|
||||
hideEnchants = false;
|
||||
}
|
||||
|
||||
revertDisplay(item);
|
||||
|
@ -58,10 +58,8 @@ public class EnchantmentCache {
|
||||
|
||||
color = type.getColor();
|
||||
|
||||
if (rarity != null) {
|
||||
if (rarity.hasCustomColor() && type != EnchantmentType.CURSE) {
|
||||
color = rarity.getCustomColor();
|
||||
}
|
||||
if (rarity != null && rarity.hasCustomColor() && type != EnchantmentType.CURSE) {
|
||||
color = rarity.getCustomColor();
|
||||
}
|
||||
|
||||
String rawName = name;
|
||||
@ -96,9 +94,9 @@ public class EnchantmentCache {
|
||||
descriptionBuilder.append(" ");
|
||||
});
|
||||
|
||||
String stringDescription = descriptionBuilder.toString();
|
||||
stringDescription = stringDescription.replaceAll("§w", "");
|
||||
this.stringDescription = stringDescription.replaceAll(EnchantDisplay.OPTIONS.getDescriptionColor(), "");
|
||||
String processedStringDescription = descriptionBuilder.toString();
|
||||
processedStringDescription = processedStringDescription.replace("§w", "");
|
||||
this.stringDescription = processedStringDescription.replaceAll(EnchantDisplay.OPTIONS.getDescriptionColor(), "");
|
||||
}
|
||||
|
||||
public Enchantment getEnchantment() {
|
||||
|
@ -73,7 +73,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
super(NamespacedKey.minecraft(key));
|
||||
|
||||
this.type = type;
|
||||
this.permissionName = key.replaceAll("_", "");
|
||||
this.permissionName = key.replace("_", "");
|
||||
EcoEnchantsConfigs.addEnchantmentConfig(new EnchantmentConfig(this.permissionName, this.getClass(), this.type));
|
||||
this.config = EcoEnchantsConfigs.getEnchantmentConfig(this.permissionName);
|
||||
|
||||
|
@ -245,7 +245,6 @@ public class EcoEnchants {
|
||||
public static final String OBTAINING_LOCATION = "obtaining.";
|
||||
public static final String GENERAL_LOCATION = "general-config.";
|
||||
|
||||
private static final List<EcoEnchant> ecoEnchants = new ArrayList<>();
|
||||
private static final Map<NamespacedKey, EcoEnchant> byKey = new HashMap<>();
|
||||
|
||||
public static final EcoEnchant TELEKINESIS = new Telekinesis();
|
||||
@ -475,7 +474,7 @@ public class EcoEnchants {
|
||||
* @return A list of all {@link EcoEnchant}s
|
||||
*/
|
||||
public static List<EcoEnchant> values() {
|
||||
return ImmutableList.copyOf(ecoEnchants);
|
||||
return ImmutableList.copyOf(byKey.values());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -570,8 +569,6 @@ public class EcoEnchants {
|
||||
* @param enchant The {@link EcoEnchant} to add
|
||||
*/
|
||||
public static void addNewEcoEnchant(EcoEnchant enchant) {
|
||||
ecoEnchants.remove(enchant);
|
||||
ecoEnchants.add(enchant);
|
||||
byKey.remove(enchant.getKey());
|
||||
byKey.put(enchant.getKey(), enchant);
|
||||
}
|
||||
@ -582,7 +579,6 @@ public class EcoEnchants {
|
||||
* @param enchant The {@link EcoEnchant} to remove
|
||||
*/
|
||||
public static void removeEcoEnchant(EcoEnchant enchant) {
|
||||
ecoEnchants.remove(enchant);
|
||||
byKey.remove(enchant.getKey());
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ public class BlastMining extends EcoEnchant {
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) {
|
||||
if (block.hasMetadata("block-ignore"))
|
||||
|
@ -25,9 +25,8 @@ public class Cleave extends EcoEnchant {
|
||||
if (victim.hasMetadata("cleaved"))
|
||||
return;
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
double damagePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-percentage-per-level") * 0.01;
|
||||
|
@ -24,9 +24,8 @@ public class Disable extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
|
@ -23,9 +23,8 @@ public class Dullness extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
@ -7,7 +8,6 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
public class EnderSlayer extends EcoEnchant {
|
||||
public EnderSlayer() {
|
||||
@ -18,12 +18,13 @@ public class EnderSlayer extends EcoEnchant {
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
private static final Set<EntityType> endMobs = new HashSet<EntityType>() {{
|
||||
add(EntityType.ENDERMITE);
|
||||
add(EntityType.ENDERMAN);
|
||||
add(EntityType.ENDER_DRAGON);
|
||||
add(EntityType.SHULKER);
|
||||
}};
|
||||
private static final Set<EntityType> endMobs = new ImmutableSet.Builder<EntityType>()
|
||||
.add(EntityType.ENDERMITE)
|
||||
.add(EntityType.ENDERMAN)
|
||||
.add(EntityType.ENDER_DRAGON)
|
||||
.add(EntityType.SHULKER)
|
||||
.build();
|
||||
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
|
@ -24,9 +24,8 @@ public class Famine extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if (attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class FirstStrike extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if (!(victim.getHealth() == victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
|
||||
if (victim.getHealth() != victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())
|
||||
return;
|
||||
|
||||
double damage = event.getDamage();
|
||||
|
@ -26,9 +26,8 @@ public class Fury extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if (attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class Grit extends EcoEnchant {
|
||||
|
||||
int damage = (int) Math.ceil(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * totalGritPoints);
|
||||
|
||||
DurabilityUtils.damageItem(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot());
|
||||
DurabilityUtils.damageItem(player, player.getInventory().getItemInMainHand(), damage, player.getInventory().getHeldItemSlot());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,9 +24,8 @@ public class IllusionAspect extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,12 +64,10 @@ public class MagmaWalker extends EcoEnchant {
|
||||
BukkitRunnable replace = new EcoBukkitRunnable(this.plugin) {
|
||||
@Override
|
||||
public void run() {
|
||||
if (block.getType().equals(Material.OBSIDIAN)) {
|
||||
if(!player.getWorld().getBlockAt(player.getLocation().add(0, -1, 0)).equals(block)) {
|
||||
block.setType(Material.LAVA);
|
||||
block.removeMetadata("byMagmaWalker", this.plugin);
|
||||
this.cancel();
|
||||
}
|
||||
if (block.getType().equals(Material.OBSIDIAN) && !player.getWorld().getBlockAt(player.getLocation().add(0, -1, 0)).equals(block)) {
|
||||
block.setType(Material.LAVA);
|
||||
block.removeMetadata("byMagmaWalker", this.plugin);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -65,10 +65,8 @@ public class Magnetic extends EcoEnchant implements EcoRunnable {
|
||||
for (Entity e : player.getWorld().getNearbyEntities(player.getLocation(), distance, 2.0d, distance)) {
|
||||
if(!(e instanceof Item || e instanceof ExperienceOrb)) continue;
|
||||
|
||||
if (e instanceof Item) {
|
||||
if (((Item) e).getPickupDelay() > 0) {
|
||||
continue;
|
||||
}
|
||||
if (e instanceof Item && ((Item) e).getPickupDelay() > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector vector = player.getLocation().toVector().subtract(e.getLocation().toVector()).normalize().multiply(0.1 * level);
|
||||
|
@ -30,8 +30,6 @@ public class ShotAssist extends EcoEnchant {
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
int points = EnchantChecks.getArmorPoints(player, this, 0);
|
||||
|
||||
|
@ -24,9 +24,8 @@ public class StrayAspect extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
@ -34,10 +34,8 @@ public class Succession extends EcoEnchant {
|
||||
arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
|
||||
if(fire) arrow1.setFireTicks(Integer.MAX_VALUE);
|
||||
|
||||
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "per-arrow-damage")) {
|
||||
if(shooter instanceof Player) {
|
||||
DurabilityUtils.damageItem((Player) shooter, ((Player) shooter).getInventory().getItemInMainHand(), 1, ((Player) shooter).getInventory().getHeldItemSlot());
|
||||
}
|
||||
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "per-arrow-damage") && shooter instanceof Player) {
|
||||
DurabilityUtils.damageItem((Player) shooter, ((Player) shooter).getInventory().getItemInMainHand(), 1, ((Player) shooter).getInventory().getHeldItemSlot());
|
||||
}
|
||||
}, i * 2L);
|
||||
}
|
||||
|
@ -22,9 +22,8 @@ public class Supercritical extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
|
@ -131,10 +131,8 @@ public class Telekinesis extends EcoEnchant {
|
||||
int xp = event.getDroppedExp();
|
||||
Collection<ItemStack> drops = event.getDrops();
|
||||
|
||||
if(entity instanceof Player) {
|
||||
if(Soulbound.getSoulboundItems((Player) entity) != null) {
|
||||
drops.removeAll(Soulbound.getSoulboundItems((Player) entity));
|
||||
}
|
||||
if(entity instanceof Player && Soulbound.getSoulboundItems((Player) entity) != null) {
|
||||
drops.removeAll(Soulbound.getSoulboundItems((Player) entity));
|
||||
}
|
||||
|
||||
new DropQueue(player)
|
||||
|
@ -23,9 +23,8 @@ public class Thor extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if (attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EnchantmentUtils.passedChance(this, level))
|
||||
|
@ -24,9 +24,8 @@ public class Toxic extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if (attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EnchantmentUtils.passedChance(this, level))
|
||||
|
@ -24,9 +24,8 @@ public class VampireAspect extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
|
@ -23,9 +23,8 @@ public class Bolt extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
@ -31,9 +31,8 @@ public class Carve extends EcoEnchant {
|
||||
final double damage = damagePerLevel * level * event.getDamage();
|
||||
final double radius = radiusPerLevel * level;
|
||||
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
victim.getNearbyEntities(radius, radius, radius).stream()
|
||||
|
@ -29,10 +29,10 @@ public class Confusion extends EcoEnchant {
|
||||
if(!(uncastVictim instanceof Player)) return;
|
||||
Player victim = (Player) uncastVictim;
|
||||
|
||||
if(attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
|
@ -24,10 +24,8 @@ public class Razor extends EcoEnchant {
|
||||
double perLevelMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-damage");
|
||||
double extra = level*perLevelMultiplier + baseDamage;
|
||||
if(this.getConfig().getBool((EcoEnchants.CONFIG_LOCATION) + "decrease-if-cooldown")) {
|
||||
if(attacker instanceof Player) {
|
||||
extra *= ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker);
|
||||
}
|
||||
if(this.getConfig().getBool((EcoEnchants.CONFIG_LOCATION) + "decrease-if-cooldown") && attacker instanceof Player) {
|
||||
extra *= ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker);
|
||||
}
|
||||
|
||||
event.setDamage(event.getDamage() + extra);
|
||||
|
@ -43,9 +43,7 @@ public class Soulbound extends EcoEnchant {
|
||||
Arrays.stream(player.getInventory().getContents()).filter(Objects::nonNull).forEach((itemStack -> {
|
||||
if(itemStack.containsEnchantment(this)) soulboundItems.add(itemStack);
|
||||
|
||||
if(itemStack.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
if(((EnchantmentStorageMeta) itemStack.getItemMeta()).getStoredEnchants().containsKey(this)) soulboundItems.add(itemStack);
|
||||
}
|
||||
if(itemStack.getItemMeta() instanceof EnchantmentStorageMeta && (((EnchantmentStorageMeta) itemStack.getItemMeta()).getStoredEnchants().containsKey(this))) soulboundItems.add(itemStack);
|
||||
}));
|
||||
|
||||
event.getDrops().removeAll(soulboundItems);
|
||||
|
@ -39,12 +39,10 @@ public class Volatile extends EcoEnchant {
|
||||
float power = (float) (0.5 + (level * 0.5));
|
||||
|
||||
if (!AntigriefManager.canCreateExplosion(attacker, event.getEntity().getLocation())) return;
|
||||
if (breakblocks) {
|
||||
if (!AntigriefManager.canBreakBlock(attacker, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation())))
|
||||
return;
|
||||
if (breakblocks && !AntigriefManager.canBreakBlock(attacker, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
double distance = attacker.getLocation().distance(victim.getLocation());
|
||||
Location explosionLoc = victim.getEyeLocation();
|
||||
|
||||
victim.getWorld().createExplosion(explosionLoc, power, fire, breakblocks);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.spell;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -13,6 +12,8 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class Ascend extends Spell {
|
||||
private static final String IGNORE_FALL_KEY = "ignore-fall-damage";
|
||||
|
||||
public Ascend() {
|
||||
super("ascend");
|
||||
}
|
||||
@ -21,8 +22,8 @@ public class Ascend extends Spell {
|
||||
public void onUse(Player player, int level, 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-damage", new FixedMetadataValue(this.plugin, true));
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> player.removeMetadata("ignore-fall-damage", this.plugin), ticks * 4L);
|
||||
player.setMetadata(IGNORE_FALL_KEY, new FixedMetadataValue(this.plugin, true));
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> player.removeMetadata(IGNORE_FALL_KEY, this.plugin), ticks * 4L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -30,7 +31,7 @@ public class Ascend extends Spell {
|
||||
if(!event.getCause().equals(EntityDamageEvent.DamageCause.FALL))
|
||||
return;
|
||||
|
||||
if(!event.getEntity().hasMetadata("ignore-fall-damage"))
|
||||
if(!event.getEntity().hasMetadata(IGNORE_FALL_KEY))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -82,13 +82,13 @@ public abstract class Spell extends EcoEnchant {
|
||||
int cooldown = getCooldown(this, player);
|
||||
|
||||
if (cooldown > 0) {
|
||||
String message = Configs.LANG.getMessage("on-cooldown").replaceAll("%seconds%", String.valueOf(cooldown)).replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName());
|
||||
String message = Configs.LANG.getMessage("on-cooldown").replace("%seconds%", String.valueOf(cooldown)).replace("%name%", EnchantmentCache.getEntry(this).getRawName());
|
||||
player.sendMessage(message);
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 0.5f);
|
||||
return;
|
||||
}
|
||||
|
||||
String message = Configs.LANG.getMessage("used-spell").replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName());
|
||||
String message = Configs.LANG.getMessage("used-spell").replace("%name%", EnchantmentCache.getEntry(this).getRawName());
|
||||
player.sendMessage(message);
|
||||
player.playSound(player.getLocation(), this.getActivationSound(), SoundCategory.PLAYERS, 1, 1);
|
||||
runnable.run();
|
||||
|
@ -20,6 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
public class AnvilMerge {
|
||||
private static final String ALLOW_UNSAFE_KEY = "anvil.allow-unsafe-levels";
|
||||
|
||||
/**
|
||||
* Merge items in anvil
|
||||
@ -36,10 +37,8 @@ public class AnvilMerge {
|
||||
// Here so it can be accessed later (scope)
|
||||
|
||||
int outDamage = -1;
|
||||
if (old != null) {
|
||||
if (old.getItemMeta() instanceof Damageable) {
|
||||
outDamage = ((Damageable) old.getItemMeta()).getDamage();
|
||||
}
|
||||
if (old != null && old.getItemMeta() instanceof Damageable) {
|
||||
outDamage = ((Damageable) old.getItemMeta()).getDamage();
|
||||
}
|
||||
|
||||
if (left == null) return new Pair<>(null, null);
|
||||
@ -50,14 +49,15 @@ public class AnvilMerge {
|
||||
ItemStack out = left.clone();
|
||||
ItemMeta outMeta = out.getItemMeta();
|
||||
assert outMeta != null;
|
||||
assert left.getItemMeta() != null;
|
||||
ItemMeta meta = left.getItemMeta();
|
||||
assert meta != null;
|
||||
|
||||
outMeta.setDisplayName(name);
|
||||
|
||||
if (left.getItemMeta().getDisplayName().equals(name)) {
|
||||
if (meta.getDisplayName().equals(name)) {
|
||||
|
||||
if (left.getItemMeta() instanceof Damageable) {
|
||||
int leftDamage = ((Damageable) left.getItemMeta()).getDamage();
|
||||
if (meta instanceof Damageable) {
|
||||
int leftDamage = ((Damageable) meta).getDamage();
|
||||
|
||||
if (outDamage >= leftDamage || outDamage == -1) {
|
||||
return new Pair<>(null, null);
|
||||
@ -110,9 +110,7 @@ public class AnvilMerge {
|
||||
if (rightLevel > level) {
|
||||
level = rightLevel;
|
||||
} else if (rightLevel == level) {
|
||||
if (rightLevel > enchantment.getMaxLevel() && Configs.CONFIG.getBool("anvil.allow-combining-unsafe")) {
|
||||
level++;
|
||||
} else if ((rightLevel + 1) <= enchantment.getMaxLevel() || Configs.CONFIG.getBool("anvil.allow-unsafe-levels")) {
|
||||
if ((rightLevel > enchantment.getMaxLevel() && Configs.CONFIG.getBool("anvil.allow-combining-unsafe")) || ((rightLevel + 1) <= enchantment.getMaxLevel() || Configs.CONFIG.getBool(ALLOW_UNSAFE_KEY))) {
|
||||
level++;
|
||||
}
|
||||
}
|
||||
@ -141,23 +139,19 @@ public class AnvilMerge {
|
||||
if (left.getItemMeta() instanceof EnchantmentStorageMeta) canEnchantItem = true;
|
||||
|
||||
if (canEnchantItem && !doesConflict.get()) {
|
||||
if (Configs.CONFIG.getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap")) {
|
||||
if (outEnchants.size() >= Configs.CONFIG.getInt("anvil.hard-cap.cap")) {
|
||||
return;
|
||||
}
|
||||
if (Configs.CONFIG.getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap") && outEnchants.size() >= Configs.CONFIG.getInt("anvil.hard-cap.cap")) {
|
||||
return;
|
||||
}
|
||||
outEnchants.put(enchantment, integer);
|
||||
}
|
||||
}));
|
||||
|
||||
// Test if the output is the same as left
|
||||
if (outEnchants.equals(leftEnchants) && left.getItemMeta().getDisplayName().equals(name)) {
|
||||
if (left.getItemMeta() instanceof Damageable) {
|
||||
int leftDamage = ((Damageable) left.getItemMeta()).getDamage();
|
||||
if (outEnchants.equals(leftEnchants) && left.getItemMeta().getDisplayName().equals(name) && left.getItemMeta() instanceof Damageable) {
|
||||
int leftDamage = ((Damageable) left.getItemMeta()).getDamage();
|
||||
|
||||
if (outDamage == leftDamage) {
|
||||
return new Pair<>(null, null);
|
||||
}
|
||||
if (outDamage == leftDamage) {
|
||||
return new Pair<>(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +164,7 @@ public class AnvilMerge {
|
||||
}));
|
||||
|
||||
outEnchants.forEach(((enchantment, integer) -> {
|
||||
meta.addStoredEnchant(enchantment, integer, Configs.CONFIG.getBool("anvil.allow-existing-unsafe-levels") || Configs.CONFIG.getBool("anvil.allow-unsafe-levels"));
|
||||
meta.addStoredEnchant(enchantment, integer, Configs.CONFIG.getBool("anvil.allow-existing-unsafe-levels") || Configs.CONFIG.getBool(ALLOW_UNSAFE_KEY));
|
||||
}));
|
||||
|
||||
meta.setDisplayName(name);
|
||||
@ -183,7 +177,7 @@ public class AnvilMerge {
|
||||
}));
|
||||
|
||||
outEnchants.forEach(((enchantment, integer) -> {
|
||||
meta.addEnchant(enchantment, integer, Configs.CONFIG.getBool("anvil.allow-existing-unsafe-levels") || Configs.CONFIG.getBool("anvil.allow-unsafe-levels"));
|
||||
meta.addEnchant(enchantment, integer, Configs.CONFIG.getBool("anvil.allow-existing-unsafe-levels") || Configs.CONFIG.getBool(ALLOW_UNSAFE_KEY));
|
||||
}));
|
||||
|
||||
if (output.getItemMeta() instanceof Damageable) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.willfp.ecoenchants.enchantments.support.obtaining;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.willfp.eco.util.NumberUtils;
|
||||
import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.injection.PluginDependent;
|
||||
@ -23,19 +24,17 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class EnchantingListeners extends PluginDependent implements Listener {
|
||||
private static final Set<Material> secondary = new HashSet<Material>() {{
|
||||
add(Material.ELYTRA);
|
||||
add(Material.SHIELD);
|
||||
add(Material.FLINT_AND_STEEL);
|
||||
add(Material.SHEARS);
|
||||
add(Material.CARROT_ON_A_STICK);
|
||||
}};
|
||||
private static final Set<Material> secondary = new ImmutableSet.Builder<Material>()
|
||||
.add(Material.ELYTRA)
|
||||
.add(Material.SHIELD)
|
||||
.add(Material.FLINT_AND_STEEL)
|
||||
.add(Material.SHEARS)
|
||||
.add(Material.CARROT_ON_A_STICK).build();
|
||||
|
||||
public static final Map<Player, int[]> currentlyEnchantingSecondary = new HashMap<>();
|
||||
|
||||
@ -135,10 +134,8 @@ public class EnchantingListeners extends PluginDependent implements Listener {
|
||||
level = NumberUtils.equalIfOver(level, enchantment.getMaxLevel());
|
||||
toAdd.put(enchantment, level);
|
||||
|
||||
if (Configs.CONFIG.getBool("enchanting-table.cap-amount.enabled")) {
|
||||
if (toAdd.size() >= Configs.CONFIG.getInt("enchanting-table.cap-amount.limit")) {
|
||||
break;
|
||||
}
|
||||
if (Configs.CONFIG.getBool("enchanting-table.cap-amount.enabled") && toAdd.size() >= Configs.CONFIG.getInt("enchanting-table.cap-amount.limit")) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (enchantment.getType().equals(EnchantmentType.SPECIAL)) gotSpecial = true;
|
||||
@ -149,11 +146,9 @@ public class EnchantingListeners extends PluginDependent implements Listener {
|
||||
}
|
||||
toAdd.forEach(event.getEnchantsToAdd()::putIfAbsent);
|
||||
|
||||
if ((secondary.contains(event.getItem().getType()))) {
|
||||
if (!toAdd.containsKey(EcoEnchants.INDESTRUCTIBILITY)) {
|
||||
event.getEnchantsToAdd().put(Enchantment.DURABILITY, currentlyEnchantingSecondary.get(player)[event.whichButton()]);
|
||||
currentlyEnchantingSecondary.remove(player);
|
||||
}
|
||||
if (secondary.contains(event.getItem().getType()) && !toAdd.containsKey(EcoEnchants.INDESTRUCTIBILITY)) {
|
||||
event.getEnchantsToAdd().put(Enchantment.DURABILITY, currentlyEnchantingSecondary.get(player)[event.whichButton()]);
|
||||
currentlyEnchantingSecondary.remove(player);
|
||||
}
|
||||
|
||||
if (gotSpecial && Configs.CONFIG.getBool("enchanting-table.notify-on-special")) {
|
||||
|
@ -292,7 +292,6 @@ public class EnchantChecks {
|
||||
if (entity.getEquipment() == null)
|
||||
return new HashMap<>();
|
||||
|
||||
AtomicInteger armorPoints = new AtomicInteger(0);
|
||||
List<ItemStack> armor = Arrays.asList(entity.getEquipment().getArmorContents());
|
||||
|
||||
Map<EcoEnchant, Integer> ecoEnchants = new HashMap<>();
|
||||
|
@ -21,7 +21,7 @@ public class EnchantmentUtils {
|
||||
);
|
||||
|
||||
enchantment.getConfig().config.getKeys(true).forEach(string -> {
|
||||
String key = string.replaceAll("\\.", "_").replaceAll("-", "_");
|
||||
String key = string.replace("\\.", "_").replace("-", "_");
|
||||
Object object = enchantment.getConfig().config.get(string);
|
||||
|
||||
PlaceholderManager.registerPlaceholder(
|
||||
|
@ -58,9 +58,7 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
|
||||
if (victim.hasMetadata("NPC")) return;
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (!AntigriefManager.canInjure((Player) attacker, victim)) return;
|
||||
}
|
||||
if (attacker instanceof Player && !AntigriefManager.canInjure((Player) attacker, victim)) return;
|
||||
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
@ -99,9 +97,7 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
|
||||
if (victim.hasMetadata("NPC")) return;
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (!AntigriefManager.canInjure((Player) attacker, victim)) return;
|
||||
}
|
||||
if (attacker instanceof Player && !AntigriefManager.canInjure((Player) attacker, victim)) return;
|
||||
|
||||
EnchantChecks.getEnchantsOnItem(item).forEach(((enchant, level) -> {
|
||||
if (event.isCancelled()) return;
|
||||
@ -126,15 +122,13 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
jumpVelocity += ((float) player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.1F;
|
||||
}
|
||||
jumpVelocity = Float.parseFloat(df.format(jumpVelocity).replace(',', '.'));
|
||||
if (event.getPlayer().getLocation().getBlock().getType() != Material.LADDER && prevPlayersOnGround.contains(player.getUniqueId())) {
|
||||
if (!player.isOnGround() && Float.compare((float) player.getVelocity().getY(), jumpVelocity) == 0) {
|
||||
EnchantChecks.getEnchantsOnArmor(player).forEach((enchant, level) -> {
|
||||
if (event.isCancelled()) return;
|
||||
if (!enchant.isEnabled()) return;
|
||||
if (enchant.getDisabledWorlds().contains(player.getWorld())) return;
|
||||
enchant.onJump(player, level, event);
|
||||
});
|
||||
}
|
||||
if (event.getPlayer().getLocation().getBlock().getType() != Material.LADDER && prevPlayersOnGround.contains(player.getUniqueId())&& !player.isOnGround() && Float.compare((float) player.getVelocity().getY(), jumpVelocity) == 0) {
|
||||
EnchantChecks.getEnchantsOnArmor(player).forEach((enchant, level) -> {
|
||||
if (event.isCancelled()) return;
|
||||
if (!enchant.isEnabled()) return;
|
||||
if (enchant.getDisabledWorlds().contains(player.getWorld())) return;
|
||||
enchant.onJump(player, level, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (player.isOnGround()) {
|
||||
@ -162,9 +156,7 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
|
||||
if (victim.hasMetadata("NPC")) return;
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (!AntigriefManager.canInjure((Player) attacker, victim)) return;
|
||||
}
|
||||
if (attacker instanceof Player && !AntigriefManager.canInjure((Player) attacker, victim)) return;
|
||||
|
||||
EnchantChecks.getEnchantsOnMainhand(attacker).forEach((enchant, level) -> {
|
||||
if (event.isCancelled()) return;
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class AnticheatAAC implements AnticheatWrapper, Listener {
|
||||
private final AACExemption ECOENCHANTS = new AACExemption("EcoEnchants");
|
||||
private final AACExemption ecoEnchantsExemption = new AACExemption("EcoEnchants");
|
||||
private final AACAPI api = Bukkit.getServicesManager().load(AACAPI.class);
|
||||
|
||||
@Override
|
||||
@ -18,11 +18,11 @@ public class AnticheatAAC implements AnticheatWrapper, Listener {
|
||||
|
||||
@Override
|
||||
public void exempt(Player player) {
|
||||
api.addExemption(player, ECOENCHANTS);
|
||||
api.addExemption(player, ecoEnchantsExemption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unexempt(Player player) {
|
||||
api.removeExemption(player, ECOENCHANTS);
|
||||
api.removeExemption(player, ecoEnchantsExemption);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class Alchemy extends EcoEnchant {
|
||||
super("alchemy", EnchantmentType.NORMAL);
|
||||
}
|
||||
|
||||
private final FixedMetadataValue TRUE = this.plugin.getMetadataValueFactory().create(true);
|
||||
private final FixedMetadataValue metaKeyTrue = this.plugin.getMetadataValueFactory().create(true);
|
||||
|
||||
@EventHandler
|
||||
public void onPotionEffect(EntityPotionEffectEvent event) {
|
||||
@ -47,7 +47,7 @@ public class Alchemy extends EcoEnchant {
|
||||
effect.hasIcon()
|
||||
);
|
||||
|
||||
entity.setMetadata(newEffect.toString(), TRUE);
|
||||
entity.setMetadata(newEffect.toString(), metaKeyTrue);
|
||||
|
||||
entity.removePotionEffect(effect.getType());
|
||||
|
||||
|
@ -8,11 +8,11 @@ public class AlchemyMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public abstract class BiomesEnchantment extends EcoEnchant {
|
||||
private static final String MULTIPLIER_KEY = "multiplier";
|
||||
|
||||
protected BiomesEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) {
|
||||
super(key, type, prerequisites);
|
||||
}
|
||||
@ -28,7 +30,7 @@ public abstract class BiomesEnchantment extends EcoEnchant {
|
||||
if(!isInBiome(attacker))
|
||||
return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + MULTIPLIER_KEY);
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier)));
|
||||
}
|
||||
|
||||
@ -47,7 +49,7 @@ public abstract class BiomesEnchantment extends EcoEnchant {
|
||||
if(!isInBiome(attacker))
|
||||
return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + MULTIPLIER_KEY);
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier)));
|
||||
}
|
||||
|
||||
@ -56,7 +58,7 @@ public abstract class BiomesEnchantment extends EcoEnchant {
|
||||
if(!isInBiome(attacker))
|
||||
return;
|
||||
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + MULTIPLIER_KEY);
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier)));
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ public class BiomesMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,8 @@ public abstract class EffectsEnchantment extends EcoEnchant {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
if (player.hasPotionEffect(this.getPotionEffect())) {
|
||||
if (player.getPotionEffect(this.getPotionEffect()).getDuration() >= 1639) {
|
||||
if (player.hasPotionEffect(this.getPotionEffect()) && player.getPotionEffect(this.getPotionEffect()).getDuration() >= 1639) {
|
||||
player.removePotionEffect(this.getPotionEffect());
|
||||
}
|
||||
}
|
||||
|
||||
int level = EnchantChecks.getArmorPoints(player, this);
|
||||
|
@ -18,10 +18,11 @@ public class EffectsMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Handled by super
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ public class EndershotMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,11 @@ public class FirewandMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Handled by super
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ public class MMOMain extends Extension {
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -40,21 +40,21 @@ public class MMOManager {
|
||||
|
||||
public static double getStamina(Player player) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
return integration.getMana(player);
|
||||
return integration.getStamina(player);
|
||||
}
|
||||
|
||||
public static double getMaxStamina(Player player) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
return integration.getMaxMana(player);
|
||||
return integration.getMaxStamina(player);
|
||||
}
|
||||
|
||||
public static void setStamina(Player player, double amount) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
integration.setMana(player, amount);
|
||||
integration.setStamina(player, amount);
|
||||
}
|
||||
|
||||
public static void giveStamina(Player player, double amount) {
|
||||
MMOIntegration integration = getIntegration();
|
||||
integration.giveMana(player, amount);
|
||||
integration.giveStamina(player, amount);
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,11 @@ public class PrecisionMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Handled by super
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ public class SprintArtifactsMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +59,8 @@ public abstract class SummoningEnchantment extends EcoEnchant {
|
||||
|
||||
private void doSpawn(LivingEntity attacker, LivingEntity victim, int level) {
|
||||
|
||||
if(summoningType.equals(SummoningType.MELEE)) {
|
||||
if (attacker instanceof Player) {
|
||||
if (ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
}
|
||||
if(summoningType.equals(SummoningType.MELEE) && attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
|
@ -17,11 +17,11 @@ public class SummoningMain extends Extension {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Handled by super
|
||||
}
|
||||
}
|
||||
|
@ -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("");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user