mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-25 20:17:38 +01:00
Fixed CallingCurse, DecayCurse, Forcefield, Magnetic, Repairing
This commit is contained in:
parent
0f531665b1
commit
bf4d681332
@ -71,15 +71,6 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
|
||||
this.getLog().info("");
|
||||
|
||||
EcoEnchants.values().forEach(enchant -> {
|
||||
if (enchant.isEnabled()) {
|
||||
this.getEventManager().registerListener(enchant);
|
||||
if (enchant instanceof EcoRunnable) {
|
||||
this.getScheduler().syncRepeating((EcoRunnable) enchant, 5, ((EcoRunnable) enchant).getTime());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.getLog().info(EcoEnchants.values().size() + " Enchantments Loaded:");
|
||||
this.getLog().info(EcoEnchants.values().stream().map(ecoEnchant -> ecoEnchant.getType().getColor() + ecoEnchant.getName()).collect(Collectors.joining(", ")));
|
||||
|
||||
@ -123,6 +114,10 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
this.getScheduler().runLater(() -> {
|
||||
if (ecoEnchant.isEnabled()) {
|
||||
this.getEventManager().registerListener(ecoEnchant);
|
||||
|
||||
if (ecoEnchant instanceof EcoRunnable) {
|
||||
this.getScheduler().syncRepeating((EcoRunnable) ecoEnchant, 5, ((EcoRunnable) ecoEnchant).getTime());
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
}));
|
||||
|
@ -20,14 +20,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CallingCurse extends EcoEnchant implements EcoRunnable {
|
||||
private final HashMap<Player, Integer> players = new HashMap<>();
|
||||
private double distance = EcoEnchants.CALLING_CURSE.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
|
||||
|
||||
public CallingCurse() {
|
||||
super(
|
||||
"calling_curse", EnchantmentType.CURSE
|
||||
);
|
||||
}
|
||||
|
||||
private final HashMap<Player, Integer> players = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onArmorEquip(@NotNull final ArmorEquipEvent event) {
|
||||
refresh();
|
||||
@ -45,18 +46,19 @@ public class CallingCurse extends EcoEnchant implements EcoRunnable {
|
||||
|
||||
private void refresh() {
|
||||
players.clear();
|
||||
this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
int level = EnchantChecks.getArmorPoints(player, this, 0);
|
||||
if (level > 0) {
|
||||
players.put(player, level);
|
||||
}
|
||||
});
|
||||
}), 1);
|
||||
|
||||
distance = EcoEnchants.CALLING_CURSE.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
players.forEach((player, level) -> {
|
||||
double distance = EcoEnchants.CALLING_CURSE.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
@ -67,11 +67,11 @@ public class DecayCurse extends EcoEnchant implements EcoRunnable {
|
||||
|
||||
private void refresh() {
|
||||
players.clear();
|
||||
this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
if (Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) {
|
||||
players.add(player);
|
||||
}
|
||||
});
|
||||
}), 1);
|
||||
amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Forcefield extends EcoEnchant implements EcoRunnable {
|
||||
private final HashMap<Player, Integer> players = new HashMap<>();
|
||||
double initialDistance = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
|
||||
double bonus = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
|
||||
double damagePerPoint = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level");
|
||||
|
||||
public Forcefield() {
|
||||
super(
|
||||
"forcefield", EnchantmentType.NORMAL
|
||||
);
|
||||
}
|
||||
|
||||
private final HashMap<Player, Integer> players = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onArmorEquip(@NotNull final ArmorEquipEvent event) {
|
||||
refresh();
|
||||
@ -43,12 +46,15 @@ public class Forcefield extends EcoEnchant implements EcoRunnable {
|
||||
|
||||
private void refresh() {
|
||||
players.clear();
|
||||
this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
int level = EnchantChecks.getArmorPoints(player, this, 0);
|
||||
if (level > 0) {
|
||||
players.put(player, level);
|
||||
}
|
||||
});
|
||||
}), 1);
|
||||
initialDistance = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
|
||||
bonus = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
|
||||
damagePerPoint = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,10 +63,7 @@ public class Forcefield extends EcoEnchant implements EcoRunnable {
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
double initialDistance = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
|
||||
double bonus = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
|
||||
double distance = initialDistance + (level * bonus);
|
||||
double damagePerPoint = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level");
|
||||
final double damage = damagePerPoint * level;
|
||||
|
||||
for (Entity e : player.getWorld().getNearbyEntities(player.getLocation(), distance, 2.0d, distance)) {
|
||||
|
@ -20,16 +20,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Magnetic extends EcoEnchant implements EcoRunnable {
|
||||
private double initialDistance = 1;
|
||||
private double bonus = 1;
|
||||
private final HashMap<Player, Integer> players = new HashMap<>();
|
||||
|
||||
public Magnetic() {
|
||||
super(
|
||||
"magnetic", EnchantmentType.NORMAL
|
||||
);
|
||||
}
|
||||
|
||||
private final HashMap<Player, Integer> players = new HashMap<>();
|
||||
private double initialDistance = 1;
|
||||
private double bonus = 1;
|
||||
|
||||
@EventHandler
|
||||
public void onArmorEquip(@NotNull final ArmorEquipEvent event) {
|
||||
refresh();
|
||||
@ -47,12 +47,12 @@ public class Magnetic extends EcoEnchant implements EcoRunnable {
|
||||
|
||||
private void refresh() {
|
||||
players.clear();
|
||||
this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
int level = EnchantChecks.getArmorPoints(player, this, 0);
|
||||
if (level > 0) {
|
||||
players.put(player, level);
|
||||
}
|
||||
});
|
||||
}), 1);
|
||||
initialDistance = EcoEnchants.MAGNETIC.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
|
||||
bonus = EcoEnchants.MAGNETIC.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
|
||||
}
|
||||
|
@ -68,11 +68,11 @@ public class Repairing extends EcoEnchant implements EcoRunnable {
|
||||
|
||||
private void refresh() {
|
||||
players.clear();
|
||||
this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> {
|
||||
if (Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) {
|
||||
players.add(player);
|
||||
}
|
||||
});
|
||||
}), 1);
|
||||
amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user