Java Code Examples for org.bukkit.event.entity.EntityTameEvent#getOwner()
The following examples show how to use
org.bukkit.event.entity.EntityTameEvent#getOwner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TamingTaskType.java From Quests with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onTame(EntityTameEvent event) { if (!(event.getOwner() instanceof Player)) { return; } Player player = (Player) event.getOwner(); QPlayer qPlayer = QuestsAPI.getPlayerManager().getPlayer(player.getUniqueId(), true); QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile(); for (Quest quest : super.getRegisteredQuests()) { if (questProgressFile.hasStartedQuest(quest)) { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { continue; } int tamesNeeded = (int) task.getConfigValue("amount"); int progressTamed; if (taskProgress.getProgress() == null) { progressTamed = 0; } else { progressTamed = (int) taskProgress.getProgress(); } taskProgress.setProgress(progressTamed + 1); if (((int) taskProgress.getProgress()) >= tamesNeeded) { taskProgress.setCompleted(true); } } } } }
Example 2
Source File: TameObjective.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onTaming(EntityTameEvent event) { if (event.getOwner() instanceof Player) { String playerID = PlayerConverter.getID((Player) event.getOwner()); if (!dataMap.containsKey(playerID)) { return; } LivingEntity entity = event.getEntity(); TameData playerData = (TameData) dataMap.get(playerID); switch (type) { case WOLF: if (entity.getType().equals(EntityType.WOLF) && checkConditions(playerID)) { playerData.subtract(); } break; case OCELOT: if (entity.getType().equals(EntityType.OCELOT) && checkConditions(playerID)) { playerData.subtract(); } break; case HORSE: if (entity.getType().equals(EntityType.HORSE) && checkConditions(playerID)) { playerData.subtract(); } break; default: break; } if (playerData.isZero()) { completeObjective(playerID); } } }