2019-01-21 15:01:25 +01:00
|
|
|
package com.songoda.epicenchants.effect.effects;
|
|
|
|
|
|
|
|
import com.songoda.epicenchants.effect.EffectExecutor;
|
2019-01-24 12:00:57 +01:00
|
|
|
import com.songoda.epicenchants.enums.EventType;
|
2019-04-03 15:58:13 +02:00
|
|
|
import com.songoda.epicenchants.utils.single.GeneralUtils;
|
2019-03-26 17:21:22 +01:00
|
|
|
import com.songoda.epicenchants.utils.single.Placeholders;
|
2019-01-21 15:01:25 +01:00
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
2019-01-30 11:58:37 +01:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2019-01-21 15:01:25 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2019-01-30 11:58:37 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2019-01-21 15:01:25 +01:00
|
|
|
|
2019-01-30 11:58:37 +01:00
|
|
|
import static com.songoda.epicenchants.effect.EffectExecutor.Who.OPPONENT;
|
2019-08-04 23:50:07 +02:00
|
|
|
import static com.songoda.epicenchants.enums.EventType.NONE;
|
|
|
|
import static com.songoda.epicenchants.enums.EventType.ON;
|
2019-01-21 15:01:25 +01:00
|
|
|
|
|
|
|
public class PlayerCommand extends EffectExecutor {
|
|
|
|
public PlayerCommand(ConfigurationSection section) {
|
|
|
|
super(section);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-03-26 15:32:53 +01:00
|
|
|
public void execute(@NotNull Player user, LivingEntity opponent, int level, EventType eventType) {
|
2019-03-26 16:12:16 +01:00
|
|
|
if (eventType != ON && eventType != NONE) {
|
|
|
|
return;
|
|
|
|
}
|
2019-01-30 11:58:37 +01:00
|
|
|
|
2019-03-26 16:12:16 +01:00
|
|
|
if (who() == OPPONENT && !(opponent instanceof Player)) {
|
|
|
|
return;
|
2019-01-30 11:58:37 +01:00
|
|
|
}
|
2019-01-21 15:01:25 +01:00
|
|
|
|
2023-06-25 13:50:27 +02:00
|
|
|
consume(entity -> GeneralUtils.getString(getSection(), "message")
|
|
|
|
.stream()
|
2019-04-03 15:58:13 +02:00
|
|
|
.map(s -> Placeholders.setPlaceholders(s, user, opponent, level))
|
|
|
|
.forEach(((Player) entity)::performCommand), user, opponent);
|
2019-01-21 15:01:25 +01:00
|
|
|
}
|
|
|
|
}
|