MapleCustomQuestData.java
Upload User: gwt600
Upload Date: 2021-06-03
Package Size: 704k
Code Size: 3k
Category:

Games

Development Platform:

Java

  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3.     Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
  4.                        Matthias Butz <matze@odinms.de>
  5.                        Jan Christian Meyer <vimes@odinms.de>
  6.     This program is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU Affero General Public License version 3
  8.     as published by the Free Software Foundation. You may not use, modify
  9.     or distribute this program under any other version of the
  10.     GNU Affero General Public License.
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU Affero General Public License for more details.
  15.     You should have received a copy of the GNU Affero General Public License
  16.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */ package net.sf.odinms.server.quest; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import net.sf.odinms.provider.MapleData; import net.sf.odinms.provider.MapleDataEntity; import net.sf.odinms.provider.wz.MapleDataType; /**  *  * @author Matze  */ public class MapleCustomQuestData implements MapleData, Serializable { private static final long serialVersionUID = -8600005891655365066L; private List<MapleCustomQuestData> children = new LinkedList<MapleCustomQuestData>(); private String name; private Object data; private MapleDataEntity parent; public MapleCustomQuestData(String name, Object data, MapleDataEntity parent) { this.name = name; this.data = data; this.parent = parent; } public void addChild(MapleData child) { children.add((MapleCustomQuestData) child); } public String getName() { return name; } public MapleDataType getType() { return MapleDataType.UNKNOWN_TYPE; } public List<MapleData> getChildren() { MapleData[] ret = new MapleData[children.size()]; ret = children.toArray(ret); return new ArrayList<MapleData>(Arrays.asList(ret)); } public MapleData getChildByPath(String name) { if (name.equals(this.name)) return this; String lookup; String nextName; if (name.indexOf("/") == -1) { lookup = name; nextName = name; } else { lookup = name.substring(0, name.indexOf("/")); nextName = name.substring(name.indexOf("/") + 1); } for (MapleData child : children) { if (child.getName().equals(lookup)) return child.getChildByPath(nextName); } return null; } public Object getData() { return data; } public Iterator<MapleData> iterator() { return getChildren().iterator(); } public MapleDataEntity getParent() { return parent; } }