Moved MP reward task to proper location.

This commit is contained in:
MobiusDevelopment 2022-07-14 17:31:22 +00:00
parent d7a17d1150
commit 4338fad8cc
65 changed files with 1433 additions and 1433 deletions

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -49,7 +49,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -61,6 +60,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -49,7 +49,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -61,6 +60,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -49,7 +49,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -61,6 +60,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -48,7 +48,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -60,6 +59,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -49,7 +49,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -61,6 +60,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -49,7 +49,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -61,6 +60,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -49,7 +49,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -61,6 +60,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -1,74 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}

View File

@ -49,7 +49,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.MpRewardTask;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Spawn;
import org.l2jmobius.gameserver.model.StatSet;
@ -61,6 +60,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Teleporter;
import org.l2jmobius.gameserver.model.actor.instance.Warehouse;
import org.l2jmobius.gameserver.model.actor.stat.NpcStat;
import org.l2jmobius.gameserver.model.actor.status.NpcStatus;
import org.l2jmobius.gameserver.model.actor.tasks.npc.MpRewardTask;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;

View File

@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.actor.tasks.npc;
import java.util.concurrent.ScheduledFuture;
import org.l2jmobius.Config;
import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
/**
* @author UnAfraid
*/
public class MpRewardTask
{
private int _count;
private final double _value;
private final ScheduledFuture<?> _task;
private final Creature _creature;
public MpRewardTask(Creature creature, Npc npc)
{
final NpcTemplate template = npc.getTemplate();
_creature = creature;
_count = template.getMpRewardTicks();
_value = calculateBaseValue(npc, creature);
_task = ThreadPool.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**
* @param npc
* @param creature
* @return
*/
private double calculateBaseValue(Npc npc, Creature creature)
{
final NpcTemplate template = npc.getTemplate();
switch (template.getMpRewardType())
{
case PER:
{
return (creature.getMaxMp() * (template.getMpRewardValue() / 100d)) / template.getMpRewardTicks();
}
}
return template.getMpRewardValue() / template.getMpRewardTicks();
}
private void run()
{
if ((--_count <= 0) || (_creature.isPlayer() && !_creature.getActingPlayer().isOnline()))
{
_task.cancel(false);
return;
}
_creature.setCurrentMp(_creature.getCurrentMp() + _value);
}
}