Merge branch 'development'

This commit is contained in:
Brianna 2020-02-01 06:06:50 -05:00
commit dc66814962
3 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>EpicEnchants</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.1.2</version>
<version>1.1.3</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>EpicEnchants-${project.version}</finalName>

View File

@ -156,7 +156,7 @@ public final class ArmorEquipEvent extends PlayerEvent implements Cancellable {
if (itemStack == null || itemStack.getType().equals(Material.AIR)) return null;
String type = itemStack.getType().name();
if (type.endsWith("_HELMET") || type.endsWith("_SKULL")) return HELMET;
else if (type.endsWith("_CHESTPLATE")) return CHESTPLATE;
else if (type.endsWith("_CHESTPLATE") || type.equals("ELYTRA")) return CHESTPLATE;
else if (type.endsWith("_LEGGINGS")) return LEGGINGS;
else if (type.endsWith("_BOOTS")) return BOOTS;
else return null;

View File

@ -91,17 +91,23 @@ public class Placeholders {
public static String setPlaceholders(String in, Player user, LivingEntity opponent, int level, Event event) {
String input = in.replace("{level}", String.valueOf(level));
for (Map.Entry<String, BiFunction<Player, LivingEntity, Object>> entry : PLAYER_FUNCTIONS.entrySet()) {
input = input.replace(entry.getKey(), entry.getValue().apply(user, opponent).toString());
}
AtomicReference<String> output = new AtomicReference<>(input);
PLAYER_FUNCTIONS.forEach((toReplace, function) -> output.updateAndGet(string -> string.replace(toReplace, function.apply(user, opponent).toString())));
REGEX_CONSUMERS.forEach(consumer -> consumer.accept(output));
Optional.ofNullable(event).ifPresent(e -> EVENT_FUNCTIONS.forEach((toReplace, function) -> output.updateAndGet(string -> string.replace(toReplace, "'" + function.apply(e) + "'"))));
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
output.updateAndGet(string -> PlaceholderAPI.setPlaceholders(user, string));
final String inputFinal = input;
if (opponent instanceof Player)
output.updateAndGet(string -> PlaceholderAPI.setRelationalPlaceholders(user, (Player) opponent, input));
output.updateAndGet(string -> PlaceholderAPI.setRelationalPlaceholders(user, (Player) opponent, inputFinal));
}
return output.get();