mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-26 20:55:54 +01:00
Null checks for player kill event, per #1559
This commit is contained in:
parent
e190651b95
commit
bc9d77bb82
@ -28,7 +28,6 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.alessiodp.parties.api.interfaces.PartyPlayer;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -50,6 +49,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.material.Crops;
|
import org.bukkit.material.Crops;
|
||||||
|
|
||||||
import com.alessiodp.parties.api.interfaces.Party;
|
import com.alessiodp.parties.api.interfaces.Party;
|
||||||
|
import com.alessiodp.parties.api.interfaces.PartyPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -2244,8 +2244,16 @@ public class Quester implements Comparable<Quester> {
|
|||||||
* @param player The player to be killed
|
* @param player The player to be killed
|
||||||
*/
|
*/
|
||||||
public void killPlayer(final Quest quest, final Player player) {
|
public void killPlayer(final Quest quest, final Player player) {
|
||||||
final int playersKilled = getQuestData(quest).getPlayersKilled();
|
final QuestData questData = getQuestData(quest);
|
||||||
final int playersToKill = getCurrentStage(quest).playersToKill;
|
if (questData == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Stage currentStage = getCurrentStage(quest);
|
||||||
|
if (currentStage == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int playersKilled = questData.getPlayersKilled();
|
||||||
|
final int playersToKill = currentStage.playersToKill;
|
||||||
|
|
||||||
final ObjectiveType type = ObjectiveType.KILL_PLAYER;
|
final ObjectiveType type = ObjectiveType.KILL_PLAYER;
|
||||||
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
||||||
@ -2254,7 +2262,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
|
|
||||||
final int newPlayersKilled = playersKilled + 1;
|
final int newPlayersKilled = playersKilled + 1;
|
||||||
if (playersKilled < playersToKill) {
|
if (playersKilled < playersToKill) {
|
||||||
getQuestData(quest).setPlayersKilled(newPlayersKilled);
|
questData.setPlayersKilled(newPlayersKilled);
|
||||||
if (newPlayersKilled >= playersToKill) {
|
if (newPlayersKilled >= playersToKill) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null);
|
||||||
@ -4000,7 +4008,8 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
plugin.getLogger().severe("Error occurred while dispatching " + type.name() + " for " + quest.getName());
|
plugin.getLogger().severe("Error occurred while dispatching " + type.name() + " for quest ID "
|
||||||
|
+ quest.getId());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4051,8 +4060,8 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (partyPlayer != null && partyPlayer.getPartyId() != null) {
|
if (partyPlayer != null && partyPlayer.getPartyId() != null) {
|
||||||
final Party party = plugin.getDependencies().getPartiesApi().getParty(partyPlayer.getPartyId());
|
final Party party = plugin.getDependencies().getPartiesApi().getParty(partyPlayer.getPartyId());
|
||||||
if (party != null) {
|
if (party != null) {
|
||||||
long distanceSquared = quest.getOptions().getPartiesDistance() * quest.getOptions().getPartiesDistance();
|
final long distanceSquared = quest.getOptions().getPartiesDistance() * quest.getOptions().getPartiesDistance();
|
||||||
boolean offlinePlayers = quest.getOptions().canPartiesHandleOfflinePlayers();
|
final boolean offlinePlayers = quest.getOptions().canPartiesHandleOfflinePlayers();
|
||||||
if (offlinePlayers) {
|
if (offlinePlayers) {
|
||||||
for (final UUID id : party.getMembers()) {
|
for (final UUID id : party.getMembers()) {
|
||||||
if (!id.equals(getUUID())) {
|
if (!id.equals(getUUID())) {
|
||||||
@ -4063,7 +4072,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
for (final PartyPlayer pp : party.getOnlineMembers(true)) {
|
for (final PartyPlayer pp : party.getOnlineMembers(true)) {
|
||||||
if (!pp.getPlayerUUID().equals(getUUID())) {
|
if (!pp.getPlayerUUID().equals(getUUID())) {
|
||||||
if (distanceSquared > 0) {
|
if (distanceSquared > 0) {
|
||||||
Player player = Bukkit.getPlayer(pp.getPlayerUUID());
|
final Player player = Bukkit.getPlayer(pp.getPlayerUUID());
|
||||||
if (player != null && distanceSquared >= getPlayer().getLocation().distanceSquared(player.getLocation())) {
|
if (player != null && distanceSquared >= getPlayer().getLocation().distanceSquared(player.getLocation())) {
|
||||||
mq.add(plugin.getQuester(pp.getPlayerUUID()));
|
mq.add(plugin.getQuester(pp.getPlayerUUID()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user