mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 18:45:27 +01:00
Fix death events for #117. Credit tamed wolf kills. Bump version number
This commit is contained in:
parent
91b5491136
commit
33d0fefb70
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests</artifactId>
|
<artifactId>quests</artifactId>
|
||||||
<version>3.1.3</version>
|
<version>3.1.4</version>
|
||||||
<name>quests</name>
|
<name>quests</name>
|
||||||
<url>https://github.com/FlyingPikachu/Quests/</url>
|
<url>https://github.com/FlyingPikachu/Quests/</url>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.Sheep;
|
import org.bukkit.entity.Sheep;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -407,98 +408,69 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent evt) {
|
public void onEntityDeath(EntityDeathEvent evt) {
|
||||||
System.out.println("1");
|
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||||
// NPCs count as a Player so we check for them through Citizens
|
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
|
||||||
boolean isTargetNPC = false;
|
Entity damager = damageEvent.getDamager();
|
||||||
if (plugin.citizens != null) {
|
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(evt.getEntity())) {
|
if (damager != null) {
|
||||||
isTargetNPC = true;
|
if (damager instanceof Projectile) {
|
||||||
|
Projectile projectile = (Projectile) damager;
|
||||||
|
ProjectileSource source = projectile.getShooter();
|
||||||
|
if (source instanceof Entity) {
|
||||||
|
killMob((Entity)source, evt.getEntity());
|
||||||
|
}
|
||||||
|
} else if (damager instanceof TNTPrimed) {
|
||||||
|
TNTPrimed tnt = (TNTPrimed) damager;
|
||||||
|
Entity source = tnt.getSource();
|
||||||
|
if (source.isValid()) {
|
||||||
|
killMob(source, evt.getEntity());
|
||||||
|
}
|
||||||
|
} else if (damager instanceof Wolf) {
|
||||||
|
Wolf wolf = (Wolf) damager;
|
||||||
|
if (wolf.isTamed()) {
|
||||||
|
Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
|
||||||
|
killPlayer(quester.getPlayer(), evt.getEntity());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
killMob(damager, evt.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//if (/*evt.getEntity() instanceof Player == false ||*/ isTargetNPC) {
|
}
|
||||||
System.out.println("2");
|
|
||||||
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
/**
|
||||||
System.out.println("3");
|
* Checks if damager is blacklisted
|
||||||
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
|
* Ensures damager is Player and not NPC
|
||||||
Entity damager = damageEvent.getDamager();
|
* Kills target mob/NPC if objective exists
|
||||||
if (damager != null) {
|
*
|
||||||
System.out.println("4");
|
* @param damager the attacking entity
|
||||||
if (damager instanceof Projectile) {
|
* @param target the entity being attacked
|
||||||
Projectile projectile = (Projectile) damager;
|
* @since 3.1.4
|
||||||
ProjectileSource source = projectile.getShooter();
|
*/
|
||||||
if (source instanceof Player) {
|
public void killMob(Entity damager, Entity target) {
|
||||||
Player player = (Player) source;
|
if (plugin.checkQuester(damager.getUniqueId()) == false) {
|
||||||
boolean okay = true;
|
return;
|
||||||
if (plugin.citizens != null) {
|
}
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
//Ensure damager is Player AND not an NPC
|
||||||
okay = false;
|
if (damager instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(damager)) {
|
||||||
}
|
//If target is an NPC...
|
||||||
}
|
if (CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||||
System.out.println("5");
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
if (okay) {
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
if (isTargetNPC) {
|
if (quester.hasObjective(quest, "killNPC")) {
|
||||||
System.out.println("6");
|
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
}
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
}
|
||||||
if (quester.hasObjective(quest, "killNPC")) {
|
//No? Must be a mob...
|
||||||
System.out.println("7");
|
} else {
|
||||||
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(evt.getEntity()));
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
}
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
}
|
if (quester.hasObjective(quest, "killMob")) {
|
||||||
} else {
|
quester.killMob(quest, target.getLocation(), target.getType());
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
|
||||||
if (quester.hasObjective(quest, "killMob")) {
|
|
||||||
System.out.println("7-2");
|
|
||||||
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (damager instanceof TNTPrimed) {
|
|
||||||
TNTPrimed tnt = (TNTPrimed) damager;
|
|
||||||
Entity source = tnt.getSource();
|
|
||||||
if (source instanceof Player) {
|
|
||||||
Player player = (Player) source;
|
|
||||||
boolean okay = true;
|
|
||||||
if (plugin.citizens != null) {
|
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
|
||||||
okay = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (okay) {
|
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
|
||||||
if (quester.hasObjective(quest, "killMob")) {
|
|
||||||
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (damager instanceof Player) {
|
|
||||||
System.out.println("7-3");
|
|
||||||
boolean okay = true;
|
|
||||||
if (plugin.citizens != null) {
|
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(damager)) {
|
|
||||||
okay = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (okay) {
|
|
||||||
System.out.println("7-4");
|
|
||||||
Player player = (Player) damager;
|
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
|
||||||
if (quester.hasObjective(quest, "killMob")) {
|
|
||||||
System.out.println("7-5");
|
|
||||||
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -506,57 +478,39 @@ public class PlayerListener implements Listener {
|
|||||||
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||||
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
|
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
|
||||||
Entity damager = damageEvent.getDamager();
|
Entity damager = damageEvent.getDamager();
|
||||||
|
|
||||||
if (damager != null) {
|
if (damager != null) {
|
||||||
|
//Ignore suicide
|
||||||
|
if (evt.getEntity().getUniqueId().equals(damager.getUniqueId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (damager instanceof Projectile) {
|
if (damager instanceof Projectile) {
|
||||||
if (evt.getEntity().getLastDamageCause().getEntity() instanceof Player) {
|
Projectile projectile = (Projectile) damager;
|
||||||
Player player = (Player) evt.getEntity().getLastDamageCause().getEntity();
|
ProjectileSource source = projectile.getShooter();
|
||||||
if (plugin.checkQuester(player.getUniqueId()) == false) {
|
if (source instanceof Entity) {
|
||||||
boolean okay = true;
|
killPlayer((Entity)source, evt.getEntity());
|
||||||
if (plugin.citizens != null) {
|
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(player) || CitizensAPI.getNPCRegistry().isNPC(evt.getEntity())) {
|
|
||||||
okay = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (evt.getEntity().getUniqueId().equals(player.getUniqueId())) {
|
|
||||||
okay = false;
|
|
||||||
}
|
|
||||||
if (okay) {
|
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
|
||||||
if (quester.hasObjective(quest, "killPlayer")) {
|
|
||||||
quester.killPlayer(quest, evt.getEntity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (damager instanceof Player) {
|
} else if (damager instanceof TNTPrimed) {
|
||||||
Player player = (Player) damager;
|
TNTPrimed tnt = (TNTPrimed) damager;
|
||||||
if (plugin.checkQuester(player.getUniqueId()) == false) {
|
Entity source = tnt.getSource();
|
||||||
boolean okay = true;
|
if (source.isValid()) {
|
||||||
if (plugin.citizens != null) {
|
killPlayer(source, evt.getEntity());
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(player) || CitizensAPI.getNPCRegistry().isNPC(evt.getEntity())) {
|
|
||||||
okay = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (evt.getEntity().getUniqueId().equals(player.getUniqueId())) {
|
|
||||||
okay = false;
|
|
||||||
}
|
|
||||||
if (okay) {
|
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
|
||||||
if (quester.hasObjective(quest, "killPlayer")) {
|
|
||||||
quester.killPlayer(quest, evt.getEntity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if (damager instanceof Wolf) {
|
||||||
|
Wolf wolf = (Wolf) damager;
|
||||||
|
if (wolf.isTamed()) {
|
||||||
|
Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
|
||||||
|
killPlayer(quester.getPlayer(), evt.getEntity());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
killPlayer(damager, evt.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Player player = evt.getEntity();
|
|
||||||
if (plugin.checkQuester(player.getUniqueId()) == false) {
|
Player target = evt.getEntity();
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
if (plugin.checkQuester(target.getUniqueId()) == false) {
|
||||||
|
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
Stage stage = quester.getCurrentStage(quest);
|
Stage stage = quester.getCurrentStage(quest);
|
||||||
if (stage != null && stage.deathEvent != null) {
|
if (stage != null && stage.deathEvent != null) {
|
||||||
@ -572,12 +526,39 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||||
evt.getDrops().remove(found);
|
evt.getDrops().remove(found);
|
||||||
quester.hasJournal = false;
|
quester.hasJournal = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if damager is blacklisted
|
||||||
|
* Ensures damager is Player and not NPC
|
||||||
|
* Kills target Player if objective exists
|
||||||
|
*
|
||||||
|
* @param damager the attacking entity
|
||||||
|
* @param target the entity being attacked
|
||||||
|
* @since 3.1.4
|
||||||
|
*/
|
||||||
|
public void killPlayer(Entity damager, Entity target) {
|
||||||
|
if (plugin.checkQuester(damager.getUniqueId()) == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Ensure damager is player AND not an NPC
|
||||||
|
if (damager instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(damager)) {
|
||||||
|
//If target is player AND not an NPC...
|
||||||
|
if (target instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||||
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
|
if (quester.hasObjective(quest, "killPlayer")) {
|
||||||
|
quester.killPlayer(quest, (Player)target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerFish(PlayerFishEvent evt) {
|
public void onPlayerFish(PlayerFishEvent evt) {
|
||||||
Player player = evt.getPlayer();
|
Player player = evt.getPlayer();
|
||||||
|
@ -3646,6 +3646,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether player has been blacklisted from Quests
|
||||||
|
*
|
||||||
|
* @param uuid the entity UUID to be checked
|
||||||
|
* @return {@code true} if UUID is blacklisted
|
||||||
|
*/
|
||||||
public boolean checkQuester(UUID uuid) {
|
public boolean checkQuester(UUID uuid) {
|
||||||
for (String s : questerBlacklist) {
|
for (String s : questerBlacklist) {
|
||||||
try {
|
try {
|
||||||
|
@ -111,10 +111,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
|
|||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCatchFish") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") + ChatColor.GRAY + ")\n";
|
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCatchFish") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") + ChatColor.GRAY + ")\n";
|
||||||
}
|
}
|
||||||
if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) {
|
if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) {
|
||||||
text += ChatColor.YELLOW + "DEPRECATED" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
} else {
|
} else {
|
||||||
Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL);
|
Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL);
|
||||||
text += ChatColor.YELLOW + "DEPRECATED" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")\n";
|
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")\n";
|
||||||
}
|
}
|
||||||
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "8 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "8 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user