Files
sweetgum-server/src/server/MapleMarriage.java
T
ronancpl 83266508af CPQ tidyup patch + Guild Creation matcher + Solution to Login Accid=0
Adjusted AP gains, to get it to work following the AP Reset check method.
Fixed usage of inexistent itemids on CPQ and fishing.
Fixed one-of-a-kind items being lost in player trades due to missing inventory checks.
Implemented matching system for the guild creation phase. All players intending to join the new guild must be on the Guild Headquartes and accept the creation of the guild.
Fixed changing jobs not properly updating info on the party tab.
Fixed double tooltip information on CPQ actions UI.
Fixed CPQ not disbanding after a player leaves the party/instance.
Fixed checks for "in-progress" CPQ instances.
Fixed changing maps on CPQ not leading players back to the starting battlefield.
Reviewed login system, now preventing non-local IP connecting on local server and local IP on non-local server.
Reviewed login system, now cherrypicking sessions in transition state when trying to disconnect them due to a failed login (avoiding possible mishaps due to duplicate sessions of a same account).
Adjusted PiratePQ stage 2, now mobs respawn rather than making party leader request for new waves.
Adjusted Prime Minister, its spawn is no longer related to starting the quest. It should also allow party fights.
Fixed "forcevac" command not properly applying, rather sending to inventory, "consume-on-pickup" items.
Fixed (probably) accId = 0 issue on login, that was occurring due to client accountid's being set to 0 a while before being checked once again on finishLogin().
Fixed an issue with extended time on CPQ not properly showing the end-match's visual effect.
2019-03-26 16:28:41 -03:00

189 lines
6.0 KiB
Java

/*
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;
import client.MapleClient;
import client.MapleCharacter;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import scripting.event.EventInstanceManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import scripting.event.EventManager;
import tools.DatabaseConnection;
import tools.Pair;
/**
*
* @author Ronan
*/
public class MapleMarriage extends EventInstanceManager {
public MapleMarriage(EventManager em, String name) {
super(em, name);
}
public boolean giftItemToSpouse(int cid) {
return this.getIntProperty("wishlistSelection") == 0;
}
public List<String> getWishlistItems(boolean groom) {
String strItems = this.getProperty(groom ? "groomWishlist" : "brideWishlist");
if (strItems != null) {
return Arrays.asList(strItems.split("\r\n"));
}
return new LinkedList<>();
}
public void initializeGiftItems() {
List<Item> groomGifts = new ArrayList<>();
this.setObjectProperty("groomGiftlist", groomGifts);
List<Item> brideGifts = new ArrayList<>();
this.setObjectProperty("brideGiftlist", brideGifts);
}
public List<Item> getGiftItems(MapleClient c, boolean groom) {
if (c.tryacquireClient()) {
try {
List<Item> gifts = getGiftItemsList(groom);
synchronized (gifts) {
return new LinkedList<>(gifts);
}
} finally {
c.releaseClient();
}
}
return new LinkedList<>();
}
private List<Item> getGiftItemsList(boolean groom) {
return (List<Item>) this.getObjectProperty(groom ? "groomGiftlist" : "brideGiftlist");
}
public Item getGiftItem(MapleClient c, boolean groom, int idx) {
try {
return getGiftItems(c, groom).get(idx);
} catch (IndexOutOfBoundsException e) {
return null;
}
}
public void addGiftItem(boolean groom, Item item) {
List<Item> gifts = getGiftItemsList(groom);
synchronized (gifts) {
gifts.add(item);
}
}
public void removeGiftItem(boolean groom, Item item) {
List<Item> gifts = getGiftItemsList(groom);
synchronized (gifts) {
gifts.remove(item);
}
}
public Boolean isMarriageGroom(MapleCharacter chr) {
Boolean groom = null;
try {
int groomid = this.getIntProperty("groomId"), brideid = this.getIntProperty("brideId");
if (chr.getId() == groomid) {
groom = true;
} else if (chr.getId() == brideid) {
groom = false;
}
} catch (NumberFormatException nfe) {}
return groom;
}
public static boolean claimGiftItems(MapleClient c, MapleCharacter chr) {
List<Item> gifts = loadGiftItemsFromDb(c, chr.getId());
if (MapleInventory.checkSpot(chr, gifts)) {
try {
Connection con = DatabaseConnection.getConnection();
ItemFactory.MARRIAGE_GIFTS.saveItems(new LinkedList<Pair<Item, MapleInventoryType>>(), chr.getId(), con);
con.close();
} catch (SQLException sqle) {}
for (Item item : gifts) {
MapleInventoryManipulator.addFromDrop(chr.getClient(), item, false);
}
return true;
}
return false;
}
public static List<Item> loadGiftItemsFromDb(MapleClient c, int cid) {
List<Item> items = new LinkedList<>();
if (c.tryacquireClient()) {
try {
try {
for (Pair<Item, MapleInventoryType> it : ItemFactory.MARRIAGE_GIFTS.loadItems(cid, false)) {
items.add(it.getLeft());
}
} catch (SQLException sqle) {
sqle.printStackTrace();
}
} finally {
c.releaseClient();
}
}
return items;
}
public void saveGiftItemsToDb(MapleClient c, boolean groom, int cid) {
MapleMarriage.saveGiftItemsToDb(c, getGiftItems(c, groom), cid);
}
public static void saveGiftItemsToDb(MapleClient c, List<Item> giftItems, int cid) {
List<Pair<Item, MapleInventoryType>> items = new LinkedList<>();
for (Item it : giftItems) {
items.add(new Pair<>(it, it.getInventoryType()));
}
if (c.tryacquireClient()) {
try {
try {
Connection con = DatabaseConnection.getConnection();
ItemFactory.MARRIAGE_GIFTS.saveItems(items, cid, con);
con.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
} finally {
c.releaseClient();
}
}
}
}