Added Breeding to Missions Handler
This commit is contained in:
parent
88f3cbb97c
commit
8d848523c5
@ -10,6 +10,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.EntityBreedEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
|
||||||
@ -24,6 +25,26 @@ public class MissionHandler implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onEntityBreed(EntityBreedEvent event) {
|
||||||
|
if (event.getEntity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getEntity().getKiller());
|
||||||
|
if (fPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("breed")).collect(Collectors.toList());
|
||||||
|
for (Mission mission2 : missions) {
|
||||||
|
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
|
||||||
|
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType"))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mission2.incrementProgress();
|
||||||
|
checkIfDone(fPlayer, mission2, section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
if (event.getEntity() == null || event.getEntity().getKiller() == null) {
|
if (event.getEntity() == null || event.getEntity().getKiller() == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user