From 4338fad8cc34222c7be577fe8b78c22d5d183e47 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Thu, 14 Jul 2022 17:31:22 +0000 Subject: [PATCH] Moved MP reward task to proper location. --- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../{ => actor/tasks/npc}/MpRewardTask.java | 2 +- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../{ => actor/tasks/npc}/MpRewardTask.java | 2 +- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../{ => actor/tasks/npc}/MpRewardTask.java | 2 +- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../{ => actor/tasks/npc}/MpRewardTask.java | 2 +- .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ .../gameserver/model/MpRewardTask.java | 74 ------------------- .../l2jmobius/gameserver/model/actor/Npc.java | 2 +- .../model/actor/tasks/npc/MpRewardTask.java | 74 +++++++++++++++++++ 65 files changed, 1433 insertions(+), 1433 deletions(-) rename L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/{ => actor/tasks/npc}/MpRewardTask.java (94%) rename L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/{ => actor/tasks/npc}/MpRewardTask.java (94%) rename L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/{ => actor/tasks/npc}/MpRewardTask.java (94%) rename L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/{ => actor/tasks/npc}/MpRewardTask.java (94%) delete mode 100644 L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java delete mode 100644 L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/MpRewardTask.java create mode 100644 L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java index ab10923a72..cc643a4730 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java similarity index 94% rename from L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/MpRewardTask.java rename to L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java index fd196dffe2..c5dc59ec7b 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver.model; +package org.l2jmobius.gameserver.model.actor.tasks.npc; import java.util.concurrent.ScheduledFuture; diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java index e38514cadb..fb2ea5b058 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java similarity index 94% rename from L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/MpRewardTask.java rename to L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java index fd196dffe2..c5dc59ec7b 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver.model; +package org.l2jmobius.gameserver.model.actor.tasks.npc; import java.util.concurrent.ScheduledFuture; diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java index e38514cadb..fb2ea5b058 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java similarity index 94% rename from L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/MpRewardTask.java rename to L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java index fd196dffe2..c5dc59ec7b 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver.model; +package org.l2jmobius.gameserver.model.actor.tasks.npc; import java.util.concurrent.ScheduledFuture; diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java index e38514cadb..fb2ea5b058 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java similarity index 94% rename from L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/MpRewardTask.java rename to L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java index fd196dffe2..c5dc59ec7b 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver.model; +package org.l2jmobius.gameserver.model.actor.tasks.npc; import java.util.concurrent.ScheduledFuture; diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java index e38514cadb..fb2ea5b058 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java index e38514cadb..fb2ea5b058 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java index e38514cadb..fb2ea5b058 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java index e38514cadb..fb2ea5b058 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java index 359622553f..3a1f523d9b 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java index 359622553f..3a1f523d9b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java index 359622553f..3a1f523d9b 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java index 359622553f..3a1f523d9b 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java index ef691d5d8d..e784db24f4 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java index ef691d5d8d..e784db24f4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java index ef691d5d8d..e784db24f4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java index 886ec14ea3..2cb1ee959b 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java index 886ec14ea3..2cb1ee959b 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java index 886ec14ea3..2cb1ee959b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java index c9b1e3ad5f..94ea54a3f7 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java index ca447b23b2..99f12e961d 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Npc.java index ca447b23b2..99f12e961d 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Npc.java index ca447b23b2..99f12e961d 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/MpRewardTask.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/MpRewardTask.java deleted file mode 100644 index fd196dffe2..0000000000 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/MpRewardTask.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Npc.java index ca447b23b2..99f12e961d 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -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; diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java new file mode 100644 index 0000000000..c5dc59ec7b --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/tasks/npc/MpRewardTask.java @@ -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 . + */ +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); + } +}