mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-26 20:55:54 +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");
|
|
||||||
// NPCs count as a Player so we check for them through Citizens
|
|
||||||
boolean isTargetNPC = false;
|
|
||||||
if (plugin.citizens != null) {
|
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(evt.getEntity())) {
|
|
||||||
isTargetNPC = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if (/*evt.getEntity() instanceof Player == false ||*/ isTargetNPC) {
|
|
||||||
System.out.println("2");
|
|
||||||
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||||
System.out.println("3");
|
|
||||||
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) {
|
||||||
System.out.println("4");
|
|
||||||
if (damager instanceof Projectile) {
|
if (damager instanceof Projectile) {
|
||||||
Projectile projectile = (Projectile) damager;
|
Projectile projectile = (Projectile) damager;
|
||||||
ProjectileSource source = projectile.getShooter();
|
ProjectileSource source = projectile.getShooter();
|
||||||
if (source instanceof Player) {
|
if (source instanceof Entity) {
|
||||||
Player player = (Player) source;
|
killMob((Entity)source, evt.getEntity());
|
||||||
boolean okay = true;
|
|
||||||
if (plugin.citizens != null) {
|
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
|
||||||
okay = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("5");
|
|
||||||
if (okay) {
|
|
||||||
if (isTargetNPC) {
|
|
||||||
System.out.println("6");
|
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
|
||||||
if (quester.hasObjective(quest, "killNPC")) {
|
|
||||||
System.out.println("7");
|
|
||||||
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(evt.getEntity()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
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) {
|
} else if (damager instanceof TNTPrimed) {
|
||||||
TNTPrimed tnt = (TNTPrimed) damager;
|
TNTPrimed tnt = (TNTPrimed) damager;
|
||||||
Entity source = tnt.getSource();
|
Entity source = tnt.getSource();
|
||||||
if (source instanceof Player) {
|
if (source.isValid()) {
|
||||||
Player player = (Player) source;
|
killMob(source, evt.getEntity());
|
||||||
boolean okay = true;
|
}
|
||||||
if (plugin.citizens != null) {
|
} else if (damager instanceof Wolf) {
|
||||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
Wolf wolf = (Wolf) damager;
|
||||||
okay = false;
|
if (wolf.isTamed()) {
|
||||||
|
Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
|
||||||
|
killPlayer(quester.getPlayer(), evt.getEntity());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
killMob(damager, evt.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (okay) {
|
}
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if damager is blacklisted
|
||||||
|
* Ensures damager is Player and not NPC
|
||||||
|
* Kills target mob/NPC if objective exists
|
||||||
|
*
|
||||||
|
* @param damager the attacking entity
|
||||||
|
* @param target the entity being attacked
|
||||||
|
* @since 3.1.4
|
||||||
|
*/
|
||||||
|
public void killMob(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 an NPC...
|
||||||
|
if (CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||||
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
|
if (quester.hasObjective(quest, "killNPC")) {
|
||||||
|
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//No? Must be a mob...
|
||||||
|
} else {
|
||||||
|
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
if (quester.hasObjective(quest, "killMob")) {
|
if (quester.hasObjective(quest, "killMob")) {
|
||||||
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
|
quester.killMob(quest, target.getLocation(), target.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;
|
|
||||||
}
|
}
|
||||||
|
} else if (damager instanceof TNTPrimed) {
|
||||||
|
TNTPrimed tnt = (TNTPrimed) damager;
|
||||||
|
Entity source = tnt.getSource();
|
||||||
|
if (source.isValid()) {
|
||||||
|
killPlayer(source, evt.getEntity());
|
||||||
}
|
}
|
||||||
if (evt.getEntity().getUniqueId().equals(player.getUniqueId())) {
|
} else if (damager instanceof Wolf) {
|
||||||
okay = false;
|
Wolf wolf = (Wolf) damager;
|
||||||
|
if (wolf.isTamed()) {
|
||||||
|
Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
|
||||||
|
killPlayer(quester.getPlayer(), evt.getEntity());
|
||||||
}
|
}
|
||||||
if (okay) {
|
} else {
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
killPlayer(damager, evt.getEntity());
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
|
||||||
if (quester.hasObjective(quest, "killPlayer")) {
|
|
||||||
quester.killPlayer(quest, evt.getEntity());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
Player target = evt.getEntity();
|
||||||
} else if (damager instanceof Player) {
|
if (plugin.checkQuester(target.getUniqueId()) == false) {
|
||||||
Player player = (Player) damager;
|
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||||
if (plugin.checkQuester(player.getUniqueId()) == false) {
|
|
||||||
boolean okay = true;
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Player player = evt.getEntity();
|
|
||||||
if (plugin.checkQuester(player.getUniqueId()) == false) {
|
|
||||||
Quester quester = plugin.getQuester(player.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