Merge branch 'master' into various-fixes

This commit is contained in:
P0nk
2022-08-03 07:43:02 +02:00
9 changed files with 86 additions and 33 deletions

View File

@@ -55,9 +55,6 @@ public final class ItemMoveHandler extends AbstractPacketHandler {
InventoryManipulator.move(c, type, src, action);
}
if (c.getPlayer().getMap().getHPDec() > 0) {
c.getPlayer().resetHpDecreaseTask();
}
c.getPlayer().getAutobanManager().spam(6);
}
}

View File

@@ -386,10 +386,6 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
player.commitExcludedItems();
showDueyNotification(c, player);
if (player.getMap().getHPDec() > 0) {
player.resetHpDecreaseTask();
}
player.resetPlayerRates();
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) {
player.setPlayerRates();

View File

@@ -0,0 +1,37 @@
/*
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 2016 - 2019 RonanLana
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.server.task;
import net.server.world.World;
/**
* @author Ronan
*/
public class CharacterHpDecreaseTask extends BaseTask implements Runnable {
@Override
public void run() {
wserv.runPlayerHpDecreaseSchedule();
}
public CharacterHpDecreaseTask(World world) {
super(world);
}
}

View File

@@ -153,6 +153,7 @@ public class World {
private MonitoredReentrantLock timedMapObjectLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.WORLD_MAPOBJS, true);
private final Map<Character, Integer> fishingAttempters = Collections.synchronizedMap(new WeakHashMap<>());
private Map<Character, Integer> playerHpDec = Collections.synchronizedMap(new WeakHashMap<>());
private ScheduledFuture<?> charactersSchedule;
private ScheduledFuture<?> marriagesSchedule;
@@ -160,6 +161,7 @@ public class World {
private ScheduledFuture<?> fishingSchedule;
private ScheduledFuture<?> partySearchSchedule;
private ScheduledFuture<?> timeoutSchedule;
private ScheduledFuture<?> hpDecSchedule;
public World(int world, int flag, String eventmsg, int exprate, int droprate, int bossdroprate, int mesorate, int questrate, int travelrate, int fishingrate) {
this.id = world;
@@ -194,6 +196,7 @@ public class World {
fishingSchedule = tman.register(new FishingTask(this), SECONDS.toMillis(10), SECONDS.toMillis(10));
partySearchSchedule = tman.register(new PartySearchTask(this), SECONDS.toMillis(10), SECONDS.toMillis(10));
timeoutSchedule = tman.register(new TimeoutTask(this), SECONDS.toMillis(10), SECONDS.toMillis(10));
hpDecSchedule = tman.register(new CharacterHpDecreaseTask(this), YamlConfig.config.server.MAP_DAMAGE_OVERTIME_INTERVAL, YamlConfig.config.server.MAP_DAMAGE_OVERTIME_INTERVAL);
if (YamlConfig.config.server.USE_FAMILY_SYSTEM) {
long timeLeft = Server.getTimeLeftForNextDay();
@@ -1715,6 +1718,33 @@ public class World {
r.run();
}
}
public void addPlayerHpDecrease(Character chr) {
playerHpDec.putIfAbsent(chr, 0);
}
public void removePlayerHpDecrease(Character chr) {
playerHpDec.remove(chr);
}
public void runPlayerHpDecreaseSchedule() {
Map<Character, Integer> m = new HashMap<>();
m.putAll(playerHpDec);
for (Entry<Character, Integer> e : m.entrySet()) {
Character chr = e.getKey();
if (!chr.isAwayFromWorld()) {
int c = e.getValue();
c = (c + 1) % YamlConfig.config.server.MAP_DAMAGE_OVERTIME_COUNT;
playerHpDec.replace(chr, c);
if (c == 0) {
chr.doHurtHp();
}
}
}
}
public void resetDisabledServerMessages() {
srvMessagesLock.lock();
@@ -2149,6 +2179,11 @@ public class World {
timeoutSchedule.cancel(false);
timeoutSchedule = null;
}
if(hpDecSchedule != null) {
hpDecSchedule.cancel(false);
hpDecSchedule = null;
}
players.disconnectAll();
players = null;