Addition of PvpFlagTaskManager.
This commit is contained in:
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -343,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -791,8 +791,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -819,26 +817,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -14010,11 +14000,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -168,7 +168,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -345,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -793,8 +793,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -821,26 +819,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -14017,11 +14007,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -169,7 +169,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -347,6 +346,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -795,8 +795,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -823,26 +821,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -14020,11 +14010,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -351,6 +350,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookC
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -800,8 +800,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -828,26 +826,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Monster Book variables
|
||||
@@ -13992,11 +13982,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -349,6 +348,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookC
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -796,8 +796,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -824,26 +822,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Monster Book variables
|
||||
@@ -13954,11 +13944,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -349,6 +348,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookC
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -796,8 +796,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -824,26 +822,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Monster Book variables
|
||||
@@ -13957,11 +13947,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -349,6 +348,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookC
|
||||
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -796,8 +796,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -824,26 +822,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Monster Book variables
|
||||
@@ -13963,11 +13953,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -170,7 +170,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -356,6 +355,7 @@ import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookR
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -803,8 +803,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -831,26 +829,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Monster Book variables
|
||||
@@ -13971,11 +13961,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -169,7 +169,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -350,6 +349,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -797,8 +797,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -825,26 +823,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -14012,11 +14002,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+1
-96
@@ -2939,36 +2939,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task lauching the function stopPvPFlag().
|
||||
*/
|
||||
class PvPFlag implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// try
|
||||
// {
|
||||
if (System.currentTimeMillis() > _pvpFlagLasts)
|
||||
{
|
||||
stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_pvpFlagLasts - 5000))
|
||||
{
|
||||
updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
}
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// LOGGER.warning("error in pvp flag task: " + e);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/** Map 32 bits (0x0000) containing all abnormal effect in progress. */
|
||||
private int _AbnormalEffects;
|
||||
|
||||
@@ -8326,71 +8296,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
_castInterruptTime = newSkillCastEndTime - 12;
|
||||
}
|
||||
|
||||
/** The _ pvp reg task. */
|
||||
private Future<?> _PvPRegTask;
|
||||
|
||||
/** The _pvp flag lasts. */
|
||||
long _pvpFlagLasts;
|
||||
|
||||
/**
|
||||
* Sets the pvp flag lasts.
|
||||
* @param time the new pvp flag lasts
|
||||
*/
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pvp flag lasts.
|
||||
* @return the pvp flag lasts
|
||||
*/
|
||||
public long getPvpFlagLasts()
|
||||
{
|
||||
return _pvpFlagLasts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start pvp flag.
|
||||
*/
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
|
||||
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlag(), 1000, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp reg task.
|
||||
*/
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_PvPRegTask != null)
|
||||
{
|
||||
_PvPRegTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp flag.
|
||||
*/
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
|
||||
updatePvPFlag(0);
|
||||
|
||||
_PvPRegTask = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pvp flag.
|
||||
* @param value the value
|
||||
*/
|
||||
public void updatePvPFlag(int value)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Random Damage in function of the weapon.
|
||||
* @param target the target
|
||||
@@ -8409,7 +8314,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "mob " + getObjectId();
|
||||
return "Creature " + getObjectId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+46
-1
@@ -221,6 +221,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradeStart;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
import org.l2jmobius.gameserver.util.IllegalPlayerAction;
|
||||
@@ -299,6 +300,7 @@ public class PlayerInstance extends Playable
|
||||
private int _lastKill = 0;
|
||||
private int _count = 0;
|
||||
private byte _pvpFlag;
|
||||
private long _pvpFlagLasts;
|
||||
private byte _siegeState = 0;
|
||||
private int _curWeightPenalty = 0;
|
||||
private byte _zoneValidateCounter = 4;
|
||||
@@ -1638,7 +1640,50 @@ public class PlayerInstance extends Playable
|
||||
return _pvpFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Sets the pvp flag lasts.
|
||||
* @param time the new pvp flag lasts
|
||||
*/
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pvp flag lasts.
|
||||
* @return the pvp flag lasts
|
||||
*/
|
||||
public long getPvpFlagLasts()
|
||||
{
|
||||
return _pvpFlagLasts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start pvp flag.
|
||||
*/
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp reg task.
|
||||
*/
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp flag.
|
||||
*/
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
}
|
||||
|
||||
public void updatePvPFlag(int value)
|
||||
{
|
||||
if (getPvpFlag() == value)
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 5000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
@@ -2982,36 +2982,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task lauching the function stopPvPFlag().
|
||||
*/
|
||||
class PvPFlag implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// try
|
||||
// {
|
||||
if (System.currentTimeMillis() > _pvpFlagLasts)
|
||||
{
|
||||
stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_pvpFlagLasts - 5000))
|
||||
{
|
||||
updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
}
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// LOGGER.warning("error in pvp flag task: " + e);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/** Map 32 bits (0x0000) containing all abnormal effect in progress. */
|
||||
private int _AbnormalEffects;
|
||||
|
||||
@@ -8373,71 +8343,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
_castInterruptTime = newSkillCastEndTime - 12;
|
||||
}
|
||||
|
||||
/** The _ pvp reg task. */
|
||||
private Future<?> _PvPRegTask;
|
||||
|
||||
/** The _pvp flag lasts. */
|
||||
long _pvpFlagLasts;
|
||||
|
||||
/**
|
||||
* Sets the pvp flag lasts.
|
||||
* @param time the new pvp flag lasts
|
||||
*/
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pvp flag lasts.
|
||||
* @return the pvp flag lasts
|
||||
*/
|
||||
public long getPvpFlagLasts()
|
||||
{
|
||||
return _pvpFlagLasts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start pvp flag.
|
||||
*/
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
|
||||
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlag(), 1000, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp reg task.
|
||||
*/
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_PvPRegTask != null)
|
||||
{
|
||||
_PvPRegTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp flag.
|
||||
*/
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
|
||||
updatePvPFlag(0);
|
||||
|
||||
_PvPRegTask = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pvp flag.
|
||||
* @param value the value
|
||||
*/
|
||||
public void updatePvPFlag(int value)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Random Damage in function of the weapon.
|
||||
* @param target the target
|
||||
@@ -8456,7 +8361,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "mob " + getObjectId();
|
||||
return "Creature " + getObjectId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+46
-1
@@ -229,6 +229,7 @@ import org.l2jmobius.gameserver.network.serverpackets.TradeStart;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
import org.l2jmobius.gameserver.util.IllegalPlayerAction;
|
||||
@@ -307,6 +308,7 @@ public class PlayerInstance extends Playable
|
||||
private int _lastKill = 0;
|
||||
private int _count = 0;
|
||||
private byte _pvpFlag;
|
||||
private long _pvpFlagLasts;
|
||||
private byte _siegeState = 0;
|
||||
private int _curWeightPenalty = 0;
|
||||
private int _lastCompassZone; // the last compass zone update send to the client
|
||||
@@ -1652,7 +1654,50 @@ public class PlayerInstance extends Playable
|
||||
return _pvpFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Sets the pvp flag lasts.
|
||||
* @param time the new pvp flag lasts
|
||||
*/
|
||||
public void setPvpFlagLasts(long time)
|
||||
{
|
||||
_pvpFlagLasts = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pvp flag lasts.
|
||||
* @return the pvp flag lasts
|
||||
*/
|
||||
public long getPvpFlagLasts()
|
||||
{
|
||||
return _pvpFlagLasts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start pvp flag.
|
||||
*/
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp reg task.
|
||||
*/
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop pvp flag.
|
||||
*/
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
}
|
||||
|
||||
public void updatePvPFlag(int value)
|
||||
{
|
||||
if (getPvpFlag() == value)
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 5000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-19
@@ -161,7 +161,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.LookingForFishTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetSoulsTask;
|
||||
@@ -322,6 +321,7 @@ import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -796,8 +796,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -864,27 +862,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Character UI
|
||||
@@ -14420,11 +14409,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-19
@@ -162,7 +162,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.LookingForFishTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoBonusTaskEnd;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
@@ -327,6 +326,7 @@ import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -815,8 +815,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -883,27 +881,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Character UI
|
||||
@@ -14514,11 +14503,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -343,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -786,8 +786,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -814,26 +812,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13766,11 +13756,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -343,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -786,8 +786,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -814,26 +812,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13766,11 +13756,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -341,6 +340,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -784,8 +784,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -812,26 +810,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13751,11 +13741,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -170,7 +170,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -345,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -791,8 +791,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -819,26 +817,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13800,11 +13790,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -170,7 +170,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -345,6 +344,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -791,8 +791,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -819,26 +817,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13800,11 +13790,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -173,7 +173,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -353,6 +352,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -799,8 +799,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -827,26 +825,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13778,11 +13768,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -167,7 +167,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -343,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommi
|
||||
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -788,8 +788,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -816,26 +814,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13787,11 +13777,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
|
||||
{
|
||||
_taskWarnUserTakeBreak.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
+3
-18
@@ -173,7 +173,6 @@ import org.l2jmobius.gameserver.model.actor.tasks.player.FameTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.HennaDurationTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.InventoryEnableTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PetFeedTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.PvPFlagTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RecoGiveTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.RentPetTask;
|
||||
import org.l2jmobius.gameserver.model.actor.tasks.player.ResetChargesTask;
|
||||
@@ -358,6 +357,7 @@ import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCoun
|
||||
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
|
||||
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PlayerAutoSaveTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectors;
|
||||
@@ -813,8 +813,6 @@ public class PlayerInstance extends Playable
|
||||
|
||||
private volatile long _lastItemAuctionInfoRequest = 0;
|
||||
|
||||
private Future<?> _pvpRegTask;
|
||||
|
||||
private long _pvpFlagLasts;
|
||||
|
||||
private long _notMoveUntil = 0;
|
||||
@@ -841,26 +839,18 @@ public class PlayerInstance extends Playable
|
||||
public void startPvPFlag()
|
||||
{
|
||||
updatePvPFlag(1);
|
||||
if (_pvpRegTask == null)
|
||||
{
|
||||
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
public void stopPvpRegTask()
|
||||
{
|
||||
if (_pvpRegTask != null)
|
||||
{
|
||||
_pvpRegTask.cancel(true);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
PvpFlagTaskManager.getInstance().remove(this);
|
||||
}
|
||||
|
||||
public void stopPvPFlag()
|
||||
{
|
||||
stopPvpRegTask();
|
||||
updatePvPFlag(0);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
@@ -13969,11 +13959,6 @@ public class PlayerInstance extends Playable
|
||||
_fallingDamageTask.cancel(false);
|
||||
_fallingDamageTask = null;
|
||||
}
|
||||
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
|
||||
{
|
||||
_pvpRegTask.cancel(false);
|
||||
_pvpRegTask = null;
|
||||
}
|
||||
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
|
||||
{
|
||||
_timedHuntingZoneFinishTask.cancel(false);
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.tasks.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* Task dedicated to update player's current pvp status.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PvPFlagTask implements Runnable
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
|
||||
public PvPFlagTask(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > _player.getPvpFlagLasts())
|
||||
{
|
||||
_player.stopPvPFlag();
|
||||
}
|
||||
else if (System.currentTimeMillis() > (_player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
_player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.taskmanager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PvpFlagTaskManager
|
||||
{
|
||||
private static final Set<PlayerInstance> PLAYERS = ConcurrentHashMap.newKeySet();
|
||||
private static boolean _working = false;
|
||||
|
||||
public PvpFlagTaskManager()
|
||||
{
|
||||
ThreadPool.scheduleAtFixedRate(() ->
|
||||
{
|
||||
if (_working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_working = true;
|
||||
|
||||
if (!PLAYERS.isEmpty())
|
||||
{
|
||||
final long time = System.currentTimeMillis();
|
||||
for (PlayerInstance player : PLAYERS)
|
||||
{
|
||||
if (time > player.getPvpFlagLasts())
|
||||
{
|
||||
player.stopPvPFlag();
|
||||
}
|
||||
else if (time > (player.getPvpFlagLasts() - 20000))
|
||||
{
|
||||
player.updatePvPFlag(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.updatePvPFlag(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_working = false;
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
public void add(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.add(player);
|
||||
}
|
||||
|
||||
public void remove(PlayerInstance player)
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
}
|
||||
|
||||
public static PvpFlagTaskManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PvpFlagTaskManager INSTANCE = new PvpFlagTaskManager();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user