mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-30 01:13:38 +01:00
Lots and LOTS of isOnline checks
This commit is contained in:
parent
e85003bc31
commit
938632e81a
@ -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));
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ public class CustomBlockMineEvent extends PlayerDataEvent implements Cancellable
|
||||
|
||||
this.block = block;
|
||||
this.info = info;
|
||||
this.drops = (info.hasDropTable() && info.getDropTable().areConditionsMet(new ConditionInstance(player.getPlayer())))
|
||||
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;
|
||||
}
|
||||
|
@ -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,6 +171,7 @@ public class PlayerProfessions {
|
||||
int chars = (int) ((double) exp / needed * 20);
|
||||
for (int j = 0; j < 20; j++)
|
||||
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
|
||||
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());
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public class BrewPotionExperienceSource extends ExperienceSource<PotionMeta> {
|
||||
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());
|
||||
|
@ -48,8 +48,12 @@ public abstract class ExperienceSource<T> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -14,6 +14,7 @@ public class CombatRunnable extends BukkitRunnable {
|
||||
public CombatRunnable(PlayerData player) {
|
||||
this.player = player;
|
||||
|
||||
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);
|
||||
|
@ -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));
|
||||
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());
|
||||
|
||||
|
@ -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());
|
||||
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());
|
||||
}
|
||||
}
|
@ -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,6 +100,7 @@ public class Party {
|
||||
public void sendPartyInvite(PlayerData inviter, PlayerData target) {
|
||||
invites.put(target.getUniqueId(), System.currentTimeMillis());
|
||||
Request request = new PartyInvite(this, inviter, target);
|
||||
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);
|
||||
|
@ -28,8 +28,13 @@ public class PartyInvite extends Request {
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
if(getCreator().isOnline())
|
||||
party.removeLastInvite(getCreator().getPlayer());
|
||||
party.getMembers().forEach(member -> MMOCore.plugin.configManager.getSimpleMessage("party-joined-other", "player", target.getPlayer().getName()).send(member.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();
|
||||
|
@ -33,6 +33,7 @@ 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]);
|
||||
if(playerData.isOnline())
|
||||
bossbar.addPlayer(playerData.getPlayer());
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<Entity> targets = new ArrayList<>();
|
||||
|
@ -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)) {
|
||||
|
@ -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();
|
||||
|
@ -28,6 +28,7 @@ public class MythicMobSkillTrigger extends Trigger {
|
||||
|
||||
@Override
|
||||
public void apply(PlayerData player) {
|
||||
if(!player.isOnline()) return;
|
||||
List<Entity> targets = new ArrayList<>();
|
||||
targets.add(player.getPlayer());
|
||||
MythicMobs.inst().getAPIHelper().castSkill(player.getPlayer(), this.skill.getInternalName(), player.getPlayer(), player.getPlayer().getEyeLocation(), targets, null, 1);
|
||||
|
@ -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)
|
||||
|
@ -294,6 +294,7 @@ public class PlayerStats extends EditableInventory {
|
||||
holders.register("attribute_points", "" + data.getAttributePoints());
|
||||
holders.register("progress", bar);
|
||||
holders.register("next_level", "" + nextLevelExp);
|
||||
if(data.isOnline())
|
||||
holders.register("player", "" + data.getPlayer().getName());
|
||||
holders.register("class", "" + data.getProfess().getName());
|
||||
|
||||
|
@ -109,6 +109,7 @@ public class EditableFriendList extends EditableInventory {
|
||||
PlayerData data = PlayerData.get(friend);
|
||||
|
||||
Placeholders holders = new Placeholders();
|
||||
if(data.isOnline())
|
||||
holders.register("name", data.getPlayer().getName());
|
||||
holders.register("class", data.getProfess().getName());
|
||||
holders.register("level", data.getLevel());
|
||||
|
@ -48,6 +48,8 @@ public class EditableGuildAdmin extends EditableInventory {
|
||||
PlayerData member = PlayerData.get(inv.getPlayerData().getGuild().getMembers().get(n));
|
||||
|
||||
Placeholders holders = new Placeholders();
|
||||
|
||||
if(member.isOnline())
|
||||
holders.register("name", member.getPlayer().getName());
|
||||
holders.register("class", member.getProfess().getName());
|
||||
holders.register("level", "" + member.getLevel());
|
||||
@ -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);
|
||||
});
|
||||
|
@ -48,6 +48,7 @@ public class EditablePartyView extends EditableInventory {
|
||||
PlayerData member = inv.getPlayerData().getParty().getMembers().get(n);
|
||||
|
||||
Placeholders holders = new Placeholders();
|
||||
if(member.isOnline())
|
||||
holders.register("name", member.getPlayer().getName());
|
||||
holders.register("class", member.getProfess().getName());
|
||||
holders.register("level", "" + member.getLevel());
|
||||
@ -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);
|
||||
});
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
if(data.isOnline())
|
||||
new ConfigMessage("death-exp-loss").addPlaceholders("loss", "" + loss).send(data.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -43,6 +43,7 @@ public class Combo_Attack extends Skill {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!data.isOnline()) return;
|
||||
if (c++ > count) {
|
||||
cancel();
|
||||
return;
|
||||
|
@ -40,6 +40,7 @@ public class Control extends Skill {
|
||||
if (!cast.isSuccessful())
|
||||
return cast;
|
||||
|
||||
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"));
|
||||
@ -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));
|
||||
|
@ -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();
|
||||
|
@ -45,6 +45,7 @@ public class Empowered_Attack extends Skill {
|
||||
if (!cast.isSuccessful())
|
||||
return cast;
|
||||
|
||||
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,6 +70,7 @@ public class Empowered_Attack extends Skill {
|
||||
this.r = ratio / 100;
|
||||
this.rad = radius;
|
||||
|
||||
if(player.isOnline())
|
||||
new SmallParticleEffect(player.getPlayer(), Particle.FIREWORKS_SPARK);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
|
||||
@ -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();
|
||||
|
||||
|
@ -36,9 +36,10 @@ public class Evade extends Skill {
|
||||
SkillResult cast = new SkillResult(data, skill);
|
||||
if (!cast.isSuccessful())
|
||||
return cast;
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
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);
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user