Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P core
- diff --git java/net/sf/l2j/achievementEngine/Achievement.java
- new file mode 100644
- index 0000000..a37c61e
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Achievement.java
- @@ -0,0 +1,106 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +import java.util.ArrayList;
- +import java.util.HashMap;
- +
- +public class Achievement
- +{
- + private int _id;
- + private String _name;
- + private String _reward;
- + private String _description = "No Description!";
- + private boolean _repeatable;
- +
- + private HashMap<Integer, Long> _rewardList;
- + private ArrayList<Condition> _conditions;
- +
- + private static Logger _log = Logger.getLogger(Achievement.class.getName());
- +
- + public Achievement(int id, String name, String description, String reward, boolean repeatable, ArrayList<Condition> conditions)
- + {
- + _rewardList = new HashMap<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);
- + Long count = Long.valueOf(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 HashMap<Integer, Long> getRewardList()
- + {
- + return _rewardList;
- + }
- +
- + public ArrayList<Condition> getConditions()
- + {
- + return _conditions;
- + }
- +}
- diff --git java/net/sf/l2j/achievementEngine/AchievementsManager.java
- new file mode 100644
- index 0000000..b6ca1d8
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/AchievementsManager.java
- @@ -0,0 +1,272 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import java.io.File;
- +import java.sql.Connection;
- +import java.sql.SQLException;
- +import java.sql.Statement;
- +import java.util.ArrayList;
- +import java.util.HashMap;
- +import java.util.Map;
- +import java.util.logging.Logger;
- +
- +import javax.xml.parsers.DocumentBuilderFactory;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.achievementEngine.EnchantAmor.Chest;
- +import net.sf.l2j.achievementEngine.EnchantAmor.Feet;
- +import net.sf.l2j.achievementEngine.EnchantAmor.Gloves;
- +import net.sf.l2j.achievementEngine.EnchantAmor.Head;
- +import net.sf.l2j.achievementEngine.EnchantAmor.Legs;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class AchievementsManager
- +{
- + private Map<Integer, Achievement> _achievementList = new HashMap<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/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");
- +
- + ArrayList<Condition> conditions = conditionList(achievement.getAttributes());
- +
- + _achievementList.put(id, new Achievement(id, name, description, reward, repeat, conditions));
- + alterTable(id);
- + }
- + }
- + }
- + }
- + _log.info("--------------------------------------------------------------------");
- + _log.info(" ");
- + _log.info("[AchievementsEngine] Successfully loaded: " + getAchievementList().size() + " achievements from xml!");
- + _log.info(" AchievementsEngine ");
- + _log.info(" ");
- + _log.info("--------------------------------------------------------------------");
- + }
- + 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)
- + {
- +
- + }
- + }
- +
- + public ArrayList<Condition> conditionList(NamedNodeMap attributesList)
- + {
- + ArrayList<Condition> conditions = new ArrayList<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, ArrayList<Condition> conditions)
- + {
- + if (nodeName.equals("minLevel"))
- + conditions.add(new Level(value));
- +
- + else if (nodeName.equals("minPvPCount"))
- + conditions.add(new Pvp(value));
- +
- + else if (nodeName.equals("minPkCount"))
- + conditions.add(new Pk(value));
- +
- + else if (nodeName.equals("minClanLevel"))
- + conditions.add(new ClanLevel(value));
- +
- + else if (nodeName.equals("mustBeHero"))
- + conditions.add(new Hero(value));
- +
- + else if (nodeName.equals("mustBeNoble"))
- + conditions.add(new Noble(value));
- +
- + else if (nodeName.equals("mustBeClanLeader"))
- + conditions.add(new ClanLeader(value));
- +
- + else if (nodeName.equals("minWeaponEnchant"))
- + conditions.add(new WeaponEnchant(value));
- +
- + else if (nodeName.equals("minKarmaCount"))
- + conditions.add(new Karma(value));
- +
- + else if (nodeName.equals("minAdenaCount"))
- + conditions.add(new Adena(value));
- +
- + else if (nodeName.equals("minClanMembersCount"))
- + conditions.add(new MinCMcount(value));
- +
- + else if (nodeName.equals("maxHP"))
- + conditions.add(new Maxhp(value));
- +
- + else if (nodeName.equals("maxMP"))
- + conditions.add(new Maxmp(value));
- +
- + else if (nodeName.equals("maxCP"))
- + conditions.add(new Maxcp(value));
- +
- + else if (nodeName.equals("mustBeMarried"))
- + conditions.add(new Marry(value));
- +
- + else if (nodeName.equals("itemAmmount"))
- + conditions.add(new ItemsCount(value));
- +
- + //else if (nodeName.equals("crpAmmount"))
- + //conditions.add(new Crp(value));
- +
- + else if (nodeName.equals("lordOfCastle"))
- + conditions.add(new Castle(value));
- +
- + else if (nodeName.equals("mustBeMageClass"))
- + conditions.add(new Mageclass(value));
- +
- + else if (nodeName.equals("mustBeVip"))
- + conditions.add(new Noble(value));
- +
- + //else if (nodeName.equals("raidToKill"))
- + //conditions.add(new RaidKill(value));
- +
- + else if (nodeName.equals("CompleteAchievements"))
- + conditions.add(new CompleteAchievements(value));
- +
- + else if (nodeName.equals("minSubclassCount"))
- + conditions.add(new Sub(value));
- +
- + else if (nodeName.equals("minSkillEnchant"))
- + conditions.add(new SkillEnchant(value));
- +
- + else if (nodeName.equals("minOnlineTime"))
- + conditions.add(new OnlineTime(value));
- +
- + // else if (nodeName.equals("Cursedweapon"))
- + // conditions.add(new CursedWeapon(value));
- +
- + else if (nodeName.equals("minHeadEnchant"))
- + conditions.add(new Head(value));
- +
- + else if (nodeName.equals("minChestEnchant"))
- + conditions.add(new Chest(value));
- +
- + else if (nodeName.equals("minFeetEnchant"))
- + conditions.add(new Feet(value));
- +
- + else if (nodeName.equals("minLegsEnchant"))
- + conditions.add(new Legs(value));
- +
- + else if (nodeName.equals("minGlovestEnchant"))
- + conditions.add(new Gloves(value));
- +
- +
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Adena.java
- new file mode 100644
- index 0000000..780b473
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Adena.java
- @@ -0,0 +1,26 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Adena extends Condition
- +{
- + public Adena(Object value)
- + {
- + super(value);
- + setName("Adena");
- + }
- +
- + @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
- diff --git java/net/sf/l2j/achievementEngine/Castle.java
- new file mode 100644
- index 0000000..ad77e91
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Castle.java
- @@ -0,0 +1,28 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +
- +public class Castle extends Condition
- +{
- + public Castle(Object value)
- + {
- + super(value);
- + setName("Have Castle");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + if (player.getClan() != null)
- + {
- + if ((player.isCastleLord(5)) || (player.isCastleLord(3)) || (player.isCastleLord(7)))
- + return true;
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/ClanLeader.java
- new file mode 100644
- index 0000000..3f00e9b
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/ClanLeader.java
- @@ -0,0 +1,25 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +
- +public class ClanLeader extends Condition
- +{
- + public ClanLeader(Object value)
- + {
- + super(value);
- + setName("Be Clan Leader");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + return (player.getClan() != null) &&
- + (player.isClanLeader());
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/ClanLevel.java
- new file mode 100644
- index 0000000..0239700
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/ClanLevel.java
- @@ -0,0 +1,28 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class ClanLevel extends Condition
- +{
- + public ClanLevel(Object value)
- + {
- + super(value);
- + setName("Clan Level");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- + if (player.getClan() != null)
- + {
- + int val = Integer.parseInt(getValue().toString());
- +
- + if (player.getClan().getLevel() >= val)
- + return true;
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/CompleteAchievements.java
- new file mode 100644
- index 0000000..8fa7162
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/CompleteAchievements.java
- @@ -0,0 +1,27 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import java.util.List;
- +
- +import net.sf.l2j.achievementEngine.Condition;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class CompleteAchievements extends Condition
- +{
- + public CompleteAchievements(Object value)
- + {
- + super(value);
- + setName("Complete Achievements");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getCompletedAchievements().size() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Condition.java
- new file mode 100644
- index 0000000..5e382f8
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Condition.java
- @@ -0,0 +1,30 @@
- +package net. sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public abstract class Condition
- +{
- + private Object _value;
- + private String _name;
- +
- + public Condition(Object value)
- + {
- + _value = value;
- + }
- +
- + public abstract boolean meetConditionRequirements(L2PcInstance paramL2PcInstance);
- +
- + public Object getValue() {
- + return _value;
- + }
- +
- + public void setName(String s)
- + {
- + _name = s;
- + }
- +
- + public String getName()
- + {
- + return _name;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/EnchantAmor/Chest.java
- new file mode 100644
- index 0000000..2a11444
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/EnchantAmor/Chest.java
- @@ -0,0 +1,37 @@
- +package net.sf.l2j.achievementEngine.EnchantAmor;
- +
- +import net.sf.l2j.achievementEngine.Condition;
- +import net.sf.l2j.gameserver.model.L2ItemInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
- +
- +public class Chest extends Condition
- +{
- + public Chest(Object value)
- + {
- + super(value);
- + setName("Chests");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + L2ItemInstance armor = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
- +
- + if (armor != null)
- + {
- + if (armor.getEnchantLevel() >= val)
- + {
- + return true;
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/EnchantAmor/Feet.java
- new file mode 100644
- index 0000000..bbc1d25
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/EnchantAmor/Feet.java
- @@ -0,0 +1,37 @@
- +package net.sf.l2j.achievementEngine.EnchantAmor;
- +
- +import net.sf.l2j.achievementEngine.Condition;
- +import net.sf.l2j.gameserver.model.L2ItemInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
- +
- +public class Feet extends Condition
- +{
- + public Feet(Object value)
- + {
- + super(value);
- + setName("Boots");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + L2ItemInstance armor = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET);
- +
- + if (armor != null)
- + {
- + if (armor.getEnchantLevel() >= val)
- + {
- + return true;
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/EnchantAmor/Gloves.java
- new file mode 100644
- index 0000000..b797d64
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/EnchantAmor/Gloves.java
- @@ -0,0 +1,37 @@
- +package net.sf.l2j.achievementEngine.EnchantAmor;
- +
- +import net.sf.l2j.achievementEngine.Condition;
- +import net.sf.l2j.gameserver.model.L2ItemInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.itemcontainer.Inventory;;
- +
- +public class Gloves extends Condition
- +{
- + public Gloves(Object value)
- + {
- + super(value);
- + setName("Gloves");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + L2ItemInstance armor = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
- +
- + if (armor != null)
- + {
- + if (armor.getEnchantLevel() >= val)
- + {
- + return true;
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/EnchantAmor/Head.java
- new file mode 100644
- index 0000000..0d0d43c
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/EnchantAmor/Head.java
- @@ -0,0 +1,37 @@
- +package net.sf.l2j.achievementEngine.EnchantAmor;
- +
- +import net.sf.l2j.achievementEngine.Condition;
- +import net.sf.l2j.gameserver.model.L2ItemInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
- +
- +public class Head extends Condition
- +{
- + public Head(Object value)
- + {
- + super(value);
- + setName("Helmets");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + L2ItemInstance armor = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_HEAD);
- +
- + if (armor != null)
- + {
- + if (armor.getEnchantLevel() >= val)
- + {
- + return true;
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/EnchantAmor/Legs.java
- new file mode 100644
- index 0000000..0647c27
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/EnchantAmor/Legs.java
- @@ -0,0 +1,37 @@
- +package net.sf.l2j.achievementEngine.EnchantAmor;
- +
- +import net.sf.l2j.achievementEngine.Condition;
- +import net.sf.l2j.gameserver.model.L2ItemInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
- +
- +public class Legs extends Condition
- +{
- + public Legs(Object value)
- + {
- + super(value);
- + setName("Legs");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + L2ItemInstance armor = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);
- +
- + if (armor != null)
- + {
- + if (armor.getEnchantLevel() >= val)
- + {
- + return true;
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Hero.java
- new file mode 100644
- index 0000000..cac874b
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Hero.java
- @@ -0,0 +1,22 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Hero extends Condition
- +{
- + public Hero(Object value)
- + {
- + super(value);
- + setName("Hero");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- +
- + return player.isHero();
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/ItemsCount.java
- new file mode 100644
- index 0000000..3a6bd5b
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/ItemsCount.java
- @@ -0,0 +1,39 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import java.util.StringTokenizer;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class ItemsCount extends Condition
- +{
- + public ItemsCount(Object value)
- + {
- + super(value);
- + setName("Items Count");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- +
- + String s = getValue().toString();
- + StringTokenizer st = new StringTokenizer(s, ",");
- + int id = 0;
- + int ammount = 0;
- + try
- + {
- + id = Integer.parseInt(st.nextToken());
- + ammount = Integer.parseInt(st.nextToken());
- + if (player.getInventory().getInventoryItemCount(id, 0) >= ammount)
- + return true;
- + }
- + catch (NumberFormatException nfe)
- + {
- + nfe.printStackTrace();
- + }
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Karma.java
- new file mode 100644
- index 0000000..0363e9f
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Karma.java
- @@ -0,0 +1,23 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Karma extends Condition
- +{
- + public Karma(Object value)
- + {
- + super(value);
- + setName("Karma Count");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getKarma() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Level.java
- new file mode 100644
- index 0000000..804e638
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Level.java
- @@ -0,0 +1,26 @@
- +
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Level extends Condition
- +{
- + public Level(Object value)
- + {
- + super(value);
- + setName("Level");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getLevel() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Mageclass.java
- new file mode 100644
- index 0000000..92c79e0
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Mageclass.java
- @@ -0,0 +1,23 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Mageclass extends Condition
- +{
- + public Mageclass(Object value)
- + {
- + super(value);
- + setName("Mage Class");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + return player.isMageClass();
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Marry.java
- new file mode 100644
- index 0000000..b8fbdcd
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Marry.java
- @@ -0,0 +1,22 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Marry extends Condition
- +{
- + public Marry(Object value)
- + {
- + super(value);
- + setName("Married");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- +
- + return player.isMarried();
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Maxcp.java
- new file mode 100644
- index 0000000..c883f61
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Maxcp.java
- @@ -0,0 +1,23 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Maxcp extends Condition
- +{
- + public Maxcp(Object value)
- + {
- + super(value);
- + setName("Max CP");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getMaxCp() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Maxhp.java
- new file mode 100644
- index 0000000..5b264a2
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Maxhp.java
- @@ -0,0 +1,23 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Maxhp extends Condition
- +{
- + public Maxhp(Object value)
- + {
- + super(value);
- + setName("Max HP");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getMaxHp() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Maxmp.java
- new file mode 100644
- index 0000000..dbb6c63
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Maxmp.java
- @@ -0,0 +1,23 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Maxmp extends Condition
- +{
- + public Maxmp(Object value)
- + {
- + super(value);
- + setName("Max MP");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getMaxMp() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/MinCMcount.java
- new file mode 100644
- index 0000000..72a6ac1
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/MinCMcount.java
- @@ -0,0 +1,28 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class MinCMcount extends Condition
- +{
- + public MinCMcount(Object value)
- + {
- + super(value);
- + setName("Clan Members Count");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- + if (player.getClan() != null)
- + {
- + int val = Integer.parseInt(getValue().toString());
- +
- + if (player.getClan().getMembersCount() >= val)
- + return true;
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Noble.java
- new file mode 100644
- index 0000000..0be07a8
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Noble.java
- @@ -0,0 +1,23 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Noble extends Condition
- +{
- + public Noble(Object value)
- + {
- + super(value);
- + setName("Noble");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- +
- + return player.isNoble();
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/OnlineTime.java
- new file mode 100644
- index 0000000..203412c
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/OnlineTime.java
- @@ -0,0 +1,24 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class OnlineTime extends Condition
- +{
- + public OnlineTime(Object value)
- + {
- + super(value);
- + setName("Online Time");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getOnlineTime() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Pk.java
- new file mode 100644
- index 0000000..e9535cb
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Pk.java
- @@ -0,0 +1,24 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Pk extends Condition
- +{
- + public Pk(Object value)
- + {
- + super(value);
- + setName("PK Count");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getPkKills() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Pvp.java
- new file mode 100644
- index 0000000..a901d4a
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Pvp.java
- @@ -0,0 +1,24 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Pvp extends Condition
- +{
- + public Pvp(Object value)
- + {
- + super(value);
- + setName("PvP Count");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getPvpKills() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/SkillEnchant.java
- new file mode 100644
- index 0000000..2888f1b
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/SkillEnchant.java
- @@ -0,0 +1,35 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.L2Skill;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class SkillEnchant extends Condition
- +{
- + public SkillEnchant(Object value)
- + {
- + super(value);
- + setName("Skill Enchant");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null) {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + for (L2Skill s : player.getAllSkills())
- + {
- + String lvl = String.valueOf(s.getLevel());
- + if (lvl.length() <= 2)
- + continue;
- + int sklvl = Integer.parseInt(lvl.substring(1));
- + if (sklvl >= val) {
- + return true;
- + }
- + }
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/Sub.java
- new file mode 100644
- index 0000000..6a0103d
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/Sub.java
- @@ -0,0 +1,24 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Sub extends Condition
- +{
- + public Sub(Object value)
- + {
- + super(value);
- + setName("Subclass Count");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + {
- + return false;
- + }
- + int val = Integer.parseInt(getValue().toString());
- +
- + return player.getSubClasses().size() >= val;
- + }
- +}
- \ No newline at end of file
- diff --git java/net/sf/l2j/achievementEngine/WeaponEnchant.java
- new file mode 100644
- index 0000000..7a9731f
- --- /dev/null
- +++ java/net/sf/l2j/achievementEngine/WeaponEnchant.java
- @@ -0,0 +1,36 @@
- +package net.sf.l2j.achievementEngine;
- +
- +import net.sf.l2j.gameserver.model.L2ItemInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
- +
- +public class WeaponEnchant extends Condition
- +{
- + public WeaponEnchant(Object value)
- + {
- + super(value);
- + setName("Weapon Enchant");
- + }
- +
- + @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
- diff --git java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- index ee0c3ba..7f49bd7 100644
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- @@ -15,12 +15,13 @@
- package net.sf.l2j.gameserver.model.actor.instance;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- +import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Collection;
- import java.util.Comparator;
- import java.util.LinkedHashMap;
- @@ -36,13 +37,15 @@
- import java.util.concurrent.atomic.AtomicInteger;
- import java.util.concurrent.locks.ReentrantLock;
- import java.util.logging.Level;
- import net.sf.l2j.Config;
- import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.achievementEngine.AchievementsManager;
- import net.sf.l2j.gameserver.GameTimeController;
- +import net.sf.l2j.gameserver.Item;
- import net.sf.l2j.gameserver.ItemsAutoDestroy;
- import net.sf.l2j.gameserver.LoginServerThread;
- import net.sf.l2j.gameserver.RecipeController;
- import net.sf.l2j.gameserver.SevenSignsFestival;
- import net.sf.l2j.gameserver.ThreadPoolManager;
- import net.sf.l2j.gameserver.ai.CtrlIntention;
- @@ -672,12 +675,109 @@
- private int _coupleId = 0;
- private boolean _isEngageRequested = false;
- private int _engageId = 0;
- private boolean _isMarryRequested = false;
- private boolean _isMarryAccepted = false;
- + private List<Integer> _completedAchievements = new ArrayList<>();
- +
- + public boolean readyAchievementsList()
- + {
- + if (_completedAchievements.isEmpty())
- + return false;
- + return true;
- + }
- + public long getOnlineTime()
- + {
- + return _onlineTime;
- + }
- + 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 (Exception e)
- + {
- + _log.warning("[ACHIEVEMENTS ENGINE GETDATA]" + e);
- + }
- + }
- +
- + 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);
- + }
- +
- + }
- +
- + public List<Integer> getCompletedAchievements()
- + {
- + return _completedAchievements;
- + }
- // NPC Buffer schemes
- private String _editingSchemeName;
- private final Map<String, List<String>> _schemes = new ConcurrentSkipListMap<>();
- /** Skill casting information (used to queue when several skills are cast in a short time) **/
- public class SkillDat
- @@ -3215,14 +3315,16 @@
- * @param process : String Identifier of process triggering this action
- * @param itemId : int Item Identifier of the item to be added
- * @param count : int Quantity of items to be added
- * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
- * @param sendMessage : boolean Specifies whether to send message to Client about this action
- */
- - public void addItem(String process, int itemId, int count, L2Object reference, boolean sendMessage)
- + public void addItem(String process, int itemId, long countL, L2Object reference, boolean sendMessage)
- {
- + int count = 0;
- + count = (int)countL;
- if (count > 0)
- {
- // Sends message to client if requested
- if (sendMessage)
- {
- if (count > 1)
- diff --git java/net/sf/l2j/gameserver/model/actor/instance/L2achievementsInstance.java
- new file mode 100644
- index 0000000..980a111
- --- /dev/null
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2achievementsInstance.java
- @@ -0,0 +1,261 @@
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import java.util.StringTokenizer;
- +
- +import net.sf.l2j.achievementEngine.Achievement;
- +import net.sf.l2j.achievementEngine.AchievementsManager;
- +import net.sf.l2j.achievementEngine.Condition;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.templates.L2NpcTemplate;
- +
- +public class L2achievementsInstance extends L2NpcInstance
- +{
- +public L2achievementsInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- +}
- +
- +@Override
- + public void onBypassFeedback(L2PcInstance player, String command)
- + {
- + 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)
- + {
- + StringBuilder tb = new StringBuilder();
- + tb.append("<html><title>Achievements Manager</title>");
- + tb.append("<body><center><br><br><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\"><br>");
- + tb.append("<br><br><button value=\"My Achievements\" action=\"bypass -h npc_%objectId%_showMyAchievements\" width=\"75\" height=\"21\" back=\"L2UI_CH3.Btn1_normal\" fore=\"L2UI_CH3.Btn1_normal\">");
- + tb.append("<br><br><button value=\"Statistics\" action=\"bypass -h npc_%objectId%_showMyStats\" width=\"75\" height=\"21\" back=\"L2UI_CH3.Btn1_normal\" fore=\"L2UI_CH3.Btn1_normal\">");
- + tb.append("<br><br><button value=\"Help\" action=\"bypass -h npc_%objectId%_showHelpWindow\" width=\"75\" height=\"21\" back=\"L2UI_CH3.Btn1_normal\" fore=\"L2UI_CH3.Btn1_normal\">");
- + tb.append("</center></body>");
- + tb.append("</html>");
- +
- + 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)
- + {
- + StringBuilder tb = new StringBuilder();
- + 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 >");
- + 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=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\"><center>");
- + }
- +
- + tb.append("</center></body></html>");
- + 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);
- +
- + StringBuilder tb = new StringBuilder();
- + 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=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\">");
- + }
- +
- + 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=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\"><center>");
- +
- + tb.append("</center></body></html>");
- + 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)
- + {
- + StringBuilder tb = new StringBuilder();
- + 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=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\"><center>");
- +
- + tb.append("</center></body></html>");
- + 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 )
- + {
- + StringBuilder tb = new StringBuilder();
- + 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("List Player " + player.getCompletedAchievements() + " ");
- +
- + 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=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\"><center>");
- +
- + tb.append("</center></body></html>");
- + 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)
- + {
- + StringBuilder tb = new StringBuilder();
- + 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("<center>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></center>");
- +
- + tb.append("Achievements Engine by <font color=\"LEVEL\">L2JSanne</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=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\"><center>");
- +
- + tb.append("</center></body></html>");
- + 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\">" + c.getName() + "</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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement