Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P L2jHellasCore2
- Index: java/Extensions/AchievmentsEngine/conditions/Noble.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Noble.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Noble.java (working copy)
- @@ -0,0 +1,30 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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;
- +
- + if (player.isNoble())
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/events.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/events.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/events.java (working copy)
- @@ -0,0 +1,33 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + *
- + *
- + */
- +public class events extends Condition
- +{
- + public events(Object value)
- + {
- + super(value);
- + setName("Events played");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + @SuppressWarnings("unused")
- + int val = Integer.parseInt(getValue().toString());
- +
- + // if (EventStats.getInstance().getEvents(player.getObjectId()) >= val)
- + // return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/ItemsCount.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/ItemsCount.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/ItemsCount.java (working copy)
- @@ -0,0 +1,51 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +import java.util.StringTokenizer;
- +
- +
- +/**
- + *
- + *
- + *
- + * Condition: ItemsCount
- + * Check if player has proper ammount of item in inventory.
- + */
- +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;
- + else
- + {
- + 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
- Index: java/Extensions/AchievmentsEngine/conditions/WeaponEnchant.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/WeaponEnchant.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/WeaponEnchant.java (working copy)
- @@ -0,0 +1,37 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.L2ItemInstance;
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jhellas.gameserver.model.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
- Index: java/Extensions/AchievmentsEngine/conditions/Hero.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Hero.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Hero.java (working copy)
- @@ -0,0 +1,30 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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;
- +
- + if (player.isHero())
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/Pvp.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Pvp.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Pvp.java (working copy)
- @@ -0,0 +1,32 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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());
- +
- + if (player.getPvpKills() >= val)
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/AchievementsManager.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/AchievementsManager.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/AchievementsManager.java (working copy)
- @@ -0,0 +1,330 @@
- +package Extensions.AchievmentsEngine;
- +
- +import Extensions.AchievmentsEngine.base.Achievement;
- +import Extensions.AchievmentsEngine.base.Condition;
- +import Extensions.AchievmentsEngine.conditions.*;
- +
- +import com.l2jhellas.Config;
- +import com.l2jhellas.L2DatabaseFactory;
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +import java.io.File;
- +import java.io.FileInputStream;
- +import java.io.InputStreamReader;
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +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 org.xml.sax.InputSource;
- +
- +
- +/**
- + *
- + *
- + */
- +public class AchievementsManager
- +{
- + private Map<Integer, Achievement> _achievementList = new FastMap<>();
- +
- + private FastList<String> _binded = new FastList<>();
- +
- + private final String ACHIEVEMENTS_FILE_PATH = Config.DATAPACK_ROOT + "/data/achievements.xml";
- +
- + 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(ACHIEVEMENTS_FILE_PATH);
- +
- + if (!file.exists())
- + {
- + _log.warning("[AchievementsEngine] Error: achievements xml file does not exist, check directory!");
- + }
- + try
- + {
- + InputSource in = new InputSource(new InputStreamReader(new FileInputStream(file), "UTF-8"));
- + in.setEncoding("UTF-8");
- + Document doc = factory.newDocumentBuilder().parse(in);
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + if (n.getNodeName().equalsIgnoreCase("list"))
- + {
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + if (d.getNodeName().equalsIgnoreCase("achievement"))
- + {
- + int id = checkInt(d, "id");
- +
- + String name = String.valueOf(d.getAttributes().getNamedItem("name").getNodeValue());
- + String description = String.valueOf(d.getAttributes().getNamedItem("description").getNodeValue());
- + String reward = String.valueOf(d.getAttributes().getNamedItem("reward").getNodeValue());
- + boolean repeat = checkBoolean(d, "repeatable");
- +
- + FastList<Condition> conditions = conditionList(d.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())
- + {
- + int count = achievement.getRewardList().get(id).intValue();
- + player.addItem(achievement.getName(), id, count, player, true);
- +
- + }
- + }
- +
- + private static boolean checkBoolean(Node d, String nodename)
- + {
- + boolean b = false;
- +
- + try
- + {
- + b = Boolean.valueOf(d.getAttributes().getNamedItem(nodename).getNodeValue());
- + }
- + catch (Exception e)
- + {
- +
- + }
- + return b;
- + }
- +
- + @SuppressWarnings("static-method")
- + 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 static 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
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +
- + public FastList<Condition> conditionList(NamedNodeMap attributesList)
- + {
- + FastList<Condition> conditions = new FastList<>();
- +
- + 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 FastList<String> getBinded()
- + {
- + return _binded;
- + }
- +
- + public boolean isBinded(int obj,int ach)
- + {
- + for(String binds : _binded)
- + {
- + String[] spl = binds.split("@");
- + if(spl[0].equals(String.valueOf(obj)) && spl[1].equals(String.valueOf(ach)))
- + return true;
- + }
- + return false;
- + }
- + public static AchievementsManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final AchievementsManager _instance = new AchievementsManager();
- + }
- +
- + private static 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 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("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("mustBeClanLeader"))
- + conditions.add(new ClanLeader(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 Mage(value));
- + else if (nodeName.equals("minSubclassCount"))
- + conditions.add(new Sub(value));
- + else if (nodeName.equals("CompleteAchievements"))
- + conditions.add(new CompleteAchievements(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("minHeroCount"))
- + conditions.add(new HeroCount(value));
- + else if (nodeName.equals("raidToKill"))
- + conditions.add(new RaidKill(value));
- + else if (nodeName.equals("raidToKill1"))
- + conditions.add(new RaidKill(value));
- + else if (nodeName.equals("raidToKill2"))
- + conditions.add(new RaidKill(value));
- + else if (nodeName.equals("minRaidPoints"))
- + conditions.add(new RaidPoints(value));
- + else if (nodeName.equals("eventKills"))
- + conditions.add(new eventKills(value));
- + else if (nodeName.equals("events"))
- + conditions.add(new events(value));
- + else if (nodeName.equals("eventWins"))
- + conditions.add(new eventWins(value));
- + }
- +
- + public void loadUsed()
- + {
- + Connection con = null;
- + try
- + {
- + PreparedStatement statement;
- + ResultSet rs;
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "SELECT ";
- + for (int i=1; i <=getAchievementList().size(); i++)
- + {
- + if(i!=getAchievementList().size())
- + sql=sql+"a"+i+",";
- + else
- + sql=sql+"a"+i;
- +
- + }
- +
- + sql=sql+" from achievements";
- + statement = con.prepareStatement(sql);
- +
- + rs = statement.executeQuery();
- + while(rs.next())
- + {
- + for (int i=1; i <=getAchievementList().size(); i++)
- + {
- + String ct=rs.getString(i);
- + if(ct.length()>1 && ct.startsWith("1"))
- + {
- + _binded.add(ct.substring(ct.indexOf("1")+1)+"@"+i);
- + }
- + }
- + }
- + statement.close();
- + rs.close();
- + }
- + catch (SQLException e)
- + {
- + _log.warning("[ACHIEVEMENTS SAVE GETDATA]" );
- + e.printStackTrace();
- + }
- + finally
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/Karma.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Karma.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Karma.java (working copy)
- @@ -0,0 +1,32 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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());
- +
- + if (player.getKarma() >= val)
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/eventKills.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/eventKills.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/eventKills.java (working copy)
- @@ -0,0 +1,33 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + *
- + *
- + */
- +public class eventKills extends Condition
- +{
- + public eventKills(Object value)
- + {
- + super(value);
- + setName("Event Kills");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + @SuppressWarnings("unused")
- + int val = Integer.parseInt(getValue().toString());
- +
- + // if (EventStats.getInstance().getEventKills(player.getObjectId()) >= val)
- + // return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/RaidPoints.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/RaidPoints.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/RaidPoints.java (working copy)
- @@ -0,0 +1,52 @@
- +/*
- + * 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 2, 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, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + *
- + *
- + *
- + */
- +public class RaidPoints extends Condition
- +{
- + public RaidPoints(Object value)
- + {
- + super(value);
- + setName("Raid Points");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + RaidBossPointsManager.getInstance();
- + if(RaidBossPointsManager.getPointsByOwnerId(player.getObjectId())>=val)
- + return true;
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/HeroCount.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/HeroCount.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/HeroCount.java (working copy)
- @@ -0,0 +1,43 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jhellas.gameserver.model.entity.Hero;
- +import com.l2jhellas.gameserver.model.entity.Olympiad;
- +import com.l2jhellas.gameserver.templates.StatsSet;
- +/**
- + *
- + *
- + *
- + */
- +public class HeroCount extends Condition
- +{
- + public HeroCount(Object value)
- + {
- + super(value);
- + setName("Hero Count");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + int val = Integer.parseInt(getValue().toString());
- + for(int hero: Hero.getInstance().getHeroes().keySet())
- + {
- + if(hero==player.getObjectId())
- + {
- + StatsSet sts = Hero.getInstance().getHeroes().get(hero);
- + if(sts.getString(Olympiad.CHAR_NAME).equals(player.getName()))
- + {
- + if(sts.getInteger(Hero.COUNT)>=val)
- + return true;
- + }
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/com/l2jhellas/gameserver/GameServer.java
- ===================================================================
- --- java/com/l2jhellas/gameserver/GameServer.java (revision 218)
- +++ java/com/l2jhellas/gameserver/GameServer.java (working copy)
- @@ -23,6 +23,7 @@
- import java.util.logging.LogManager;
- import java.util.logging.Logger;
- +import Extensions.AchievmentsEngine.AchievementsManager;
- import Extensions.Balancer.BalanceLoad;
- import Extensions.RankSystem.PvpTable;
- import Extensions.RankSystem.RankCharacterRewardTable;
- @@ -370,6 +371,7 @@
- Util.printSection("Customs");
- // we could add general custom config?
- + AchievementsManager.getInstance();
- PcColorTable.getInstance();
- MaxCheatersTable.getInstance();
- Hitman.start();
- Index: java/Extensions/AchievmentsEngine/conditions/Castle.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Castle.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Castle.java (working copy)
- @@ -0,0 +1,32 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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
- Index: java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java (revision 218)
- +++ java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -16,6 +16,7 @@
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- +import java.sql.Statement;
- import java.util.Calendar;
- import java.util.Collection;
- import java.util.Date;
- @@ -32,6 +33,7 @@
- import javolution.util.FastList;
- import javolution.util.FastMap;
- +import Extensions.AchievmentsEngine.AchievementsManager;
- import Extensions.RaidEvent.L2EventChecks;
- import Extensions.RaidEvent.L2RaidEvent;
- import Extensions.RankSystem.RankPvpSystem;
- @@ -3274,7 +3276,134 @@
- }
- }
- }
- -
- + /*
- + * Conversion to long (Only For Achievement Manager)
- + *
- + */
- + 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())
- + {
- + 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);
- + }
- + else if(CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
- + {
- + CursedWeaponsManager.getInstance().activate(this, item);
- + }
- +
- + item = null;
- + }
- + }
- + }
- +
- /**
- * Adds item to Inventory and send a Server->Client InventoryUpdate packet
- * to the L2PcInstance.
- @@ -13319,4 +13448,127 @@
- else
- return;
- }
- +private List<Integer> _completedAchievements = new FastList<>();
- +
- + public long getOnlineTime()
- + {
- + return _onlineTime;
- + }
- +
- + public List<Integer> getCompletedAchievements()
- + {
- + return _completedAchievements;
- + }
- +
- + 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 || String.valueOf(a).startsWith("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
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +
- + public void saveAchievementData(int achievementID,int objid)
- + {
- + Connection con = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + Statement statement = con.createStatement();
- + if (achievementID==4 || achievementID==6 || achievementID==11 || achievementID==13)
- + {
- + statement.executeUpdate("UPDATE achievements SET a" + achievementID + "=1"+objid+" WHERE owner_id=" + getObjectId());
- + }
- + else
- + 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
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- }
- Index: java/com/l2jhellas/gameserver/instancemanager/RaidBossPointsManager.java
- ===================================================================
- --- java/com/l2jhellas/gameserver/instancemanager/RaidBossPointsManager.java (revision 218)
- +++ java/com/l2jhellas/gameserver/instancemanager/RaidBossPointsManager.java (working copy)
- @@ -29,6 +29,7 @@
- import javolution.util.FastList;
- import javolution.util.FastMap;
- +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
- import com.l2jhellas.Config;
- import com.l2jhellas.L2DatabaseFactory;
- import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- @@ -99,6 +100,11 @@
- }
- }
- + public static final RaidBossPointsManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- public final static void updatePointsInDB(L2PcInstance player, int raidId, int points)
- {
- Connection con = null;
- @@ -278,4 +284,9 @@
- return tmpRanking;
- }
- +
- + private static class SingletonHolder
- + {
- + protected static final RaidBossPointsManager _instance = new RaidBossPointsManager();
- + }
- }
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/SkillEnchant.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/SkillEnchant.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/SkillEnchant.java (working copy)
- @@ -0,0 +1,42 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.L2Skill;
- +import com.l2jhellas.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)
- + {
- + int sklvl = Integer.parseInt(lvl.substring(1));
- + if(sklvl>=val)
- + return true;
- + }
- + }
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/base/Achievement.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/base/Achievement.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/base/Achievement.java (working copy)
- @@ -0,0 +1,111 @@
- +package Extensions.AchievmentsEngine.base;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +import java.util.logging.Logger;
- +
- +
- +import javolution.util.FastList;
- +import javolution.util.FastMap;
- +
- +/**
- + *
- + *
- + */
- +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());
- +
- + @SuppressWarnings("unused")
- + 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;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/Level.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Level.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Level.java (working copy)
- @@ -0,0 +1,33 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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;
- + else
- + {
- + int val = Integer.parseInt(getValue().toString());
- +
- + if (player.getLevel() >= val)
- + return true;
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/Adena.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Adena.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Adena.java (working copy)
- @@ -0,0 +1,33 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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;
- + else
- + {
- + long val = Integer.parseInt(getValue().toString());
- +
- + if (player.getInventory().getAdena() >= val)
- + return true;
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/Pk.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Pk.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Pk.java (working copy)
- @@ -0,0 +1,32 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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());
- +
- + if (player.getPkKills() >= val)
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/com/l2jhellas/gameserver/model/actor/instance/L2AchievementsInstance.java
- ===================================================================
- --- java/com/l2jhellas/gameserver/model/actor/instance/L2AchievementsInstance.java (revision 0)
- +++ java/com/l2jhellas/gameserver/model/actor/instance/L2AchievementsInstance.java (working copy)
- @@ -0,0 +1,338 @@
- +package com.l2jhellas.gameserver.model.actor.instance;
- +
- +import com.l2jhellas.gameserver.skills.SkillTable;
- +import com.l2jhellas.gameserver.model.L2Clan;
- +import com.l2jhellas.gameserver.model.L2ItemInstance;
- +import com.l2jhellas.gameserver.model.L2Skill;
- +import com.l2jhellas.gameserver.model.actor.instance.L2NpcInstance;
- +import Extensions.AchievmentsEngine.AchievementsManager;
- +import Extensions.AchievmentsEngine.base.Achievement;
- +import Extensions.AchievmentsEngine.base.Condition;
- +import Extensions.AchievmentsEngine.conditions.WeaponEnchant;
- +import com.l2jhellas.gameserver.model.Inventory;
- +import com.l2jhellas.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jhellas.gameserver.templates.L2NpcTemplate;
- +
- +import java.util.StringTokenizer;
- +
- +import javolution.text.TextBuilder;
- +
- +
- +/**
- + *
- + *
- + */
- +@SuppressWarnings("unused")
- +public class L2AchievementsInstance extends L2NpcInstance
- +{
- + public L2AchievementsInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- + private boolean first=true;
- + @Override
- + public void onBypassFeedback(L2PcInstance player, String command)
- + {
- + if (player == null)
- + {
- + 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());
- + if (id == 10)
- + {
- + player.destroyItemByItemId("", 8787, 200, this, true);
- + AchievementsManager.getInstance().rewardForAchievement(id, player);
- + }
- + else if(id==4 || id==19)
- + {
- + L2ItemInstance weapon = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
- + if(weapon!=null)
- + {
- + int objid = weapon.getObjectId();
- + if(AchievementsManager.getInstance().getAchievementList().get(id).meetAchievementRequirements(player))
- + {
- + if(!AchievementsManager.getInstance().isBinded(objid,id))
- + {
- + AchievementsManager.getInstance().getBinded().add(objid+"@"+id);
- + player.saveAchievementData(id,objid);
- + AchievementsManager.getInstance().rewardForAchievement(id, player);
- + }
- + else
- + player.sendMessage("This item was already used to earn this achievement");
- + }
- + else
- + {
- + player.sendMessage("Seems you don't meet the achievements requirements now.");
- + }
- + }
- + else
- + player.sendMessage("You must equip your weapon in order to get rewarded.");
- + }
- + else if(id==6 || id==18)
- + {
- + int clid = player.getClan().getClanId();
- +
- + if(!AchievementsManager.getInstance().isBinded(clid,id))
- + {
- + AchievementsManager.getInstance().getBinded().add(clid+"@"+id);
- + player.saveAchievementData(id,clid);
- + AchievementsManager.getInstance().rewardForAchievement(id, player);
- + }
- + else
- + player.sendMessage("Current clan was already rewarded for this achievement.");
- + }
- + else
- + {
- + player.saveAchievementData(id,0);
- + AchievementsManager.getInstance().rewardForAchievement(id, player);
- + }
- + showMyAchievements(player);
- + }
- + else if (command.startsWith ("showMyStats"))
- + {
- + showMyStatsWindow(player);
- + }
- + else if (command.startsWith("showHelpWindow"))
- + {
- + showHelpWindow(player);
- + }
- + }
- +
- + @Override
- + public void showChatWindow(L2PcInstance player, int val)
- + {
- + if(first)
- + {
- + AchievementsManager.getInstance().loadUsed();
- + first=false;
- + }
- + 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\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21>");
- + tb.append("<button value=\"Statistics\" action=\"bypass -h npc_%objectId%_showMyStats\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21>");
- + tb.append("<button value=\"Help\" action=\"bypass -h npc_%objectId%_showHelpWindow\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21>");
- +
- + 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\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></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() + "\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21>");
- + }
- +
- + 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=\"left\">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\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></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\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></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\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></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("<table><tr><td>You can check the status of your achievements,</td></tr><tr><td>receive reward if every condition of the achievement is meet,</td></tr><tr><td>if not you can check which condition is still not met, by using info button</td></tr></table>");
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<table><tr><td><font color=\"FF0000\">Not Completed</font> - you did not meet the achivement requirements.</td></tr>");
- + tb.append("<tr><td><font color=\"LEVEL\">Get Reward</font> - you may receive reward, click info.</td></tr>");
- + tb.append("<tr><td><font color=\"5EA82E\">Completed</font> - achievement completed, reward received.</td></tr></table>");
- +
- + tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
- + tb.append("<center><button value=\"Back\" action=\"bypass -h npc_%objectId%_showMainWindow\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></center>");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
- + msg.setHtml(tb.toString());
- + msg.replace("%objectId%", String.valueOf(this.getObjectId()));
- +
- + player.sendPacket(msg);
- + }
- +
- + @SuppressWarnings("static-method")
- + private String getStatusString(int achievementID, L2PcInstance player)
- + {
- + if (player.getCompletedAchievements().contains(achievementID))
- + {
- + return "<font color=\"5EA82E\">Completed</font>";
- + }
- + else
- + {
- + if (AchievementsManager.getInstance().getAchievementList().get(achievementID).meetAchievementRequirements(player))
- + {
- + return "<font color=\"LEVEL\">Get Reward</font>";
- + }
- + else
- + {
- + return "<font color=\"FF0000\">Not Completed</font>";
- + }
- + }
- + }
- +
- + @SuppressWarnings("static-method")
- + private String getTableColor(int i)
- + {
- + if (i % 2 == 0)
- + return "<table width=270 border=0 bgcolor=\"444444\">";
- + else
- + 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=100 align=\"left\">" + 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
- Index: java/Extensions/AchievmentsEngine/conditions/Marry.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Marry.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Marry.java (working copy)
- @@ -0,0 +1,30 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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;
- +
- + if (player.isMarried())
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/com/l2jhellas/gameserver/model/entity/Siege.java
- ===================================================================
- --- java/com/l2jhellas/gameserver/model/entity/Siege.java (revision 218)
- +++ java/com/l2jhellas/gameserver/model/entity/Siege.java (working copy)
- @@ -36,6 +36,7 @@
- import com.l2jhellas.gameserver.instancemanager.SiegeReward;
- import com.l2jhellas.gameserver.model.L2Character;
- import com.l2jhellas.gameserver.model.L2Clan;
- +import com.l2jhellas.gameserver.model.L2ClanMember;
- import com.l2jhellas.gameserver.model.L2Object;
- import com.l2jhellas.gameserver.model.L2SiegeClan;
- import com.l2jhellas.gameserver.model.L2SiegeClan.SiegeClanType;
- @@ -267,6 +268,16 @@
- _siegeGuardManager.removeMercs();
- getCastle().spawnDoor(); // Respawn door to castle
- getCastle().getZone().updateZoneStatusForCharactersInside();
- + L2Clan clan = ClanTable.getInstance().getClan(getCastle().getOwnerId());
- + for (L2ClanMember member : clan.getMembers())
- + {
- + if (member != null)
- + {
- + L2PcInstance player = member.getPlayerInstance();
- + if (player != null && player.isNoble())
- + Hero.getInstance().setCastleTaken(player.getObjectId(), getCastle().getCastleId());
- + }
- + }
- }
- }
- Index: java/Extensions/AchievmentsEngine/conditions/ClanLeader.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/ClanLeader.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/ClanLeader.java (working copy)
- @@ -0,0 +1,31 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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;
- +
- + if (player.getClan() != null)
- + if (player.isClanLeader())
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/eventWins.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/eventWins.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/eventWins.java (working copy)
- @@ -0,0 +1,33 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + *
- + *
- + */
- +public class eventWins extends Condition
- +{
- + public eventWins(Object value)
- + {
- + super(value);
- + setName("Event Wins");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + @SuppressWarnings("unused")
- + int val = Integer.parseInt(getValue().toString());
- +
- + //if (EventStats.getInstance().getEventWins(player.getObjectId()) >= val)
- + // return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/Crp.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Crp.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Crp.java (working copy)
- @@ -0,0 +1,34 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + *
- + *
- + */
- +public class Crp extends Condition
- +{
- + public Crp(Object value)
- + {
- + super(value);
- + setName("Clan Reputation");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + if (player.getClan() != null)
- + {
- + int val = Integer.parseInt(getValue().toString());
- +
- + if (player.getClan().getReputationScore() >= val)
- + return true;
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/com/l2jhellas/gameserver/model/actor/instance/L2RaidBossInstance.java
- ===================================================================
- --- java/com/l2jhellas/gameserver/model/actor/instance/L2RaidBossInstance.java (revision 218)
- +++ java/com/l2jhellas/gameserver/model/actor/instance/L2RaidBossInstance.java (working copy)
- @@ -15,9 +15,11 @@
- package com.l2jhellas.gameserver.model.actor.instance;
- import com.l2jhellas.gameserver.ThreadPoolManager;
- +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
- import com.l2jhellas.gameserver.instancemanager.RaidBossSpawnManager;
- import com.l2jhellas.gameserver.model.L2Character;
- import com.l2jhellas.gameserver.model.L2Spawn;
- +import com.l2jhellas.gameserver.model.entity.Hero;
- import com.l2jhellas.gameserver.network.SystemMessageId;
- import com.l2jhellas.gameserver.network.serverpackets.SystemMessage;
- import com.l2jhellas.gameserver.templates.L2NpcTemplate;
- @@ -68,8 +70,19 @@
- return false;
- if(killer instanceof L2PlayableInstance)
- {
- - SystemMessage msg = new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL);
- - broadcastPacket(msg);
- + if (killer.isInParty())
- + {
- + for (L2PcInstance member : killer.getParty().getPartyMembers())
- + {
- + Hero.getInstance().setRBkilled(member.getObjectId(), getNpcId());
- + }
- + }
- + else
- + {
- + Hero.getInstance().setRBkilled(killer.getObjectId(), getNpcId());
- + }
- + SystemMessage msg = new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL);
- + broadcastPacket(msg);
- }
- RaidBossSpawnManager.getInstance().updateStatus(this, true);
- Index: java/Extensions/AchievmentsEngine/conditions/Mage.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Mage.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Mage.java (working copy)
- @@ -0,0 +1,30 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + *
- + *
- + */
- +public class Mage extends Condition
- +{
- + public Mage(Object value)
- + {
- + super(value);
- + setName("Be Mage");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + if (player.isMageClass())
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/MinCMcount.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/MinCMcount.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/MinCMcount.java (working copy)
- @@ -0,0 +1,34 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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
- Index: java/Extensions/AchievmentsEngine/conditions/CompleteAchievements.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/CompleteAchievements.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/CompleteAchievements.java (working copy)
- @@ -0,0 +1,32 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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());
- +
- + if (player.getCompletedAchievements().size() >= val)
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/OnlineTime.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/OnlineTime.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/OnlineTime.java (working copy)
- @@ -0,0 +1,34 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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());
- +
- + if(player.getOnlineTime()>=val*24*60*60*1000)
- + {
- + return true;
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/com/l2jhellas/gameserver/model/entity/Hero.java
- ===================================================================
- --- java/com/l2jhellas/gameserver/model/entity/Hero.java (revision 218)
- +++ java/com/l2jhellas/gameserver/model/entity/Hero.java (working copy)
- @@ -18,17 +18,23 @@
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- +import java.text.SimpleDateFormat;
- import java.util.Arrays;
- +import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- +import javolution.util.FastList;
- import javolution.util.FastMap;
- import com.l2jhellas.Config;
- import com.l2jhellas.L2DatabaseFactory;
- +import com.l2jhellas.gameserver.datatables.sql.CharNameTable;
- import com.l2jhellas.gameserver.datatables.sql.ClanTable;
- +import com.l2jhellas.gameserver.datatables.sql.NpcTable;
- +import com.l2jhellas.gameserver.instancemanager.CastleManager;
- import com.l2jhellas.gameserver.model.L2Clan;
- import com.l2jhellas.gameserver.model.L2ItemInstance;
- import com.l2jhellas.gameserver.model.L2World;
- @@ -39,6 +45,7 @@
- import com.l2jhellas.gameserver.network.serverpackets.SystemMessage;
- import com.l2jhellas.gameserver.network.serverpackets.UserInfo;
- import com.l2jhellas.gameserver.templates.L2Item;
- +import com.l2jhellas.gameserver.templates.L2NpcTemplate;
- import com.l2jhellas.gameserver.templates.StatsSet;
- @@ -60,11 +67,18 @@
- "(6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621) " +
- "AND owner_id NOT IN (SELECT obj_Id FROM characters WHERE accesslevel > 0)";
- + private static final String GET_DIARIES = "SELECT * FROM heroes_diary WHERE char_id=? ORDER BY time ASC";
- + private static final String UPDATE_DIARIES = "INSERT INTO heroes_diary (char_id, time, action, param) values(?,?,?,?)";
- +
- +
- private static final int[] _heroItems = {6842, 6611, 6612, 6613, 6614, 6615, 6616,
- 6617, 6618, 6619, 6620, 6621
- };
- private static Map<Integer, StatsSet> _heroes;
- private static Map<Integer, StatsSet> _completeHeroes;
- +
- + private static Map<Integer, List<StatsSet>> _herodiary;
- + private static List<StatsSet> _diary;
- public static final String COUNT = "count";
- public static final String PLAYED = "played";
- @@ -73,6 +87,10 @@
- public static final String ALLY_NAME = "ally_name";
- public static final String ALLY_CREST = "ally_crest";
- + public static final int ACTION_RAID_KILLED = 1;
- + public static final int ACTION_HERO_GAINED = 2;
- + public static final int ACTION_CASTLE_TAKEN = 3;
- +
- public static Hero getInstance()
- {
- if (_instance == null)
- @@ -89,7 +107,8 @@
- {
- _heroes = new FastMap<Integer, StatsSet>();
- _completeHeroes = new FastMap<Integer, StatsSet>();
- -
- + _herodiary = new FastMap<>();
- +
- PreparedStatement statement;
- PreparedStatement statement2;
- @@ -539,4 +558,133 @@
- try{con.close();}catch(SQLException e){e.printStackTrace();}
- }
- }
- +
- + public void setDiaryData(int charId, int action, int param)
- + {
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement statement = con.prepareStatement(UPDATE_DIARIES);
- + statement.setInt(1, charId);
- + statement.setLong(2, System.currentTimeMillis());
- + statement.setInt(3, action);
- + statement.setInt(4, param);
- + statement.execute();
- + statement.close();
- + }
- + catch (SQLException e)
- + {
- + if (_log.isLoggable(Level.SEVERE))
- + _log.log(Level.SEVERE, "SQL exception while saving DiaryData.", e);
- + }
- + }
- +
- + public void loadDiary(int charId)
- + {
- + _diary = new FastList<>();
- +
- + int diaryentries = 0;
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement statement = con.prepareStatement(GET_DIARIES);
- + statement.setInt(1, charId);
- + ResultSet rset = statement.executeQuery();
- +
- + while (rset.next())
- + {
- + StatsSet _diaryentry = new StatsSet();
- +
- + long time = rset.getLong("time");
- + int action = rset.getInt("action");
- + int param = rset.getInt("param");
- +
- + String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(time));
- + _diaryentry.set("date", date);
- +
- + if (action == ACTION_RAID_KILLED)
- + {
- + L2NpcTemplate template = NpcTable.getInstance().getTemplate(param);
- + if (template != null)
- + _diaryentry.set("action", template.getName() + " was defeated");
- + }
- + else if (action == ACTION_HERO_GAINED)
- + _diaryentry.set("action", "Gained Hero status");
- + else if (action == ACTION_CASTLE_TAKEN)
- + {
- + Castle castle = CastleManager.getInstance().getCastleById(param);
- + if (castle != null)
- + _diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
- + }
- + _diary.add(_diaryentry);
- + diaryentries++;
- + }
- + rset.close();
- + statement.close();
- +
- + _herodiary.put(charId, _diary);
- +
- + _log.info("Hero System: Loaded " + diaryentries + " diary entries for Hero: " + CharNameTable.getInstance().getNameById(charId));
- + }
- + catch (SQLException e)
- + {
- + _log.warning("Hero System: Couldnt load Hero Diary for char_id: " + charId);
- + if (Config.DEBUG)
- + _log.log(Level.WARNING, "", e);
- + }
- + }
- +
- + public void setRBkilled(int charId, int npcId)
- + {
- + setDiaryData(charId, ACTION_RAID_KILLED, npcId);
- +
- + L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
- +
- + if (_herodiary.containsKey(charId) && (template != null))
- + {
- + // Get Data
- + List<StatsSet> _list = _herodiary.get(charId);
- +
- + // Clear old data
- + _herodiary.remove(charId);
- +
- + // Prepare new data
- + StatsSet _diaryentry = new StatsSet();
- + String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
- + _diaryentry.set("date", date);
- + _diaryentry.set("action", template.getName() + " was defeated");
- +
- + // Add to old list
- + _list.add(_diaryentry);
- +
- + // Put new list into diary
- + _herodiary.put(charId, _list);
- + }
- + }
- +
- + public void setCastleTaken(int charId, int castleId)
- + {
- + setDiaryData(charId, ACTION_CASTLE_TAKEN, castleId);
- +
- + Castle castle = CastleManager.getInstance().getCastleById(castleId);
- +
- + if (_herodiary.containsKey(charId) && (castle != null))
- + {
- + // Get Data
- + List<StatsSet> _list = _herodiary.get(charId);
- +
- + // Clear old data
- + _herodiary.remove(charId);
- +
- + // Prepare new data
- + StatsSet _diaryentry = new StatsSet();
- + String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
- + _diaryentry.set("date", date);
- + _diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
- +
- + // Add to old list
- + _list.add(_diaryentry);
- +
- + // Put new list into diary
- + _herodiary.put(charId, _list);
- + }
- + }
- }
- Index: java/Extensions/AchievmentsEngine/conditions/ClanLevel.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/ClanLevel.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/ClanLevel.java (working copy)
- @@ -0,0 +1,34 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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
- Index: java/Extensions/AchievmentsEngine/base/Condition.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/base/Condition.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/base/Condition.java (working copy)
- @@ -0,0 +1,35 @@
- +package Extensions.AchievmentsEngine.base;
- +
- +import com.l2jhellas.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 player);
- +
- + public Object getValue()
- + {
- + return _value;
- + }
- +
- + public void setName(String s)
- + {
- + _name = s;
- + }
- +
- + public String getName()
- + {
- + return _name;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/Sub.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/Sub.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/Sub.java (working copy)
- @@ -0,0 +1,32 @@
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.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());
- +
- + if (player.getSubClasses().size() >= val)
- + return true;
- +
- + return false;
- + }
- +}
- \ No newline at end of file
- Index: java/Extensions/AchievmentsEngine/conditions/RaidKill.java
- ===================================================================
- --- java/Extensions/AchievmentsEngine/conditions/RaidKill.java (revision 0)
- +++ java/Extensions/AchievmentsEngine/conditions/RaidKill.java (working copy)
- @@ -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 2, 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, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package Extensions.AchievmentsEngine.conditions;
- +
- +import Extensions.AchievmentsEngine.base.Condition;
- +
- +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- +
- +import java.util.Map;
- +
- +
- +/**
- + *
- + *
- + *
- + */
- +public class RaidKill extends Condition
- +{
- + public RaidKill(Object value)
- + {
- + super(value);
- + setName("Raid Kill");
- + }
- +
- + @Override
- + public boolean meetConditionRequirements(L2PcInstance player)
- + {
- + if (getValue() == null)
- + return false;
- +
- + int val = Integer.parseInt(getValue().toString());
- +
- + Map<Integer,Integer> list = RaidBossPointsManager.getList(player);
- + if(list!=null)
- + {
- + for(int bid: list.keySet())
- + {
- + if(bid==val)
- + {
- + if(RaidBossPointsManager.getList(player).get(bid)>0)
- + return true;
- + }
- + }
- + }
- + return false;
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement