This repository has been archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged pull request #221 from fabianwennink/breeding_category
Added a new category: Breeding
- Loading branch information
Showing
5 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/hm/achievement/listener/AchieveBreedListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.hm.achievement.listener; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.entity.EntityBreedEvent; | ||
|
||
import com.hm.achievement.AdvancedAchievements; | ||
import com.hm.achievement.category.MultipleAchievements; | ||
|
||
/** | ||
* Listener class to deal with Breeding achievements. | ||
*/ | ||
public class AchieveBreedListener extends AbstractListener { | ||
|
||
public AchieveBreedListener(AdvancedAchievements plugin) { | ||
super(plugin); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) | ||
public void onEntityBreed(EntityBreedEvent event) { | ||
if(!(event.getBreeder() instanceof Player)) { | ||
return; | ||
} | ||
|
||
Player player = (Player)event.getBreeder(); | ||
|
||
if (player == null) { | ||
return; | ||
} | ||
|
||
if (!shouldEventBeTakenIntoAccountNoPermission(player)) { | ||
return; | ||
} | ||
|
||
Entity entity = event.getMother(); | ||
|
||
if (!(entity instanceof LivingEntity)) { | ||
return; | ||
} | ||
|
||
String mobName = entity.getType().name().toLowerCase(); | ||
|
||
MultipleAchievements category = MultipleAchievements.BREEDING; | ||
|
||
if (plugin.getPluginConfig().isConfigurationSection(category + "." + mobName) | ||
&& player.hasPermission(category.toPermName() + '.' + mobName)) { | ||
updateStatisticAndAwardAchievementsIfAvailable(player, category, mobName, 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters