diff --git a/src/main/java/net/Indyuce/mmocore/api/droptable/dropitem/DropTableDropItem.java b/src/main/java/net/Indyuce/mmocore/api/droptable/dropitem/DropTableDropItem.java index 61fbdebb..aa0c7f67 100644 --- a/src/main/java/net/Indyuce/mmocore/api/droptable/dropitem/DropTableDropItem.java +++ b/src/main/java/net/Indyuce/mmocore/api/droptable/dropitem/DropTableDropItem.java @@ -6,6 +6,7 @@ import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.droptable.DropTable; import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance; import net.Indyuce.mmocore.api.loot.LootBuilder; +import net.Indyuce.mmocore.api.player.PlayerData; import net.mmogroup.mmolib.api.MMOLineConfig; public class DropTableDropItem extends DropItem { @@ -23,7 +24,9 @@ public class DropTableDropItem extends DropItem { @Override public void collect(LootBuilder builder) { - if (dropTable.areConditionsMet(new ConditionInstance(builder.getEntity().getPlayer()))) + PlayerData data = builder.getEntity(); + if(!data.isOnline()) return; + if (dropTable.areConditionsMet(new ConditionInstance(data.getPlayer()))) for (int j = 0; j < rollAmount(); j++) builder.addLoot(dropTable.collect(builder)); } diff --git a/src/main/java/net/Indyuce/mmocore/api/event/CustomBlockMineEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/CustomBlockMineEvent.java index 21f55257..3cc6c087 100644 --- a/src/main/java/net/Indyuce/mmocore/api/event/CustomBlockMineEvent.java +++ b/src/main/java/net/Indyuce/mmocore/api/event/CustomBlockMineEvent.java @@ -29,8 +29,9 @@ public class CustomBlockMineEvent extends PlayerDataEvent implements Cancellable this.block = block; this.info = info; - this.drops = (info.hasDropTable() && info.getDropTable().areConditionsMet(new ConditionInstance(player.getPlayer()))) - ? info.collectDrops(new LootBuilder(player, 0)) : new ArrayList<>(); + this.drops = (info.hasDropTable() && player.isOnline() + && info.getDropTable().areConditionsMet(new ConditionInstance(player.getPlayer()))) + ? info.collectDrops(new LootBuilder(player, 0)) : new ArrayList<>(); this.experience = info.hasExperience() ? info.getExperience().newInfo() : null; } diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java b/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java index 42904ccc..774edc84 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java @@ -127,7 +127,7 @@ public class PlayerProfessions { value = MMOCore.plugin.boosterManager.calculateExp(profession, value); // display hologram - if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms")) + if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms") && playerData.isOnline()) if (loc != null && MMOCore.plugin.hologramSupport != null) MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer()); @@ -158,7 +158,7 @@ public class PlayerProfessions { playerData.giveExperience((int) profession.getExperience().calculate(level), null); } - if (check) { + if (check && playerData.isOnline()) { Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(playerData, profession, oldLevel, level)); new SmallParticleEffect(playerData.getPlayer(), Particle.SPELL_INSTANT); new ConfigMessage("profession-level-up").addPlaceholders("level", "" + level, "profession", profession.getName()) @@ -171,7 +171,8 @@ public class PlayerProfessions { int chars = (int) ((double) exp / needed * 20); for (int j = 0; j < 20; j++) bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|"; - MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio", + if(playerData.isOnline()) + MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio", MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)).send(playerData.getPlayer()); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/source/BrewPotionExperienceSource.java b/src/main/java/net/Indyuce/mmocore/api/experience/source/BrewPotionExperienceSource.java index 81599307..b6c95afa 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/source/BrewPotionExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/source/BrewPotionExperienceSource.java @@ -58,6 +58,7 @@ public class BrewPotionExperienceSource extends ExperienceSource { return; PlayerData data = PlayerData.get(playerOpt.get()); + if(!data.isOnline()) return; for (BrewPotionExperienceSource source : getSources()) if (source.matches(data, (PotionMeta) brewn.getItemMeta())) new PotionUpgrade(found, brewn).process(data.getPlayer()); diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java b/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java index 26469223..ed9de2b9 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java @@ -48,8 +48,12 @@ public abstract class ExperienceSource { public void giveExperience(PlayerData player, int amount, Location location) { if (hasProfession()) - player.getCollectionSkills().giveExperience(profession, amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE); + player.getCollectionSkills().giveExperience(profession, amount, location == null ? getPlayerLocation(player) : location, EXPSource.SOURCE); else - player.giveExperience(amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE); + player.giveExperience(amount, location == null ? getPlayerLocation(player) : location, EXPSource.SOURCE); + } + + private Location getPlayerLocation(PlayerData player) { + return player.isOnline() ? player.getPlayer().getLocation() : null; } } diff --git a/src/main/java/net/Indyuce/mmocore/api/loot/LootChestRegion.java b/src/main/java/net/Indyuce/mmocore/api/loot/LootChestRegion.java index 2ffa6491..541169f1 100644 --- a/src/main/java/net/Indyuce/mmocore/api/loot/LootChestRegion.java +++ b/src/main/java/net/Indyuce/mmocore/api/loot/LootChestRegion.java @@ -76,7 +76,7 @@ public class LootChestRegion { } public void spawnChest(PlayerData player) { - + if(!player.isOnline()) return; // first randomly determine the chest tier ChestTier tier = rollTier(); diff --git a/src/main/java/net/Indyuce/mmocore/api/player/CombatRunnable.java b/src/main/java/net/Indyuce/mmocore/api/player/CombatRunnable.java index bc114c29..8b950693 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/CombatRunnable.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/CombatRunnable.java @@ -14,7 +14,8 @@ public class CombatRunnable extends BukkitRunnable { public CombatRunnable(PlayerData player) { this.player = player; - MMOCore.plugin.configManager.getSimpleMessage("now-in-combat").send(player.getPlayer()); + if(player.isOnline()) + MMOCore.plugin.configManager.getSimpleMessage("now-in-combat").send(player.getPlayer()); Bukkit.getPluginManager().callEvent(new PlayerCombatEvent(player, true)); runTaskTimer(MMOCore.plugin, 20, 20); } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 95046c48..8aa95393 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -254,6 +254,7 @@ public class PlayerData extends OfflinePlayerData { public void refreshVanillaExp() { if (MMOCore.plugin.configManager.overrideVanillaExp) { + if(!isOnline()) return; getPlayer().setLevel(getLevel()); getPlayer().setExp(Math.max(0, Math.min(1, (float) experience / (float) getLevelUpExperience()))); } @@ -333,6 +334,7 @@ public class PlayerData extends OfflinePlayerData { } public void heal(double heal) { + if(!isOnline()) return; double newest = Math.max(0, Math.min(getPlayer().getHealth() + heal, getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())); if (getPlayer().getHealth() == newest) return; @@ -368,7 +370,7 @@ public class PlayerData extends OfflinePlayerData { } public void log(Level level, String message) { - MMOCore.plugin.getLogger().log(level, "[Userdata:" + getPlayer().getName() + "] " + message); + MMOCore.plugin.getLogger().log(level, "[Userdata:" + (isOnline() ? getPlayer().getName() : "Offline Player") + "] " + message); } public void setLastFriendRequest(long ms) { @@ -376,6 +378,7 @@ public class PlayerData extends OfflinePlayerData { } public void sendFriendRequest(PlayerData target) { + if(!isOnline() || !target.isOnline()) return; setLastFriendRequest(System.currentTimeMillis()); FriendRequest request = new FriendRequest(this, target); @@ -395,10 +398,12 @@ public class PlayerData extends OfflinePlayerData { giveStellium(-waypoint.getStelliumCost()); + if(!isOnline()) return; new BukkitRunnable() { int x = getPlayer().getLocation().getBlockX(), y = getPlayer().getLocation().getBlockY(), z = getPlayer().getLocation().getBlockZ(), t; public void run() { + if(!isOnline()) return; if (getPlayer().getLocation().getBlockX() != x || getPlayer().getLocation().getBlockY() != y || getPlayer().getLocation().getBlockZ() != z) { getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, .5f); @@ -442,7 +447,7 @@ public class PlayerData extends OfflinePlayerData { } // display hologram - if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms")) + if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms") && isOnline()) if (loc != null && MMOCore.plugin.hologramSupport != null) MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), getPlayer()); @@ -471,9 +476,11 @@ public class PlayerData extends OfflinePlayerData { if (level > oldLevel) { Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(this, null, oldLevel, level)); - new ConfigMessage("level-up").addPlaceholders("level", "" + level).send(getPlayer()); - getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); - new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT); + if(isOnline()) { + new ConfigMessage("level-up").addPlaceholders("level", "" + level).send(getPlayer()); + getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); + new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT); + } getStats().updateStats(); } @@ -577,6 +584,7 @@ public class PlayerData extends OfflinePlayerData { } public void displayActionBar(String message) { + if(!isOnline()) return; setActionBarTimeOut(MMOCore.plugin.actionBarManager.getTimeOut()); getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); } @@ -728,7 +736,7 @@ public class PlayerData extends OfflinePlayerData { */ SkillResult cast = skill.getSkill().whenCast(this, skill); if (!cast.isSuccessful()) { - if (!skill.getSkill().isPassive()) { + if (!skill.getSkill().isPassive() && isOnline()) { if (cast.getCancelReason() == CancelReason.LOCKED) MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill").send(getPlayer()); diff --git a/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java b/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java index 1b19829e..895c3d3f 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java @@ -20,6 +20,7 @@ public class FriendRequest extends Request { public void deny() { MMOCore.plugin.requestManager.unregisterRequest(getUniqueId()); + if(!target.isOnline()) return; target.getPlayer().playSound(target.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); } @@ -27,8 +28,10 @@ public class FriendRequest extends Request { getCreator().setLastFriendRequest(0); getCreator().addFriend(target.getUniqueId()); target.addFriend(getCreator().getUniqueId()); - MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()).send(getCreator().getPlayer()); - MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", getCreator().getPlayer().getName()).send(target.getPlayer()); + if(target.isOnline() && getCreator().isOnline()) { + MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()).send(getCreator().getPlayer()); + MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", getCreator().getPlayer().getName()).send(target.getPlayer()); + } MMOCore.plugin.requestManager.unregisterRequest(getUniqueId()); } } \ No newline at end of file diff --git a/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java b/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java index 1fa364cc..d6e82ffd 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java @@ -76,7 +76,7 @@ public class Party { // transfer ownership if (owner.equals(data)) { owner = members.get(0); - if(notify) MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership").send(owner.getPlayer()); + if(notify && owner.isOnline()) MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership").send(owner.getPlayer()); } } @@ -100,8 +100,9 @@ public class Party { public void sendPartyInvite(PlayerData inviter, PlayerData target) { invites.put(target.getUniqueId(), System.currentTimeMillis()); Request request = new PartyInvite(this, inviter, target); - new ConfigMessage("party-invite").addPlaceholders("player", inviter.getPlayer().getName(), "uuid", request.getUniqueId().toString()) - .sendAsJSon(target.getPlayer()); + if(inviter.isOnline() && target.isOnline()) + new ConfigMessage("party-invite").addPlaceholders("player", inviter.getPlayer().getName(), "uuid", request.getUniqueId().toString()) + .sendAsJSon(target.getPlayer()); MMOCore.plugin.requestManager.registerRequest(request); } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/social/PartyInvite.java b/src/main/java/net/Indyuce/mmocore/api/player/social/PartyInvite.java index b6154ba6..78c907a9 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/social/PartyInvite.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/social/PartyInvite.java @@ -28,9 +28,14 @@ public class PartyInvite extends Request { } public void accept() { - party.removeLastInvite(getCreator().getPlayer()); - party.getMembers().forEach(member -> MMOCore.plugin.configManager.getSimpleMessage("party-joined-other", "player", target.getPlayer().getName()).send(member.getPlayer())); - MMOCore.plugin.configManager.getSimpleMessage("party-joined", "owner", party.getOwner().getPlayer().getName()).send(target.getPlayer()); + if(getCreator().isOnline()) + party.removeLastInvite(getCreator().getPlayer()); + party.getMembers().forEach(member -> { + if(member.isOnline() && target.isOnline()) + MMOCore.plugin.configManager.getSimpleMessage("party-joined-other", "player", target.getPlayer().getName()).send(member.getPlayer()); + }); + if(party.getOwner().isOnline() && target.isOnline()) + MMOCore.plugin.configManager.getSimpleMessage("party-joined", "owner", party.getOwner().getPlayer().getName()).send(target.getPlayer()); party.addMember(target); InventoryManager.PARTY_VIEW.newInventory(target).open(); MMOCore.plugin.requestManager.unregisterRequest(getUniqueId()); diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java b/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java index db859e62..d50f4b06 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java @@ -33,7 +33,8 @@ public class PlayerQuests { this.playerData = playerData; bossbar = MMOLib.plugin.getVersion().getWrapper().createBossBar(new NamespacedKey(MMOCore.plugin, "quest_bar_" + playerData.getUniqueId().toString()), "", BarColor.PURPLE, BarStyle.SEGMENTED_20, new BarFlag[0]); - bossbar.addPlayer(playerData.getPlayer()); + if(playerData.isOnline()) + bossbar.addPlayer(playerData.getPlayer()); } @Deprecated diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/objective/ClickonObjective.java b/src/main/java/net/Indyuce/mmocore/api/quest/objective/ClickonObjective.java index a58f33a0..71fba1a7 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/objective/ClickonObjective.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/objective/ClickonObjective.java @@ -47,7 +47,7 @@ public class ClickonObjective extends Objective { return; Player player = event.getPlayer(); - if (player.equals(getPlayer().getPlayer())) + if (getPlayer().isOnline() && player.equals(getPlayer().getPlayer())) if (player.getWorld().equals(loc.getWorld()) && event.getClickedBlock().getLocation().distanceSquared(loc) < rangeSquared) getQuestProgress().completeObjective(); } diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/objective/GoToObjective.java b/src/main/java/net/Indyuce/mmocore/api/quest/objective/GoToObjective.java index fa1c6c29..87e7b09f 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/objective/GoToObjective.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/objective/GoToObjective.java @@ -46,7 +46,7 @@ public class GoToObjective extends Objective { return; Player player = event.getPlayer(); - if (player.equals(getPlayer().getPlayer())) + if (getPlayer().isOnline() && player.equals(getPlayer().getPlayer())) if (player.getWorld().equals(loc.getWorld()) && player.getLocation().distanceSquared(loc) < rangeSquared) getQuestProgress().completeObjective(); } diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java b/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java index 8c4f7253..eadff63b 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java @@ -37,6 +37,7 @@ public class KillMobObjective extends Objective { @EventHandler public void a(EntityKillEntityEvent event) { + if(!getPlayer().isOnline()) return; if (event.getTarget().getType() == type && event.getEntity().equals(getPlayer().getPlayer())) { count++; getQuestProgress().getPlayer().getQuestData().updateBossBar(); diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java b/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java index ec2e6482..7e1dca89 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java @@ -41,6 +41,7 @@ public class MineBlockObjective extends Objective { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void a(BlockBreakEvent event) { + if(!getQuestProgress().getPlayer().isOnline()) return; if ((!playerPlaced) && event.getBlock().hasMetadata("player_placed")) return; if (event.getPlayer().equals(getQuestProgress().getPlayer().getPlayer()) && event.getBlock().getType() == block) { @@ -53,6 +54,7 @@ public class MineBlockObjective extends Objective { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void b(CustomBlockMineEvent event) { + if(!getQuestProgress().getPlayer().isOnline()) return; if (event.getPlayer().equals(getQuestProgress().getPlayer().getPlayer()) && event.getBlock().getType() == block) { count++; getQuestProgress().getPlayer().getQuestData().updateBossBar(); diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java index c92671cc..bff68d0b 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java @@ -19,6 +19,7 @@ public class CommandTrigger extends Trigger { @Override public void apply(PlayerData player) { + if(!player.isOnline()) return; Bukkit.dispatchCommand(Bukkit.getConsoleSender(), format(player.getPlayer())); } diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ItemTrigger.java b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ItemTrigger.java index f02afb2a..daeef370 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ItemTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ItemTrigger.java @@ -22,6 +22,7 @@ public class ItemTrigger extends Trigger { @Override public void apply(PlayerData player) { + if(!player.isOnline()) return; new SmartGive(player.getPlayer()).give(new ItemStack(material, amount)); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java index ff24abd9..308d072f 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java @@ -18,6 +18,7 @@ public class MessageTrigger extends Trigger { @Override public void apply(PlayerData player) { + if(!player.isOnline()) return; player.getPlayer().sendMessage(format(player.getPlayer())); } diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SoundTrigger.java b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SoundTrigger.java index d7a6e908..ca4ef01f 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SoundTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SoundTrigger.java @@ -21,6 +21,7 @@ public class SoundTrigger extends Trigger { @Override public void apply(PlayerData player) { + if(!player.isOnline()) return; player.getPlayer().playSound(player.getPlayer().getLocation(), sound, vol, pitch); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java index 90af35ee..89b7c77c 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java @@ -150,6 +150,7 @@ public class MMOCoreUtils { // TODO worldguard flags support for no target public static boolean canTarget(PlayerData player, Entity target) { + if(!player.isOnline()) return false; // basic checks if (!(target instanceof LivingEntity) || player.getPlayer().equals(target) || target.isDead() || MMOLib.plugin.getEntities().findCustom(target)) diff --git a/src/main/java/net/Indyuce/mmocore/comp/citizens/TalktoCitizenObjective.java b/src/main/java/net/Indyuce/mmocore/comp/citizens/TalktoCitizenObjective.java index 2192799b..1b49caf9 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/citizens/TalktoCitizenObjective.java +++ b/src/main/java/net/Indyuce/mmocore/comp/citizens/TalktoCitizenObjective.java @@ -32,6 +32,7 @@ public class TalktoCitizenObjective extends Objective { @EventHandler public void a(CitizenInteractEvent event) { + if(!getQuestProgress().getPlayer().isOnline()) return; if (event.getPlayer().equals(getQuestProgress().getPlayer().getPlayer()) && event.getNPC().getId() == id) getQuestProgress().completeObjective(); } diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobSkill.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobSkill.java index 306d7032..5708247f 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobSkill.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobSkill.java @@ -62,7 +62,7 @@ public class MythicMobSkill extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { SkillResult cast = new SkillResult(data, skill); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; List targets = new ArrayList<>(); diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionObjective.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionObjective.java index afcd8c3a..e39c03bd 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionObjective.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionObjective.java @@ -38,6 +38,7 @@ public class KillMythicFactionObjective extends Objective { @EventHandler public void a(MythicMobDeathEvent event) { + if(!getQuestProgress().getPlayer().isOnline()) return; if (event.getKiller() instanceof Player && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) && event.getMob().hasFaction() && event.getMob().getFaction().equals(factionName)) { diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicMobObjective.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicMobObjective.java index fc1109f5..29497a53 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicMobObjective.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicMobObjective.java @@ -38,6 +38,7 @@ public class KillMythicMobObjective extends Objective { @EventHandler public void a(MythicMobDeathEvent event) { + if(!getQuestProgress().getPlayer().isOnline()) return; if (event.getKiller() instanceof Player && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) && event.getMob().getType().getInternalName().equals(internalName)) { count++; getQuestProgress().getPlayer().getQuestData().updateBossBar(); diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/MythicMobSkillTrigger.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/MythicMobSkillTrigger.java index ac7f1ed4..0c17ac50 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/MythicMobSkillTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/MythicMobSkillTrigger.java @@ -28,6 +28,7 @@ public class MythicMobSkillTrigger extends Trigger { @Override public void apply(PlayerData player) { + if(!player.isOnline()) return; List targets = new ArrayList<>(); targets.add(player.getPlayer()); MythicMobs.inst().getAPIHelper().castSkill(player.getPlayer(), this.skill.getInternalName(), player.getPlayer(), player.getPlayer().getEyeLocation(), targets, null, 1); diff --git a/src/main/java/net/Indyuce/mmocore/comp/vault/MoneyTrigger.java b/src/main/java/net/Indyuce/mmocore/comp/vault/MoneyTrigger.java index 8badf10c..a8c0f872 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/vault/MoneyTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/comp/vault/MoneyTrigger.java @@ -26,7 +26,7 @@ public class MoneyTrigger extends Trigger { * instanced when the plugin loads and the economy has not been loaded * yet. */ - if (!MMOCore.plugin.economy.isValid()) + if (!MMOCore.plugin.economy.isValid() || !player.isOnline()) return; if (operation == Operation.GIVE) diff --git a/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java b/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java index 240ac52d..09e7771e 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java @@ -294,7 +294,8 @@ public class PlayerStats extends EditableInventory { holders.register("attribute_points", "" + data.getAttributePoints()); holders.register("progress", bar); holders.register("next_level", "" + nextLevelExp); - holders.register("player", "" + data.getPlayer().getName()); + if(data.isOnline()) + holders.register("player", "" + data.getPlayer().getName()); holders.register("class", "" + data.getProfess().getName()); return holders; diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java b/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java index 1d9aa562..92860271 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java @@ -109,7 +109,8 @@ public class EditableFriendList extends EditableInventory { PlayerData data = PlayerData.get(friend); Placeholders holders = new Placeholders(); - holders.register("name", data.getPlayer().getName()); + if(data.isOnline()) + holders.register("name", data.getPlayer().getName()); holders.register("class", data.getProfess().getName()); holders.register("level", data.getLevel()); holders.register("online_since", new DelayFormat(2).format(System.currentTimeMillis() - data.getLastLogin())); diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java index 777eacdd..e606673a 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java @@ -48,7 +48,9 @@ public class EditableGuildAdmin extends EditableInventory { PlayerData member = PlayerData.get(inv.getPlayerData().getGuild().getMembers().get(n)); Placeholders holders = new Placeholders(); - holders.register("name", member.getPlayer().getName()); + + if(member.isOnline()) + holders.register("name", member.getPlayer().getName()); holders.register("class", member.getProfess().getName()); holders.register("level", "" + member.getLevel()); holders.register("since", new DelayFormat(2).format(System.currentTimeMillis() - member.getLastLogin())); @@ -64,6 +66,7 @@ public class EditableGuildAdmin extends EditableInventory { if (meta instanceof SkullMeta) Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> { + if(!member.isOnline()) return; ((SkullMeta) meta).setOwningPlayer(member.getPlayer()); disp.setItemMeta(meta); }); diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java index c8e88cda..4be425e7 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java @@ -48,7 +48,8 @@ public class EditablePartyView extends EditableInventory { PlayerData member = inv.getPlayerData().getParty().getMembers().get(n); Placeholders holders = new Placeholders(); - holders.register("name", member.getPlayer().getName()); + if(member.isOnline()) + holders.register("name", member.getPlayer().getName()); holders.register("class", member.getProfess().getName()); holders.register("level", "" + member.getLevel()); holders.register("since", new DelayFormat(2).format(System.currentTimeMillis() - member.getLastLogin())); @@ -67,6 +68,7 @@ public class EditablePartyView extends EditableInventory { */ if (meta instanceof SkullMeta) Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> { + if(!member.isOnline()) return; ((SkullMeta) meta).setOwningPlayer(member.getPlayer()); disp.setItemMeta(meta); }); diff --git a/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java b/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java index fd29fd31..36eedb71 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java +++ b/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java @@ -66,6 +66,7 @@ public class SpellCast implements Listener { @EventHandler(ignoreCancelled = false) public void onSkillCast(PlayerItemHeldEvent event) { Player player = event.getPlayer(); + if(!playerData.isOnline()) return; if (!event.getPlayer().equals(playerData.getPlayer())) return; @@ -92,6 +93,7 @@ public class SpellCast implements Listener { @EventHandler public void stopCasting(PlayerSwapHandItemsEvent event) { Player player = event.getPlayer(); + if(!playerData.isOnline()) return; if (event.getPlayer().equals(playerData.getPlayer()) && !player.isSneaking()) { player.playSound(player.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1, 2); MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(playerData.getPlayer()); @@ -107,6 +109,7 @@ public class SpellCast implements Listener { private String getFormat(PlayerData data) { String str = ""; + if(!data.isOnline()) return str; for (int j = 0; j < data.getBoundSkills().size(); j++) { SkillInfo skill = data.getBoundSkill(j); str += (str.isEmpty() ? "" : split) diff --git a/src/main/java/net/Indyuce/mmocore/listener/option/DeathExperienceLoss.java b/src/main/java/net/Indyuce/mmocore/listener/option/DeathExperienceLoss.java index 751b6e02..83de996a 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/option/DeathExperienceLoss.java +++ b/src/main/java/net/Indyuce/mmocore/listener/option/DeathExperienceLoss.java @@ -17,6 +17,7 @@ public class DeathExperienceLoss implements Listener { PlayerData data = PlayerData.get(event.getEntity()); int loss = (int) (data.getExperience() * this.loss); data.setExperience(data.getExperience() - loss); - new ConfigMessage("death-exp-loss").addPlaceholders("loss", "" + loss).send(data.getPlayer()); + if(data.isOnline()) + new ConfigMessage("death-exp-loss").addPlaceholders("loss", "" + loss).send(data.getPlayer()); } } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Ambers.java b/src/main/java/net/Indyuce/mmocore/skill/Ambers.java index 090275ef..245eb15b 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Ambers.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Ambers.java @@ -70,6 +70,7 @@ public class Ambers extends Skill implements Listener { @Override public void run() { + if(!data.isOnline()) return; if (j++ > 66 || !data.getPlayer().getWorld().equals(loc.getWorld())) { cancel(); return; diff --git a/src/main/java/net/Indyuce/mmocore/skill/Combo_Attack.java b/src/main/java/net/Indyuce/mmocore/skill/Combo_Attack.java index 956fc4c9..25dc5255 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Combo_Attack.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Combo_Attack.java @@ -43,6 +43,7 @@ public class Combo_Attack extends Skill { @Override public void run() { + if(!data.isOnline()) return; if (c++ > count) { cancel(); return; diff --git a/src/main/java/net/Indyuce/mmocore/skill/Control.java b/src/main/java/net/Indyuce/mmocore/skill/Control.java index febe4bf8..1a7e9841 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Control.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Control.java @@ -40,7 +40,8 @@ public class Control extends Skill { if (!cast.isSuccessful()) return cast; - data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 1); + if(data.isOnline()) + data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 1); cast.getTarget().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 0)); new TelekinesyRunnable(data, cast.getTarget(), cast.getModifier("knockback") / 100, cast.getModifier("duration")); return cast; @@ -67,6 +68,7 @@ public class Control extends Skill { @EventHandler public void a(PlayerInteractEvent event) { + if(!data.isOnline()) return; if (event.getPlayer().equals(data.getPlayer()) && event.getAction().name().contains("LEFT_CLICK")) { Vector vec = data.getPlayer().getEyeLocation().getDirection().multiply(3 * f); vec.setY(Math.max(.5, vec.getY() / 2)); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Deep_Wound.java b/src/main/java/net/Indyuce/mmocore/skill/Deep_Wound.java index 10ce0690..5c98ec7b 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Deep_Wound.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Deep_Wound.java @@ -31,7 +31,7 @@ public class Deep_Wound extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { TargetSkillResult cast = new TargetSkillResult(data, skill, 3); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; LivingEntity target = cast.getTarget(); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java b/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java index 1f71898b..7114fa42 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java @@ -45,7 +45,8 @@ public class Empowered_Attack extends Skill { if (!cast.isSuccessful()) return cast; - data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 1); + if(data.isOnline()) + data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 1); new EmpoweredAttack(data, cast.getModifier("extra"), cast.getModifier("ratio"), cast.getModifier("radius")); return cast; } @@ -69,7 +70,8 @@ public class Empowered_Attack extends Skill { this.r = ratio / 100; this.rad = radius; - new SmallParticleEffect(player.getPlayer(), Particle.FIREWORKS_SPARK); + if(player.isOnline()) + new SmallParticleEffect(player.getPlayer(), Particle.FIREWORKS_SPARK); Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin); Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> close(), 80); @@ -81,6 +83,7 @@ public class Empowered_Attack extends Skill { @EventHandler public void a(PlayerAttackEvent event) { + if(!player.isOnline()) return; if (event.getPlayer().equals(player.getPlayer()) && event.getAttack().hasType(DamageType.WEAPON)) { close(); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Evade.java b/src/main/java/net/Indyuce/mmocore/skill/Evade.java index b74a929b..c8266802 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Evade.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Evade.java @@ -36,9 +36,10 @@ public class Evade extends Skill { SkillResult cast = new SkillResult(data, skill); if (!cast.isSuccessful()) return cast; - - data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 2); - new SmallParticleEffect(data.getPlayer(), Particle.CLOUD); + if(data.isOnline()) { + data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 2); + new SmallParticleEffect(data.getPlayer(), Particle.CLOUD); + } new EvadeSkill(data, cast.getModifier("duration")); return cast; } @@ -61,6 +62,7 @@ public class Evade extends Skill { @EventHandler(priority = EventPriority.LOW) public void a(EntityDamageEvent event) { + if(!data.isOnline()) return; if (event.getEntity().equals(data.getPlayer())) event.setCancelled(true); } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java b/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java index 355e0f88..b5cb1485 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java @@ -76,12 +76,15 @@ public class Fire_Rage extends Skill { Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> close(), (long) (cast.getModifier("duration") * 20)); runTaskTimer(MMOCore.plugin, 0, 1); - data.getPlayer().removePotionEffect(PotionEffectType.SLOW); - data.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (cast.getModifier("duration") * 20), 1)); + if(data.isOnline()) { + data.getPlayer().removePotionEffect(PotionEffectType.SLOW); + data.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (cast.getModifier("duration") * 20), 1)); + } } @EventHandler public void a(PlayerInteractEvent event) { + if(!data.isOnline()) return; if (event.getPlayer().equals(data.getPlayer()) && event.getAction().name().contains("LEFT_CLICK") && (System.currentTimeMillis() - last) > timeOut) { last = System.currentTimeMillis(); castEffect(); @@ -92,6 +95,7 @@ public class Fire_Rage extends Skill { } private void castEffect() { + if(!data.isOnline()) return; VectorRotation rotation = new VectorRotation(data.getPlayer().getEyeLocation()); for (double a = 0; a < Math.PI * 2; a += Math.PI / 13) { Vector vec = rotation.rotate(new Vector(Math.cos(a), Math.sin(a), 0)).add(data.getPlayer().getEyeLocation().getDirection().multiply(.5)).multiply(.3); @@ -108,6 +112,7 @@ public class Fire_Rage extends Skill { } private void fireball(boolean last) { + if(!data.isOnline()) return; if (last) { data.getPlayer().removePotionEffect(PotionEffectType.SLOW); data.getPlayer().removePotionEffect(PotionEffectType.SLOW); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Fire_Storm.java b/src/main/java/net/Indyuce/mmocore/skill/Fire_Storm.java index 204f907c..dc8a6bab 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Fire_Storm.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Fire_Storm.java @@ -35,7 +35,7 @@ public class Fire_Storm extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { TargetSkillResult cast = new TargetSkillResult(data, skill, 20); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; LivingEntity target = cast.getTarget(); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Fireball.java b/src/main/java/net/Indyuce/mmocore/skill/Fireball.java index ff5d59f3..473f4d7f 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Fireball.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Fireball.java @@ -37,7 +37,7 @@ public class Fireball extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { SkillResult cast = new SkillResult(data, skill); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Furtive_Strike.java b/src/main/java/net/Indyuce/mmocore/skill/Furtive_Strike.java index 34681059..b76fe517 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Furtive_Strike.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Furtive_Strike.java @@ -31,7 +31,7 @@ public class Furtive_Strike extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { TargetSkillResult cast = new TargetSkillResult(data, skill, 3); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; LivingEntity target = cast.getTarget(); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java b/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java index cbc62d3b..b1f349fb 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java @@ -40,7 +40,7 @@ public class Ice_Spikes extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { LocationSkillResult cast = new LocationSkillResult(data, skill, 20); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; Location loc = cast.getHit(); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java b/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java index 553e4beb..64c73f5e 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java @@ -99,7 +99,7 @@ public class Power_Mark extends Skill implements Listener { @Override public void run() { - + if(!data.isOnline()) return; if (j++ > duration * 20) { unregister(); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Telekinesy.java b/src/main/java/net/Indyuce/mmocore/skill/Telekinesy.java index 3efd5b9c..209dac5a 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Telekinesy.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Telekinesy.java @@ -36,7 +36,7 @@ public class Telekinesy extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { TargetSkillResult cast = new TargetSkillResult(data, skill, 7); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 1); @@ -67,6 +67,7 @@ public class Telekinesy extends Skill { @EventHandler public void a(PlayerInteractEvent event) { + if(!data.isOnline()) return; if (event.getPlayer().equals(data.getPlayer()) && event.getAction().name().contains("LEFT_CLICK")) { entity.setVelocity(data.getPlayer().getEyeLocation().getDirection().multiply(1.5 * f)); entity.getWorld().playSound(entity.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 1); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Warp.java b/src/main/java/net/Indyuce/mmocore/skill/Warp.java index 20cef31a..993753c8 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Warp.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Warp.java @@ -27,7 +27,7 @@ public class Warp extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { WarpCast cast = new WarpCast(data, skill); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 2); @@ -52,7 +52,8 @@ public class Warp extends Skill { public WarpCast(PlayerData data, SkillInfo skill) { super(data, skill); - if (isSuccessful() && (block = data.getPlayer().getTargetBlock(null, (int) getModifier("range"))) == null) + if(!data.isOnline()) abort(); + else if (isSuccessful() && (block = data.getPlayer().getTargetBlock(null, (int) getModifier("range"))) == null) abort(); } } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Weaken.java b/src/main/java/net/Indyuce/mmocore/skill/Weaken.java index 9f9b5dfc..80b4247a 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Weaken.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Weaken.java @@ -35,7 +35,7 @@ public class Weaken extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { TargetSkillResult cast = new TargetSkillResult(data, skill, 7); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || !data.isOnline()) return cast; LivingEntity target = cast.getTarget();