Commands overhaul + Selective loot + Antimulticlient Coordinator
Completely overhauled commands layout, each command splitted in Java classes. Optimized "ranks" command, no more calling the DB to get ranking info. Implemented a mechanic where mobs only spawns loots that are visible/collectable by the player's party. Implemented a server flag which sets whether explorers, cygnus and legends are allowed to share the cash shop inventory or not. Implemented support for dynamic server rates at bootup. Rates can now be assigned at the configuration.ini file. Devised the anti-multiclient login coordinator feature. Besides multiclient attempts by the same machine, it also prevents unauthorized login attempts into an account. Fixed PQ instances being forcefully closed even when party leader reassignment upon logout is available. Fixed mob statis not concurrently protected.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 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 server.loot;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MapleInventoryType;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MapleLootInventory {
|
||||
Map<Integer, Integer> items = new HashMap<>(50);
|
||||
|
||||
public MapleLootInventory(MapleCharacter from) {
|
||||
for (MapleInventoryType values : MapleInventoryType.values()) {
|
||||
|
||||
for(Item it : from.getInventory(values).list()) {
|
||||
Integer itemQty = items.get(it.getItemId());
|
||||
|
||||
if(itemQty == null) {
|
||||
items.put(it.getItemId(), (int) it.getQuantity());
|
||||
} else {
|
||||
items.put(it.getItemId(), itemQty + it.getQuantity());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasItem(int itemid, int quantity) {
|
||||
Integer itemQty = items.get(itemid);
|
||||
return itemQty != null && itemQty >= quantity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 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 server.loot;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.life.MapleMonsterInformationProvider;
|
||||
import server.life.MonsterDropEntry;
|
||||
import server.quest.MapleQuest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MapleLootManager {
|
||||
|
||||
private static boolean needQuestItem(MonsterDropEntry dropEntry, MapleQuest quest, MapleCharacter chr, MapleLootInventory chrInv) {
|
||||
if (chr.getQuestStatus(dropEntry.questid) != 1) return false;
|
||||
return !chrInv.hasItem(dropEntry.itemId, quest.getItemAmountNeeded(dropEntry.itemId));
|
||||
}
|
||||
|
||||
private static boolean isRelevantDrop(MonsterDropEntry dropEntry, List<MapleCharacter> partyMembers, List<MapleLootInventory> partyInv) {
|
||||
MapleQuest quest = MapleQuest.getInstance(dropEntry.questid);
|
||||
boolean restricted = MapleItemInformationProvider.getInstance().isDropRestricted(dropEntry.itemId);
|
||||
|
||||
for (int i = 0; i < partyMembers.size(); i++) {
|
||||
MapleLootInventory chrInv = partyInv.get(i);
|
||||
|
||||
if(restricted && chrInv.hasItem(dropEntry.itemId, 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(dropEntry.questid <= 0 || needQuestItem(dropEntry, quest, partyMembers.get(i), chrInv)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<MonsterDropEntry> retrieveRelevantDrops(int monsterId, List<MapleCharacter> partyMembers) {
|
||||
List<MonsterDropEntry> loots = MapleMonsterInformationProvider.getInstance().retrieveEffectiveDrop(monsterId);
|
||||
if(loots.isEmpty()) return loots;
|
||||
|
||||
List<MapleLootInventory> partyInv = new LinkedList<>();
|
||||
for(MapleCharacter chr : partyMembers) {
|
||||
MapleLootInventory lootInv = new MapleLootInventory(chr);
|
||||
partyInv.add(lootInv);
|
||||
}
|
||||
|
||||
List<MonsterDropEntry> effectiveLoot = new LinkedList<>();
|
||||
for(MonsterDropEntry mde : loots) {
|
||||
if(isRelevantDrop(mde, partyMembers, partyInv)) {
|
||||
effectiveLoot.add(mde);
|
||||
}
|
||||
}
|
||||
|
||||
return effectiveLoot;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user