Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Go to gameserver/model/actor/instance/L2PcInstance.java:
- ### Eclipse Workspace Patch 1.0
- #P L2jFrozen_GameServer
- Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (revision 974)
- +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -24,6 +24,7 @@
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- +import java.sql.Statement;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- @@ -47,6 +48,7 @@
- import org.apache.commons.lang.RandomStringUtils;
- import com.l2jfrozen.Config;
- +import com.l2jfrozen.AchievementEngine.AchievementsManager;
- import com.l2jfrozen.crypt.nProtect;
- import com.l2jfrozen.gameserver.ai.CtrlIntention;
- import com.l2jfrozen.gameserver.ai.L2CharacterAI;
- @@ -1042,6 +1044,106 @@
- /** The _summon request. */
- private SummonRequest _summonRequest = new SummonRequest();
- + private List<Integer> _completedAchievements = new FastList<Integer>();
- +
- + public boolean readyAchievementsList()
- + {
- + if (_completedAchievements.isEmpty())
- + return false;
- + return true;
- + }
- +
- + public void saveAchievemntData()
- + {
- +
- + }
- +
- + public void getAchievemntData()
- + {
- + Connection con = null;
- + try
- + {
- + PreparedStatement statement;
- + PreparedStatement insertStatement;
- + ResultSet rs;
- + con = L2DatabaseFactory.getInstance().getConnection();
- +
- + statement = con.prepareStatement("SELECT * from achievements WHERE owner_id=" + getObjectId());
- +
- + rs = statement.executeQuery();
- +
- + String values = "owner_id";
- + String in = Integer.toString(getObjectId());
- + String questionMarks = in;
- + int ilosc = AchievementsManager.getInstance().getAchievementList().size();
- +
- + if (rs.next())
- + {
- + _completedAchievements.clear();
- + for (int i=1; i <=ilosc; i++)
- + {
- + int a = rs.getInt("a" + i);
- +
- + if (!_completedAchievements.contains(i))
- + if (a == 1)
- + _completedAchievements.add(i);
- + }
- + }
- + else
- + {
- + //Player hasnt entry in database, means we have to create it.
- +
- + for (int i=1; i <=ilosc; i++)
- + {
- + values += ", a" + i;
- + questionMarks += ", 0";
- + }
- +
- + String s = "INSERT INTO achievements(" + values + ") VALUES (" + questionMarks + ")";
- + insertStatement = con.prepareStatement(s);
- +
- + insertStatement.execute();
- + insertStatement.close();
- + }
- + }
- + catch (SQLException e)
- + {
- + _log.warning("[ACHIEVEMENTS ENGINE GETDATA]" + e);
- + }
- + finally
- + {
- + L2DatabaseFactory.close(con);
- + }
- + }
- +
- + public void saveAchievementData(int achievementID)
- + {
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + Statement statement = con.createStatement();
- + statement.executeUpdate("UPDATE achievements SET a" + achievementID + "=1 WHERE owner_id=" + getObjectId());
- + statement.close();
- +
- + if (!_completedAchievements.contains(achievementID))
- + _completedAchievements.add(achievementID);
- + }
- + catch (SQLException e)
- + {
- + _log.warning("[ACHIEVEMENTS SAVE GETDATA]" + e);
- + }
- + finally
- + {
- + L2DatabaseFactory.close(con);
- + }
- + }
- +
- + public List<Integer> getCompletedAchievements()
- + {
- + return _completedAchievements;
- + }
- +
- /**
- * The Class SummonRequest.
- */
- @@ -5114,6 +5216,135 @@
- }
- }
- }
- +
- + /*
- + * Conversion to long (Only For Achievement Manager)
- + * Author: Tortex
- + *
- + */
- + public void addItem(String process, int itemId, long countL, L2Object reference, boolean sendMessage)
- + {
- + int count = 0;
- + count = (int)countL;
- + if(count!=countL)
- + {
- + count = 1;
- + }
- +
- + if(count > 0)
- + {
- + // Sends message to client if requested
- + if(sendMessage && (!isCastingNow()
- + && ItemTable.getInstance().createDummyItem(itemId).getItemType() == L2EtcItemType.HERB
- + || ItemTable.getInstance().createDummyItem(itemId).getItemType() != L2EtcItemType.HERB))
- + {
- + if(count > 1)
- + {
- + if(process.equalsIgnoreCase("sweep") || process.equalsIgnoreCase("Quest"))
- + {
- + SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + sm.addItemName(itemId);
- + sm.addNumber(count);
- + sendPacket(sm);
- + sm = null;
- + }
- + else
- + {
- + SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
- + sm.addItemName(itemId);
- + sm.addNumber(count);
- + sendPacket(sm);
- + sm = null;
- + }
- + }
- + else
- + {
- + if(process.equalsIgnoreCase("sweep") || process.equalsIgnoreCase("Quest"))
- + {
- + SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
- + sm.addItemName(itemId);
- + sendPacket(sm);
- + sm = null;
- + }
- + else
- + {
- + SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1);
- + sm.addItemName(itemId);
- + sendPacket(sm);
- + sm = null;
- + }
- + }
- + }
- + //Auto use herbs - autoloot
- + if(ItemTable.getInstance().createDummyItem(itemId).getItemType() == L2EtcItemType.HERB) //If item is herb dont add it to iv :]
- + {
- + if(!isCastingNow() && !isCastingPotionNow())
- + {
- + L2ItemInstance herb = new L2ItemInstance(_charId, itemId);
- + IItemHandler handler = ItemHandler.getInstance().getItemHandler(herb.getItemId());
- +
- + if(handler == null)
- + {
- + _log.warning("No item handler registered for Herb - item ID " + herb.getItemId() + ".");
- + }
- + else
- + {
- + handler.useItem(this, herb);
- +
- + if(_herbstask >= 100)
- + {
- + _herbstask -= 100;
- + }
- +
- + handler = null;
- + }
- +
- + herb = null;
- + }
- + else
- + {
- + _herbstask += 100;
- + ThreadPoolManager.getInstance().scheduleAi(new HerbTask(process, itemId, count, reference, sendMessage), _herbstask);
- + }
- + }
- + else
- + {
- + // Add the item to inventory
- + L2ItemInstance item = _inventory.addItem(process, itemId, count, this, reference);
- +
- + // Send inventory update packet
- + if(!Config.FORCE_INVENTORY_UPDATE)
- + {
- + InventoryUpdate playerIU = new InventoryUpdate();
- + playerIU.addItem(item);
- + sendPacket(playerIU);
- + playerIU = null;
- + }
- + else
- + {
- + sendPacket(new ItemList(this, false));
- + }
- +
- + // Update current load as well
- + StatusUpdate su = new StatusUpdate(getObjectId());
- + su.addAttribute(StatusUpdate.CUR_LOAD, getCurrentLoad());
- + sendPacket(su);
- + su = null;
- +
- + // If over capacity, drop the item
- + if(!isGM() && !_inventory.validateCapacity(item))
- + {
- + dropItem("InvDrop", item, null, true, true);
- + }
- + else if(CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
- + {
- + CursedWeaponsManager.getInstance().activate(this, item);
- + }
- +
- + item = null;
- + }
- + }
- + }
- /**
- * Destroy item from inventory and send a Server->Client InventoryUpdate packet to the L2PcInstance.
- Create a new package com/l2jfrozen/AchievementEngine and add all these classes:
- ### Eclipse Workspace Patch 1.0
- #P L2jFrozen_GameServer
- Index: head-src/com/l2jfrozen/AchievementEngine/ClanCondition.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/ClanCondition.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/ClanCondition.java (revision 0)
- @@ -0,0 +1,46 @@
- +/*
- + * 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 com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.AchievementEngine.Condition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public abstract class ClanCondition extends Condition
- +{
- + private ClanConditionType _type;
- +
- + public ClanCondition(Object value, ClanConditionType type)
- + {
- + super(value);
- + _type = type;
- + }
- +
- + public ClanConditionType getType()
- + {
- + return _type;
- + }
- +
- + public enum ClanConditionType
- + {
- + MUST_BE_CLAN_LEADER,
- + MIN_CLAN_LEVEL,
- + MIN_CLAN_MEMBERS_COUNT,
- + CRP_AMMOUNT,
- + IS_CASTLE_LORD,
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/WeaponEnchant.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/WeaponEnchant.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/WeaponEnchant.java (revision 0)
- @@ -0,0 +1,40 @@
- +package com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.Condition;
- +import com.l2jfrozen.gameserver.model.Inventory;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public class WeaponEnchant extends Condition
- +{
- + public WeaponEnchant(Object value)
- + {
- + super(value);
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + L2ItemInstance weapon = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
- +
- + if (weapon != null)
- + {
- + if (weapon.getEnchantLevel() >= val)
- + {
- + return true;
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/Condition.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/Condition.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/Condition.java (revision 0)
- @@ -0,0 +1,38 @@
- +/*
- + * 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 com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public abstract class Condition
- +{
- + private Object _value;
- +
- + public Condition(Object value)
- + {
- + _value = value;
- + }
- +
- + public abstract boolean meetConditionRequirements(L2PcInstance player);
- +
- + public Object getValue()
- + {
- + return _value;
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/ItemsCount.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/ItemsCount.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/ItemsCount.java (revision 0)
- @@ -0,0 +1,64 @@
- +/*
- + * 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 com.l2jfrozen.AchievementEngine;
- +
- +import java.util.StringTokenizer;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.Condition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + * <br><br>
- + * Condition: ItemsCount
- + * Check if player has proper ammount of item in inventory.
- + */
- +public class ItemsCount extends Condition
- +{
- + public ItemsCount(Object value)
- + {
- + super(value);
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + String s = getValue().toString();
- + StringTokenizer st = new StringTokenizer(s, ",");
- + int id = 0;
- + long ammount = 0;
- +
- + try
- + {
- + id = Integer.parseInt(st.nextToken());
- + ammount = Integer.parseInt(st.nextToken());
- +
- + if (player.getInventory().getItemByItemId(id).getCount() >= ammount)
- + {
- + return true;
- + }
- + }
- + catch (NumberFormatException nfe)
- + {
- + nfe.printStackTrace();
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/StatsCondition.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/StatsCondition.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/StatsCondition.java (revision 0)
- @@ -0,0 +1,34 @@
- +package com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.AchievementEngine.Condition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public abstract class StatsCondition extends Condition
- +{
- + private StatsConditionType _type;
- +
- + public StatsCondition(Object value, StatsConditionType type)
- + {
- + super(value);
- + _type = type;
- + }
- +
- + public StatsConditionType getType()
- + {
- + return _type;
- + }
- +
- + public enum StatsConditionType
- + {
- + MIN_PVP_COUNT,
- + MIN_PK_COUNT,
- + MAX_HP,
- + MAX_MP,
- + MAX_CP,
- + MIN_KARMA,
- + MIN_RANK,
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/StatusCondition.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/StatusCondition.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/StatusCondition.java (revision 0)
- @@ -0,0 +1,49 @@
- +/*
- + * 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 com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.AchievementEngine.Condition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public abstract class StatusCondition extends Condition
- +{
- + private StatusConditionType _type;
- +
- + public StatusCondition(Object value, StatusConditionType type)
- + {
- + super(value);
- + _type = type;
- + }
- +
- + public StatusConditionType getType()
- + {
- + return _type;
- + }
- +
- + public enum StatusConditionType
- + {
- + MUST_BE_NOBLE,
- + MUST_BE_HERO,
- + MUST_BE_MARRIED,
- + MUST_BE_ACADEMY_MEMBER,
- + MUST_BE_MAGE,
- + MUST_BE_SUMMONER,
- + HAS_COMMON_CRAFT,
- + HAS_DWARVEN_CRAFT,
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/AchievementsManager.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/AchievementsManager.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/AchievementsManager.java (revision 0)
- @@ -0,0 +1,243 @@
- +package com.l2jfrozen.AchievementEngine;
- +
- +import java.io.File;
- +
- +import java.sql.Connection;
- +import java.sql.SQLException;
- +import java.sql.Statement;
- +import java.util.Map;
- +import java.util.logging.Logger;
- +
- +import javax.xml.parsers.DocumentBuilderFactory;
- +
- +import javolution.util.FastList;
- +import javolution.util.FastMap;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +
- +
- +import com.l2jfrozen.Config;
- +import com.l2jfrozen.util.database.L2DatabaseFactory;
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.Achievement;
- +import com.l2jfrozen.AchievementEngine.Condition;
- +import com.l2jfrozen.AchievementEngine.ClanCondition.ClanConditionType;
- +import com.l2jfrozen.AchievementEngine.StatsCondition.StatsConditionType;
- +import com.l2jfrozen.AchievementEngine.StatusCondition.StatusConditionType;
- +import com.l2jfrozen.AchievementEngine.Adena;
- +import com.l2jfrozen.AchievementEngine.Clan;
- +import com.l2jfrozen.AchievementEngine.ItemsCount;
- +import com.l2jfrozen.AchievementEngine.Level;
- +import com.l2jfrozen.AchievementEngine.Stats;
- +import com.l2jfrozen.AchievementEngine.Status;
- +import com.l2jfrozen.AchievementEngine.WeaponEnchant;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public class AchievementsManager
- +{
- + private Map<Integer, Achievement> _achievementList = new FastMap<Integer, Achievement>();
- +
- +
- + private static Logger _log = Logger.getLogger(AchievementsManager.class.getName());
- +
- + public AchievementsManager()
- + {
- + loadAchievements();
- + }
- +
- + private void loadAchievements()
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- +
- + File file = new File(Config.DATAPACK_ROOT + "/config/absolute/achievements.xml");
- +
- + if (!file.exists())
- + {
- + _log.warning("[AchievementsEngine] Error: achievements xml file does not exist, check directory!");
- + }
- + try
- + {
- + Document doc = factory.newDocumentBuilder().parse(file);
- +
- + for (Node list = doc.getFirstChild(); list != null; list = list.getNextSibling())
- + {
- + if("list".equalsIgnoreCase(list.getNodeName()))
- + {
- + for (Node achievement = list.getFirstChild(); achievement != null; achievement = achievement.getNextSibling())
- + {
- + if("achievement".equalsIgnoreCase(achievement.getNodeName()))
- + {
- + int id = checkInt(achievement, "id");
- +
- + String name = String.valueOf(achievement.getAttributes().getNamedItem("name").getNodeValue());
- + String description = String.valueOf(achievement.getAttributes().getNamedItem("description").getNodeValue());
- + String reward = String.valueOf(achievement.getAttributes().getNamedItem("reward").getNodeValue());
- + boolean repeat = checkBoolean(achievement, "repeatable");
- +
- + FastList<Condition> conditions = conditionList(achievement.getAttributes());
- +
- + _achievementList.put(id, new Achievement(id, name, description, reward, repeat, conditions));
- + alterTable(id);
- + }
- + }
- + }
- + }
- +
- + _log.info("[AchievementsEngine] Successfully loaded: " + getAchievementList().size() + " achievements from xml!");
- + }
- + catch (Exception e)
- + {
- + _log.warning("[AchievementsEngine] Error: " + e);
- + e.printStackTrace();
- + }
- + }
- +
- + public void rewardForAchievement(int achievementID, L2PcInstance player)
- + {
- + Achievement achievement = _achievementList.get(achievementID);
- +
- + for (int id: achievement.getRewardList().keySet())
- + player.addItem(achievement.getName(), id, achievement.getRewardList().get(id), player, true);
- + }
- +
- + private boolean checkBoolean(Node d, String nodename)
- + {
- + boolean b = false;
- +
- + try
- + {
- + b = Boolean.valueOf(d.getAttributes().getNamedItem(nodename).getNodeValue());
- + }
- + catch (Exception e)
- + {
- +
- + }
- + return b;
- + }
- +
- + private int checkInt(Node d, String nodename)
- + {
- + int i = 0;
- +
- + try
- + {
- + i = Integer.valueOf(d.getAttributes().getNamedItem(nodename).getNodeValue());
- + }
- + catch (Exception e)
- + {
- +
- + }
- + return i;
- + }
- +
- + /**
- + * Alter table, catch exception if already exist.
- + * @param fieldID
- + */
- + private void alterTable(int fieldID)
- + {
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + Statement statement = con.createStatement();
- + statement.executeUpdate("ALTER TABLE achievements ADD a" + fieldID + " INT DEFAULT 0");
- + statement.close();
- + }
- + catch (SQLException e)
- + {
- +
- + }
- + finally
- + {
- + L2DatabaseFactory.close(con);
- + }
- + }
- +
- + public FastList<Condition> conditionList(NamedNodeMap attributesList)
- + {
- + FastList<Condition> conditions = new FastList<Condition>();
- +
- + for (int j = 0; j < attributesList.getLength(); j++)
- + {
- + addToConditionList(attributesList.item(j).getNodeName(), attributesList.item(j).getNodeValue(), conditions);
- + }
- +
- + return conditions;
- + }
- +
- + public Map<Integer, Achievement> getAchievementList()
- + {
- + return _achievementList;
- + }
- +
- + public static AchievementsManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final AchievementsManager _instance = new AchievementsManager();
- + }
- +
- + private void addToConditionList(String nodeName, Object value, FastList<Condition> conditions)
- + {
- + if (nodeName.equals("minLevel"))
- + conditions.add(new Level(value));
- + else if (nodeName.equals("minPvPCount"))
- + conditions.add(new Stats(value, StatsConditionType.MIN_PVP_COUNT));
- + else if (nodeName.equals("minPkCount"))
- + conditions.add(new Stats(value, StatsConditionType.MIN_PK_COUNT));
- + else if (nodeName.equals("minClanLevel"))
- + conditions.add(new Clan(value, ClanConditionType.MIN_CLAN_LEVEL));
- + else if (nodeName.equals("mustBeHero"))
- + conditions.add(new Status(value, StatusConditionType.MUST_BE_HERO));
- + else if (nodeName.equals("mustBeNoble"))
- + conditions.add(new Status(value, StatusConditionType.MUST_BE_NOBLE));
- + else if (nodeName.equals("minWeaponEnchant"))
- + conditions.add(new WeaponEnchant(value));
- + else if (nodeName.equals("minKarmaCount"))
- + conditions.add(new Stats(value, StatsConditionType.MIN_KARMA));
- + else if (nodeName.equals("minRankCount"))
- + conditions.add(new Stats(value, StatsConditionType.MIN_RANK));
- + else if (nodeName.equals("minAdenaCount"))
- + conditions.add(new Adena(value));
- + else if (nodeName.equals("minClanMembersCount"))
- + conditions.add(new Clan(value, ClanConditionType.MIN_CLAN_MEMBERS_COUNT));
- + else if (nodeName.equals("mustBeClanLeader"))
- + conditions.add(new Clan(value, ClanConditionType.MUST_BE_CLAN_LEADER));
- + else if (nodeName.equals("maxHP"))
- + conditions.add(new Stats(value, StatsConditionType.MAX_HP));
- + else if (nodeName.equals("maxMP"))
- + conditions.add(new Stats(value, StatsConditionType.MAX_MP));
- + else if (nodeName.equals("maxCP"))
- + conditions.add(new Stats(value, StatsConditionType.MAX_CP));
- + else if (nodeName.equals("mustBeMarried"))
- + conditions.add(new Status(value, StatusConditionType.MUST_BE_MARRIED));
- + else if (nodeName.equals("itemAmmount"))
- + conditions.add(new ItemsCount(value));
- + else if (nodeName.equals("crpAmmount"))
- + conditions.add(new Clan(value, ClanConditionType.CRP_AMMOUNT));
- + else if (nodeName.equals("lordOfCastle"))
- + conditions.add(new Clan(value, ClanConditionType.IS_CASTLE_LORD));
- + else if (nodeName.equals("mustBeAcademyMember"))
- + conditions.add(new Status(value, StatusConditionType.MUST_BE_ACADEMY_MEMBER));
- + else if (nodeName.equals("mustBeMageClass"))
- + conditions.add(new Status(value, StatusConditionType.MUST_BE_MAGE));
- + else if (nodeName.equals("mustBeSummoner"))
- + conditions.add(new Status(value, StatusConditionType.MUST_BE_SUMMONER));
- + else if (nodeName.equals("hasCommonCraft"))
- + conditions.add(new Status(value, StatusConditionType.HAS_COMMON_CRAFT));
- + else if (nodeName.equals("hasDwarvenCraft"))
- + conditions.add(new Status(value, StatusConditionType.HAS_DWARVEN_CRAFT));
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/Achievement.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/Achievement.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/Achievement.java (revision 0)
- @@ -0,0 +1,110 @@
- +package com.l2jfrozen.AchievementEngine;
- +
- +import java.util.logging.Logger;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +
- +import javolution.util.FastList;
- +import javolution.util.FastMap;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public class Achievement
- +{
- + private int _id;
- + private String _name;
- + private String _reward;
- + private String _description = "No Description!";
- + private boolean _repeatable;
- +
- + private FastMap<Integer, Long> _rewardList;
- + private FastList<Condition> _conditions;
- +
- + private static Logger _log = Logger.getLogger(Achievement.class.getName());
- +
- + public Achievement(int id, String name, String description, String reward, boolean repeatable, FastList<Condition> conditions)
- + {
- + _rewardList = new FastMap<Integer, Long>();
- + _id = id;
- + _name = name;
- + _description = description;
- + _reward = reward;
- + _conditions = conditions;
- + _repeatable = repeatable;
- +
- + createRewardList();
- + }
- +
- + private void createRewardList()
- + {
- + for (String s : _reward.split(";"))
- + {
- + if (s == null || s.isEmpty())
- + continue;
- +
- + String[] split = s.split(",");
- + Integer item = 0;
- + Long count = new Long(0);
- + try
- + {
- + item = Integer.valueOf(split[0]);
- + count = Long.valueOf(split[1]);
- + }
- + catch(NumberFormatException nfe)
- + {
- + _log.warning("[AchievementsEngine] Error: Wrong reward " + nfe);
- + }
- + _rewardList.put(item, count);
- + }
- + }
- +
- + public boolean meetAchievementRequirements(L2PcInstance player)
- + {
- + for (Condition c: getConditions())
- + {
- + if (!c.meetConditionRequirements(player))
- + {
- + return false;
- + }
- + }
- + return true;
- + }
- +
- + public int getID()
- + {
- + return _id;
- + }
- +
- + public String getName()
- + {
- + return _name;
- + }
- +
- + public String getDescription()
- + {
- + return _description;
- + }
- +
- + public String getReward()
- + {
- + return _reward;
- + }
- +
- + public boolean isRepeatable()
- + {
- + return _repeatable;
- + }
- +
- + public FastMap<Integer, Long> getRewardList()
- + {
- + return _rewardList;
- + }
- +
- + public FastList<Condition> getConditions()
- + {
- + return _conditions;
- + }
- +}
- +
- Index: head-src/com/l2jfrozen/AchievementEngine/Adena.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/Adena.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/Adena.java (revision 0)
- @@ -0,0 +1,30 @@
- +package com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.Condition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public class Adena extends Condition
- +{
- + public Adena(Object value)
- + {
- + super(value);
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + long val = Integer.parseInt(getValue().toString());
- +
- + if (player.getInventory().getAdena() >= val)
- + return true;
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/Stats.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/Stats.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/Stats.java (revision 0)
- @@ -0,0 +1,89 @@
- +/*
- + * 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 com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.StatsCondition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- +*/
- +public class Stats extends StatsCondition
- +{
- + public Stats(Object value, StatsConditionType type)
- + {
- + super(value, type);
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + switch (getType())
- + {
- + case MAX_HP:
- + if (player.getMaxHp() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case MAX_CP:
- + if (player.getMaxCp() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case MAX_MP:
- + if (player.getMaxMp() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case MIN_PK_COUNT:
- + if (player.getPkKills() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case MIN_PVP_COUNT:
- + if (player.getPvpKills() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case MIN_KARMA:
- + if (player.getKarma() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + }
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/Status.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/Status.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/Status.java (revision 0)
- @@ -0,0 +1,93 @@
- +/*
- + * 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 com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.StatusCondition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public class Status extends StatusCondition
- +{
- + public Status(Object value, StatusConditionType type)
- + {
- + super(value, type);
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + switch (getType())
- + {
- + case MUST_BE_NOBLE:
- + if (player.isNoble())
- + {
- + return true;
- + }
- + break;
- +
- + case MUST_BE_HERO:
- + if (player.isHero())
- + {
- + return true;
- + }
- + break;
- +
- + case MUST_BE_MARRIED:
- + if (player.isMarried())
- + {
- + return true;
- + }
- + break;
- +
- + case MUST_BE_ACADEMY_MEMBER:
- + if (player.isAcademyMember())
- + {
- + return true;
- + }
- + break;
- +
- + case MUST_BE_MAGE:
- + if (player.isMageClass())
- + {
- + return true;
- + }
- + break;
- +
- +
- + case HAS_COMMON_CRAFT:
- + if (player.hasCommonCraft())
- + {
- + return true;
- + }
- + break;
- +
- + case HAS_DWARVEN_CRAFT:
- + if (player.hasCommonCraft())
- + {
- + return true;
- + }
- + break;
- + } //TODO CLASS ID
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/Clan.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/Clan.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/Clan.java (revision 0)
- @@ -0,0 +1,69 @@
- +package com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.ClanCondition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public class Clan extends ClanCondition
- +{
- + public Clan(Object value, ClanConditionType type)
- + {
- + super(value, type);
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + if (player.getClan() != null)
- + {
- + int val = Integer.parseInt(getValue().toString());
- +
- + switch (getType())
- + {
- + case MIN_CLAN_LEVEL:
- + if (player.getClan().getLevel() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case MIN_CLAN_MEMBERS_COUNT:
- + if (player.getClan().getMembersCount() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case MUST_BE_CLAN_LEADER:
- + if (player.isClanLeader())
- + {
- + return true;
- + }
- + break;
- +
- + case CRP_AMMOUNT:
- + if (player.getClan().getReputationScore() >= val)
- + {
- + return true;
- + }
- + break;
- +
- + case IS_CASTLE_LORD:
- + if (player.isCastleLord(val))
- + {
- + return true;
- + }
- + break;
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/AchievementEngine/Level.java
- ===================================================================
- --- head-src/com/l2jfrozen/AchievementEngine/Level.java (revision 0)
- +++ head-src/com/l2jfrozen/AchievementEngine/Level.java (revision 0)
- @@ -0,0 +1,44 @@
- +/*
- + * 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 com.l2jfrozen.AchievementEngine;
- +
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.AchievementEngine.Condition;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +public class Level extends Condition
- +{
- + public Level(Object value)
- + {
- + super(value);
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + if (player.getLevel() >= val)
- + return true;
- + return false;
- + }
- +}
- Create gameserver/model/actor/instance/L2AchievementsInstance.java
- ### Eclipse Workspace Patch 1.0
- #P L2jFrozen_GameServer
- Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2AchievementsInstance.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2AchievementsInstance.java (revision 0)
- +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2AchievementsInstance.java (revision 0)
- @@ -0,0 +1,277 @@
- +package com.l2jfrozen.gameserver.model.actor.instance;
- +
- +import java.util.StringTokenizer;
- +
- +import javolution.text.TextBuilder;
- +
- +import com.l2jfrozen.gameserver.model.L2World;
- +import com.l2jfrozen.gameserver.model.entity.Announcements;
- +import com.l2jfrozen.AchievementEngine.AchievementsManager;
- +import com.l2jfrozen.AchievementEngine.Achievement;
- +import com.l2jfrozen.AchievementEngine.Condition;
- +import com.l2jfrozen.gameserver.model.Inventory;
- +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
- +
- +/**
- + * @author Matim
- + * @version 1.0
- + */
- +@SuppressWarnings("unused")
- +public class L2AchievementsInstance extends L2FolkInstance
- +{
- + public L2AchievementsInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance player, String command)
- + {
- + if (player == null || player.getLastFolkNPC() == null || player.getLastFolkNPC().getObjectId() != this.getObjectId())
- + {
- + return;
- + }
- + if (command.startsWith("showMyAchievements"))
- + {
- + player.getAchievemntData();
- + showMyAchievements(player);
- + }
- + else if (command.startsWith("achievementInfo"))
- + {
- + StringTokenizer st = new StringTokenizer(command, " ");
- + st.nextToken();
- + int id = Integer.parseInt(st.nextToken());
- +
- + showAchievementInfo(id, player);
- + }
- + else if (command.startsWith("topList"))
- + {
- + showTopListWindow(player);
- + }
- + else if (command.startsWith("showMainWindow"))
- + {
- + showChatWindow(player, 0);
- + }
- + else if (command.startsWith("getReward"))
- + {
- + StringTokenizer st = new StringTokenizer(command, " ");
- + st.nextToken();
- + int id = Integer.parseInt(st.nextToken());
- + AchievementsManager.getInstance().rewardForAchievement(id, player);
- + player.saveAchievementData(id);
- + showMyAchievements(player);
- +
- + }
- + else if (command.startsWith ("showMyStats"))
- + {
- + showMyStatsWindow(player);
- + }
- + else if (command.startsWith("showHelpWindow"))
- + {
- + showHelpWindow(player);
- + }
- + }
- +
- + @Override
- + public void showChatWindow(L2PcInstance player, int val)
- + {
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Achievements Manager</title><body><center><br>");
- + tb.append("Hello <font color=\"LEVEL\">" + player.getName() + "</font><br>Are you looking for challenge?");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
- + tb.append("<button value=\"My Achievements\" action=\"bypass -h npc_%objectId%_showMyAchievements\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
- + tb.append("<button value=\"Statistics\" action=\"bypass -h npc_%objectId%_showMyStats\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
- + tb.append("<button value=\"Top List\" action=\"bypass -h npc_%objectId%_topList\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
- + tb.append("<button value=\"Help\" action=\"bypass -h npc_%objectId%_showHelpWindow\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- + msg.setHtml(tb.toString());
- + msg.replace("%objectId%", String.valueOf(this.getObjectId()));
- +
- + player.sendPacket(msg);
- + }
- +
- + private void showMyAchievements(L2PcInstance player)
- + {
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Achievements Manager</title><body><br>");
- +
- + tb.append("<center><font color=\"LEVEL\">My achievements</font>:</center><br>");
- +
- + if (AchievementsManager.getInstance().getAchievementList().isEmpty())
- + {
- + tb.append("There are no Achievements created yet!");
- + }
- + else
- + {
- + int i = 0;
- +
- + tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
- + tb.append("<tr><td width=270 align=\"left\">Name:</td><td width=60 align=\"right\">Info:</td><td width=200 align=\"center\">Status:</td></tr></table>");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
- +
- + for (Achievement a: AchievementsManager.getInstance().getAchievementList().values())
- + {
- + tb.append(getTableColor(i));
- + tb.append("<tr><td width=270 align=\"left\">" + a.getName() + "</td><td width=50 align=\"right\"><a action=\"bypass -h npc_%objectId%_achievementInfo "
- + + a.getID() + "\">info</a></td><td width=200 align=\"center\">" + getStatusString(a.getID(), player) + "</td></tr></table>");
- + i++;
- + }
- +
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<center><button value=\"Back\" action=\"bypass -h npc_%objectId%_showMainWindow\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- + }
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- + msg.setHtml(tb.toString());
- + msg.replace("%objectId%", String.valueOf(this.getObjectId()));
- +
- + player.sendPacket(msg);
- + }
- +
- + private void showAchievementInfo(int achievementID, L2PcInstance player)
- + {
- + Achievement a = AchievementsManager.getInstance().getAchievementList().get(achievementID);
- +
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Achievements Manager</title><body><br>");
- +
- + tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
- + tb.append("<tr><td width=270 align=\"center\">" + a.getName() + "</td></tr></table><br>");
- + tb.append("<center>Status: " + getStatusString(achievementID, player));
- +
- + if (a.meetAchievementRequirements(player) && !player.getCompletedAchievements().contains(achievementID))
- + {
- + tb.append("<button value=\"Receive Reward!\" action=\"bypass -h npc_%objectId%_getReward " + a.getID() + "\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\">");
- + }
- +
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- +
- + tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
- + tb.append("<tr><td width=270 align=\"center\">Description</td></tr></table><br>");
- + tb.append(a.getDescription());
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- +
- + tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
- + tb.append("<tr><td width=270 align=\"left\">Condition:</td><td width=100 align=\"right\">Value:</td><td width=200 align=\"center\">Status:</td></tr></table>");
- + tb.append(getConditionsStatus(achievementID, player));
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<center><button value=\"Back\" action=\"bypass -h npc_%objectId%_showMyAchievements\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- + msg.setHtml(tb.toString());
- + msg.replace("%objectId%", String.valueOf(this.getObjectId()));
- +
- + player.sendPacket(msg);
- + }
- +
- + private void showMyStatsWindow(L2PcInstance player)
- + {
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Achievements Manager</title><body><center><br>");
- + tb.append("Check your <font color=\"LEVEL\">Achievements </font>statistics:");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
- +
- + player.getAchievemntData();
- + int completedCount = player.getCompletedAchievements().size();
- +
- + tb.append("You have completed: " + completedCount + "/<font color=\"LEVEL\">" + AchievementsManager.getInstance().getAchievementList().size() + "</font>");
- +
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<center><button value=\"Back\" action=\"bypass -h npc_%objectId%_showMainWindow\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- + msg.setHtml(tb.toString());
- + msg.replace("%objectId%", String.valueOf(this.getObjectId()));
- +
- + player.sendPacket(msg);
- + }
- +
- + private void showTopListWindow(L2PcInstance player)
- + {
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Achievements Manager</title><body><center><br>");
- + tb.append("Check your <font color=\"LEVEL\">Achievements </font>Top List:");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
- +
- + tb.append("Not implemented yet!");
- +
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<center><button value=\"Back\" action=\"bypass -h npc_%objectId%_showMainWindow\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- + msg.setHtml(tb.toString());
- + msg.replace("%objectId%", String.valueOf(this.getObjectId()));
- +
- + player.sendPacket(msg);
- + }
- +
- + private void showHelpWindow(L2PcInstance player)
- + {
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Achievements Manager</title><body><center><br>");
- + tb.append("Achievements <font color=\"LEVEL\">Help </font>page:");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
- +
- + tb.append("You can check status of your achievements, receive reward if every condition of achievement is meet, if not you can check which condition is still not meet, by using info button");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<font color=\"FF0000\">Not Completed</font> - you did not meet the achivement requirements.<br>");
- + tb.append("<font color=\"LEVEL\">Get Reward</font> - you may receive reward, click info.<br>");
- + tb.append("<font color=\"5EA82E\">Completed</font> - achievement completed, reward received.<br>");
- +
- + tb.append("Achievements Engine by <font color=\"LEVEL\">Matim</font>");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<center><button value=\"Back\" action=\"bypass -h npc_%objectId%_showMainWindow\" width=160 height=32 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center>");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- + msg.setHtml(tb.toString());
- + msg.replace("%objectId%", String.valueOf(this.getObjectId()));
- +
- + player.sendPacket(msg);
- + }
- +
- + private String getStatusString(int achievementID, L2PcInstance player)
- + {
- + if (player.getCompletedAchievements().contains(achievementID))
- + {
- + return "<font color=\"5EA82E\">Completed</font>";
- + }
- + if (AchievementsManager.getInstance().getAchievementList().get(achievementID).meetAchievementRequirements(player))
- + {
- + return "<font color=\"LEVEL\">Get Reward</font>";
- + }
- + return "<font color=\"FF0000\">Not Completed</font>";
- + }
- +
- + private String getTableColor(int i)
- + {
- + if (i % 2 == 0)
- + return "<table width=270 border=0 bgcolor=\"444444\">";
- + return "<table width=270 border=0>";
- + }
- +
- + private String getConditionsStatus(int achievementID, L2PcInstance player)
- + {
- + int i = 0;
- + String s = "</center>";
- + Achievement a = AchievementsManager.getInstance().getAchievementList().get(achievementID);
- + String completed = "<font color=\"5EA82E\">Completed</font></td></tr></table>";
- + String notcompleted = "<font color=\"FF0000\">Not Completed</font></td></tr></table>";
- +
- + for (Condition c: a.getConditions())
- + {
- + s+= getTableColor(i);
- + s+= "<tr><td width=270 align=\"left\">Level</td><td width=50 align=\"right\">" + c.getValue() + "</td><td width=200 align=\"center\">";
- + i++;
- +
- + if (c.meetConditionRequirements(player))
- + s+= completed;
- + else
- + s+= notcompleted;
- + }
- + return s;
- + }
- +}
- \ No newline at end of file
- Create achievements.sql
- ### Eclipse Workspace Patch 1.0
- #P L2jFrozen_DataPack
- Index: sql/achievements.sql
- ===================================================================
- --- sql/achievements.sql (revision 0)
- +++ sql/achievements.sql (revision 0)
- @@ -0,0 +1,4 @@
- +CREATE TABLE IF NOT EXISTS `achievements` (
- + `owner_id` INT,
- + PRIMARY KEY (`owner_id`)
- +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- \ No newline at end of file
- Now make gameserver/config/achievements.xml
- + <list>
- + <achievement id="1" name="Hero" description="Gain Hero!" reward="57,20000" repeatable="false" mustBeHero="true"/>
- + <achievement id="2" name="Nobless" description="Gain Nobless!" reward="57,10000" repeatable="false" mustBeNoble="true"/>
- + </list>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement