Advertisement
Guest User

Untitled

a guest
Mar 20th, 2013
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 77.14 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jHellasCore2
  3. Index: java/Extensions/AchievmentsEngine/conditions/Noble.java
  4. ===================================================================
  5. --- java/Extensions/AchievmentsEngine/conditions/Noble.java (revision 0)
  6. +++ java/Extensions/AchievmentsEngine/conditions/Noble.java (working copy)
  7. @@ -0,0 +1,30 @@
  8. +package Extensions.AchievmentsEngine.conditions;
  9. +
  10. +import Extensions.AchievmentsEngine.base.Condition;
  11. +
  12. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  13. +
  14. +/**
  15. + *
  16. + *
  17. + */
  18. +public class Noble extends Condition
  19. +{
  20. +   public Noble(Object value)
  21. +   {
  22. +       super(value);
  23. +       setName("Noble");
  24. +   }
  25. +
  26. +   @Override
  27. +   public boolean meetConditionRequirements(L2PcInstance player)
  28. +   {
  29. +       if (getValue() == null)
  30. +           return false;
  31. +      
  32. +       if (player.isNoble())
  33. +           return true;
  34. +          
  35. +       return false;
  36. +   }
  37. +}
  38. \ No newline at end of file
  39. Index: java/Extensions/AchievmentsEngine/conditions/events.java
  40. ===================================================================
  41. --- java/Extensions/AchievmentsEngine/conditions/events.java    (revision 0)
  42. +++ java/Extensions/AchievmentsEngine/conditions/events.java    (working copy)
  43. @@ -0,0 +1,33 @@
  44. +package Extensions.AchievmentsEngine.conditions;
  45. +
  46. +import Extensions.AchievmentsEngine.base.Condition;
  47. +
  48. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  49. +
  50. +/**
  51. + *
  52. + *
  53. + */
  54. +public class events extends Condition
  55. +{
  56. +   public events(Object value)
  57. +   {
  58. +       super(value);
  59. +       setName("Events played");
  60. +   }
  61. +
  62. +   @Override
  63. +   public boolean meetConditionRequirements(L2PcInstance player)
  64. +   {
  65. +       if (getValue() == null)
  66. +           return false;
  67. +      
  68. +       @SuppressWarnings("unused")
  69. +       int val = Integer.parseInt(getValue().toString());
  70. +      
  71. +   //  if (EventStats.getInstance().getEvents(player.getObjectId()) >= val)
  72. +       //  return true;
  73. +      
  74. +       return false;
  75. +   }
  76. +}
  77. \ No newline at end of file
  78. Index: java/Extensions/AchievmentsEngine/conditions/ItemsCount.java
  79. ===================================================================
  80. --- java/Extensions/AchievmentsEngine/conditions/ItemsCount.java    (revision 0)
  81. +++ java/Extensions/AchievmentsEngine/conditions/ItemsCount.java    (working copy)
  82. @@ -0,0 +1,51 @@
  83. +package Extensions.AchievmentsEngine.conditions;
  84. +
  85. +import Extensions.AchievmentsEngine.base.Condition;
  86. +
  87. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  88. +
  89. +import java.util.StringTokenizer;
  90. +
  91. +
  92. +/**
  93. + *
  94. + *
  95. + *
  96. + * Condition: ItemsCount
  97. + * Check if player has proper ammount of item in inventory.
  98. + */
  99. +public class ItemsCount extends Condition
  100. +{
  101. +   public ItemsCount(Object value)
  102. +   {
  103. +       super(value);
  104. +       setName("Items Count");
  105. +   }
  106. +
  107. +   @Override
  108. +   public boolean meetConditionRequirements(L2PcInstance player)
  109. +   {
  110. +       if (getValue() == null)
  111. +           return false;
  112. +       else
  113. +       {
  114. +           String s = getValue().toString();
  115. +           StringTokenizer st = new StringTokenizer(s, ",");
  116. +           int id = 0;
  117. +           int ammount = 0;
  118. +          
  119. +           try
  120. +           {
  121. +               id = Integer.parseInt(st.nextToken());
  122. +               ammount = Integer.parseInt(st.nextToken());
  123. +               if (player.getInventory().getInventoryItemCount(id, 0) >= ammount)
  124. +                   return true;
  125. +           }
  126. +           catch (NumberFormatException nfe)
  127. +           {
  128. +               nfe.printStackTrace();
  129. +           }
  130. +       }
  131. +       return false;
  132. +   }
  133. +}
  134. \ No newline at end of file
  135. Index: java/Extensions/AchievmentsEngine/conditions/WeaponEnchant.java
  136. ===================================================================
  137. --- java/Extensions/AchievmentsEngine/conditions/WeaponEnchant.java (revision 0)
  138. +++ java/Extensions/AchievmentsEngine/conditions/WeaponEnchant.java (working copy)
  139. @@ -0,0 +1,37 @@
  140. +package Extensions.AchievmentsEngine.conditions;
  141. +
  142. +import Extensions.AchievmentsEngine.base.Condition;
  143. +
  144. +import com.l2jhellas.gameserver.model.L2ItemInstance;
  145. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  146. +import com.l2jhellas.gameserver.model.Inventory;
  147. +
  148. +/**
  149. + *
  150. + *
  151. + */
  152. +public class WeaponEnchant extends Condition
  153. +{
  154. +   public WeaponEnchant(Object value)
  155. +   {
  156. +       super(value);
  157. +       setName("Weapon Enchant");
  158. +   }
  159. +
  160. +   @Override
  161. +   public boolean meetConditionRequirements(L2PcInstance player)
  162. +   {
  163. +       if (getValue() == null)
  164. +           return false;
  165. +      
  166. +       int val = Integer.parseInt(getValue().toString());
  167. +      
  168. +       L2ItemInstance weapon = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  169. +      
  170. +       if (weapon != null)
  171. +           if (weapon.getEnchantLevel() >= val)
  172. +               return true;
  173. +
  174. +       return false;
  175. +   }
  176. +}
  177. \ No newline at end of file
  178. Index: java/Extensions/AchievmentsEngine/conditions/Hero.java
  179. ===================================================================
  180. --- java/Extensions/AchievmentsEngine/conditions/Hero.java  (revision 0)
  181. +++ java/Extensions/AchievmentsEngine/conditions/Hero.java  (working copy)
  182. @@ -0,0 +1,30 @@
  183. +package Extensions.AchievmentsEngine.conditions;
  184. +
  185. +import Extensions.AchievmentsEngine.base.Condition;
  186. +
  187. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  188. +
  189. +/**
  190. + *
  191. + *
  192. + */
  193. +public class Hero extends Condition
  194. +{
  195. +   public Hero(Object value)
  196. +   {
  197. +       super(value);
  198. +       setName("Hero");
  199. +   }
  200. +
  201. +   @Override
  202. +   public boolean meetConditionRequirements(L2PcInstance player)
  203. +   {
  204. +       if (getValue() == null)
  205. +           return false;
  206. +      
  207. +       if (player.isHero())
  208. +           return true;
  209. +          
  210. +       return false;
  211. +   }
  212. +}
  213. \ No newline at end of file
  214. Index: java/Extensions/AchievmentsEngine/conditions/Pvp.java
  215. ===================================================================
  216. --- java/Extensions/AchievmentsEngine/conditions/Pvp.java   (revision 0)
  217. +++ java/Extensions/AchievmentsEngine/conditions/Pvp.java   (working copy)
  218. @@ -0,0 +1,32 @@
  219. +package Extensions.AchievmentsEngine.conditions;
  220. +
  221. +import Extensions.AchievmentsEngine.base.Condition;
  222. +
  223. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  224. +
  225. +/**
  226. + *
  227. + *
  228. + */
  229. +public class Pvp extends Condition
  230. +{
  231. +   public Pvp(Object value)
  232. +   {
  233. +       super(value);
  234. +       setName("PvP Count");
  235. +   }
  236. +
  237. +   @Override
  238. +   public boolean meetConditionRequirements(L2PcInstance player)
  239. +   {
  240. +       if (getValue() == null)
  241. +           return false;
  242. +      
  243. +       int val = Integer.parseInt(getValue().toString());
  244. +      
  245. +       if (player.getPvpKills() >= val)
  246. +           return true;
  247. +      
  248. +       return false;
  249. +   }
  250. +}
  251. \ No newline at end of file
  252. Index: java/Extensions/AchievmentsEngine/AchievementsManager.java
  253. ===================================================================
  254. --- java/Extensions/AchievmentsEngine/AchievementsManager.java  (revision 0)
  255. +++ java/Extensions/AchievmentsEngine/AchievementsManager.java  (working copy)
  256. @@ -0,0 +1,330 @@
  257. +package Extensions.AchievmentsEngine;
  258. +
  259. +import Extensions.AchievmentsEngine.base.Achievement;
  260. +import Extensions.AchievmentsEngine.base.Condition;
  261. +import Extensions.AchievmentsEngine.conditions.*;
  262. +
  263. +import com.l2jhellas.Config;
  264. +import com.l2jhellas.L2DatabaseFactory;
  265. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  266. +
  267. +import java.io.File;
  268. +import java.io.FileInputStream;
  269. +import java.io.InputStreamReader;
  270. +import java.sql.Connection;
  271. +import java.sql.PreparedStatement;
  272. +import java.sql.ResultSet;
  273. +import java.sql.SQLException;
  274. +import java.sql.Statement;
  275. +import java.util.Map;
  276. +import java.util.logging.Logger;
  277. +
  278. +import javax.xml.parsers.DocumentBuilderFactory;
  279. +
  280. +import javolution.util.FastList;
  281. +import javolution.util.FastMap;
  282. +
  283. +import org.w3c.dom.Document;
  284. +import org.w3c.dom.NamedNodeMap;
  285. +import org.w3c.dom.Node;
  286. +import org.xml.sax.InputSource;
  287. +
  288. +
  289. +/**
  290. + *
  291. + *
  292. + */
  293. +public class AchievementsManager
  294. +{
  295. +   private Map<Integer, Achievement> _achievementList = new FastMap<>();
  296. +  
  297. +   private FastList<String> _binded = new FastList<>();
  298. +  
  299. +   private final String ACHIEVEMENTS_FILE_PATH = Config.DATAPACK_ROOT + "/data/achievements.xml";
  300. +  
  301. +   private static Logger _log = Logger.getLogger(AchievementsManager.class.getName());
  302. +  
  303. +   public AchievementsManager()
  304. +   {
  305. +       loadAchievements();
  306. +   }
  307. +  
  308. +   private void loadAchievements()
  309. +   {
  310. +       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  311. +       factory.setValidating(false);
  312. +       factory.setIgnoringComments(true);
  313. +      
  314. +       File file = new File(ACHIEVEMENTS_FILE_PATH);
  315. +      
  316. +       if (!file.exists())
  317. +       {
  318. +           _log.warning("[AchievementsEngine] Error: achievements xml file does not exist, check directory!");
  319. +       }
  320. +       try
  321. +       {
  322. +           InputSource in = new InputSource(new InputStreamReader(new FileInputStream(file), "UTF-8"));
  323. +           in.setEncoding("UTF-8");
  324. +           Document doc = factory.newDocumentBuilder().parse(in);
  325. +          
  326. +           for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  327. +           {
  328. +               if (n.getNodeName().equalsIgnoreCase("list"))
  329. +               {
  330. +                   for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  331. +                   {
  332. +                       if (d.getNodeName().equalsIgnoreCase("achievement"))
  333. +                       {
  334. +                           int id = checkInt(d, "id");
  335. +                          
  336. +                           String name = String.valueOf(d.getAttributes().getNamedItem("name").getNodeValue());
  337. +                           String description = String.valueOf(d.getAttributes().getNamedItem("description").getNodeValue());
  338. +                           String reward = String.valueOf(d.getAttributes().getNamedItem("reward").getNodeValue());
  339. +                           boolean repeat = checkBoolean(d, "repeatable");
  340. +                          
  341. +                           FastList<Condition> conditions = conditionList(d.getAttributes());
  342. +                          
  343. +                           _achievementList.put(id, new Achievement(id, name, description, reward, repeat, conditions));
  344. +                           alterTable(id);
  345. +                       }
  346. +                   }
  347. +               }
  348. +           }
  349. +          
  350. +           _log.info("[AchievementsEngine] Successfully loaded: " + getAchievementList().size() + " achievements from xml!");
  351. +       }
  352. +       catch (Exception e)
  353. +       {
  354. +           _log.warning("[AchievementsEngine] Error: " + e);
  355. +           e.printStackTrace();
  356. +       }
  357. +   }
  358. +  
  359. +   public void rewardForAchievement(int achievementID, L2PcInstance player)
  360. +   {
  361. +       Achievement achievement = _achievementList.get(achievementID);
  362. +      
  363. +       for (int id: achievement.getRewardList().keySet())
  364. +       {
  365. +           int count = achievement.getRewardList().get(id).intValue();
  366. +           player.addItem(achievement.getName(), id, count, player, true);
  367. +          
  368. +       }
  369. +   }
  370. +  
  371. +   private static boolean checkBoolean(Node d, String nodename)
  372. +   {
  373. +       boolean b = false;
  374. +      
  375. +       try
  376. +       {
  377. +           b = Boolean.valueOf(d.getAttributes().getNamedItem(nodename).getNodeValue());
  378. +       }
  379. +       catch (Exception e)
  380. +       {
  381. +          
  382. +       }
  383. +       return b;
  384. +   }
  385. +  
  386. +   @SuppressWarnings("static-method")
  387. +   private int checkInt(Node d, String nodename)
  388. +   {
  389. +       int i = 0;
  390. +      
  391. +       try
  392. +       {
  393. +           i = Integer.valueOf(d.getAttributes().getNamedItem(nodename).getNodeValue());
  394. +       }
  395. +       catch (Exception e)
  396. +       {
  397. +          
  398. +       }
  399. +       return i;
  400. +   }
  401. +  
  402. +   /**
  403. +    * Alter table, catch exception if already exist.
  404. +    * @param fieldID
  405. +    */
  406. +   private static void alterTable(int fieldID)
  407. +   {
  408. +       Connection con = null;
  409. +       try
  410. +       {
  411. +           con = L2DatabaseFactory.getInstance().getConnection();
  412. +           Statement statement = con.createStatement();
  413. +           statement.executeUpdate("ALTER TABLE achievements ADD a" + fieldID + " INT DEFAULT 0");
  414. +           statement.close();
  415. +       }
  416. +       catch (SQLException e)
  417. +       {
  418. +
  419. +       }
  420. +       finally
  421. +       {
  422. +           try
  423. +           {
  424. +               con.close();
  425. +           }
  426. +           catch (Exception e)
  427. +           {
  428. +           }
  429. +       }
  430. +   }
  431. +  
  432. +   public FastList<Condition> conditionList(NamedNodeMap attributesList)
  433. +   {
  434. +       FastList<Condition> conditions = new FastList<>();
  435. +      
  436. +       for (int j = 0; j < attributesList.getLength(); j++)
  437. +       {
  438. +           addToConditionList(attributesList.item(j).getNodeName(), attributesList.item(j).getNodeValue(), conditions);
  439. +       }
  440. +      
  441. +       return conditions;
  442. +   }
  443. +  
  444. +   public Map<Integer, Achievement> getAchievementList()
  445. +   {
  446. +       return _achievementList;
  447. +   }
  448. +  
  449. +   public FastList<String> getBinded()
  450. +   {
  451. +       return _binded;
  452. +   }
  453. +
  454. +   public boolean isBinded(int obj,int ach)
  455. +   {
  456. +       for(String binds : _binded)
  457. +       {
  458. +           String[] spl = binds.split("@");
  459. +           if(spl[0].equals(String.valueOf(obj)) && spl[1].equals(String.valueOf(ach)))
  460. +               return true;
  461. +       }
  462. +       return false;
  463. +   }
  464. +   public static AchievementsManager getInstance()
  465. +   {
  466. +       return SingletonHolder._instance;
  467. +   }
  468. +      
  469. +   private static class SingletonHolder
  470. +   {
  471. +       protected static final AchievementsManager _instance = new AchievementsManager();
  472. +   }
  473. +  
  474. +   private static void addToConditionList(String nodeName, Object value, FastList<Condition> conditions)
  475. +   {
  476. +       if (nodeName.equals("minLevel"))
  477. +           conditions.add(new Level(value));
  478. +       else if (nodeName.equals("minPvPCount"))
  479. +           conditions.add(new Pvp(value));
  480. +       else if (nodeName.equals("minPkCount"))
  481. +           conditions.add(new Pk(value));
  482. +       else if (nodeName.equals("minClanLevel"))
  483. +           conditions.add(new ClanLevel(value));
  484. +       else if (nodeName.equals("mustBeHero"))
  485. +           conditions.add(new Hero(value));
  486. +       else if (nodeName.equals("mustBeNoble"))
  487. +           conditions.add(new Noble(value));
  488. +       else if (nodeName.equals("minWeaponEnchant"))
  489. +           conditions.add(new WeaponEnchant(value));          
  490. +       else if (nodeName.equals("minKarmaCount"))
  491. +           conditions.add(new Karma(value));
  492. +       else if (nodeName.equals("minAdenaCount"))
  493. +           conditions.add(new Adena(value));
  494. +       else if (nodeName.equals("minClanMembersCount"))
  495. +           conditions.add(new MinCMcount(value));
  496. +       else if (nodeName.equals("mustBeClanLeader"))
  497. +           conditions.add(new ClanLeader(value));
  498. +       else if (nodeName.equals("mustBeMarried"))
  499. +           conditions.add(new Marry(value));
  500. +       else if (nodeName.equals("itemAmmount"))
  501. +           conditions.add(new ItemsCount(value));
  502. +       else if (nodeName.equals("crpAmmount"))
  503. +           conditions.add(new Crp(value));
  504. +       else if (nodeName.equals("lordOfCastle"))
  505. +           conditions.add(new Castle(value));
  506. +       else if (nodeName.equals("mustBeMageClass"))
  507. +           conditions.add(new Mage(value));   
  508. +       else if (nodeName.equals("minSubclassCount"))
  509. +           conditions.add(new Sub(value));
  510. +       else if (nodeName.equals("CompleteAchievements"))
  511. +           conditions.add(new CompleteAchievements(value));
  512. +       else if (nodeName.equals("minSkillEnchant"))
  513. +           conditions.add(new SkillEnchant(value));
  514. +       else if (nodeName.equals("minOnlineTime"))
  515. +           conditions.add(new OnlineTime(value));
  516. +       else if (nodeName.equals("minHeroCount"))
  517. +           conditions.add(new HeroCount(value));
  518. +       else if (nodeName.equals("raidToKill"))
  519. +           conditions.add(new RaidKill(value));
  520. +       else if (nodeName.equals("raidToKill1"))
  521. +           conditions.add(new RaidKill(value));
  522. +       else if (nodeName.equals("raidToKill2"))
  523. +           conditions.add(new RaidKill(value));
  524. +       else if (nodeName.equals("minRaidPoints"))
  525. +           conditions.add(new RaidPoints(value));
  526. +       else if (nodeName.equals("eventKills"))
  527. +           conditions.add(new eventKills(value));
  528. +       else if (nodeName.equals("events"))
  529. +           conditions.add(new events(value));
  530. +       else if (nodeName.equals("eventWins"))
  531. +           conditions.add(new eventWins(value));
  532. +   }
  533. +  
  534. +   public void loadUsed()
  535. +   {
  536. +       Connection con = null;
  537. +       try
  538. +       {          
  539. +           PreparedStatement statement;
  540. +           ResultSet rs;
  541. +           con = L2DatabaseFactory.getInstance().getConnection();
  542. +           String sql = "SELECT ";
  543. +           for (int i=1; i <=getAchievementList().size(); i++)
  544. +           {
  545. +               if(i!=getAchievementList().size())
  546. +                sql=sql+"a"+i+",";
  547. +               else
  548. +                sql=sql+"a"+i;
  549. +              
  550. +           }
  551. +          
  552. +           sql=sql+" from achievements";
  553. +            statement = con.prepareStatement(sql);
  554. +          
  555. +           rs = statement.executeQuery();  
  556. +           while(rs.next())
  557. +           {
  558. +               for (int i=1; i <=getAchievementList().size(); i++)
  559. +               {
  560. +                   String ct=rs.getString(i);
  561. +                   if(ct.length()>1 &&  ct.startsWith("1"))
  562. +                   {
  563. +                       _binded.add(ct.substring(ct.indexOf("1")+1)+"@"+i);
  564. +                   }
  565. +               }
  566. +           }
  567. +           statement.close();
  568. +           rs.close();
  569. +       }
  570. +       catch (SQLException e)
  571. +       {
  572. +           _log.warning("[ACHIEVEMENTS SAVE GETDATA]" );
  573. +           e.printStackTrace();
  574. +       }
  575. +       finally
  576. +       {
  577. +           try
  578. +           {
  579. +               con.close();
  580. +           }
  581. +           catch (Exception e)
  582. +           {
  583. +           }
  584. +       }
  585. +   }
  586. +}
  587. \ No newline at end of file
  588. Index: java/Extensions/AchievmentsEngine/conditions/Karma.java
  589. ===================================================================
  590. --- java/Extensions/AchievmentsEngine/conditions/Karma.java (revision 0)
  591. +++ java/Extensions/AchievmentsEngine/conditions/Karma.java (working copy)
  592. @@ -0,0 +1,32 @@
  593. +package Extensions.AchievmentsEngine.conditions;
  594. +
  595. +import Extensions.AchievmentsEngine.base.Condition;
  596. +
  597. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  598. +
  599. +/**
  600. + *
  601. + *
  602. + */
  603. +public class Karma extends Condition
  604. +{
  605. +   public Karma(Object value)
  606. +   {
  607. +       super(value);
  608. +       setName("Karma Count");
  609. +   }
  610. +
  611. +   @Override
  612. +   public boolean meetConditionRequirements(L2PcInstance player)
  613. +   {
  614. +       if (getValue() == null)
  615. +           return false;
  616. +      
  617. +       int val = Integer.parseInt(getValue().toString());
  618. +      
  619. +       if (player.getKarma() >= val)
  620. +           return true;
  621. +      
  622. +       return false;
  623. +   }
  624. +}
  625. \ No newline at end of file
  626. Index: java/Extensions/AchievmentsEngine/conditions/eventKills.java
  627. ===================================================================
  628. --- java/Extensions/AchievmentsEngine/conditions/eventKills.java    (revision 0)
  629. +++ java/Extensions/AchievmentsEngine/conditions/eventKills.java    (working copy)
  630. @@ -0,0 +1,33 @@
  631. +package Extensions.AchievmentsEngine.conditions;
  632. +
  633. +import Extensions.AchievmentsEngine.base.Condition;
  634. +
  635. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  636. +
  637. +/**
  638. + *
  639. + *
  640. + */
  641. +public class eventKills extends Condition
  642. +{
  643. +   public eventKills(Object value)
  644. +   {
  645. +       super(value);
  646. +       setName("Event Kills");
  647. +   }
  648. +
  649. +   @Override
  650. +   public boolean meetConditionRequirements(L2PcInstance player)
  651. +   {
  652. +       if (getValue() == null)
  653. +           return false;
  654. +      
  655. +       @SuppressWarnings("unused")
  656. +       int val = Integer.parseInt(getValue().toString());
  657. +      
  658. +   //  if (EventStats.getInstance().getEventKills(player.getObjectId()) >= val)
  659. +   //      return true;
  660. +      
  661. +       return false;
  662. +   }
  663. +}
  664. \ No newline at end of file
  665. Index: java/Extensions/AchievmentsEngine/conditions/RaidPoints.java
  666. ===================================================================
  667. --- java/Extensions/AchievmentsEngine/conditions/RaidPoints.java    (revision 0)
  668. +++ java/Extensions/AchievmentsEngine/conditions/RaidPoints.java    (working copy)
  669. @@ -0,0 +1,52 @@
  670. +/*
  671. + * This program is free software; you can redistribute it and/or modify
  672. + * it under the terms of the GNU General Public License as published by
  673. + * the Free Software Foundation; either version 2, or (at your option)
  674. + * any later version.
  675. + *
  676. + * This program is distributed in the hope that it will be useful,
  677. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  678. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  679. + * GNU General Public License for more details.
  680. + *
  681. + * You should have received a copy of the GNU General Public License
  682. + * along with this program; if not, write to the Free Software
  683. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  684. + * 02111-1307, USA.
  685. + *
  686. + * http://www.gnu.org/copyleft/gpl.html
  687. + */
  688. +package Extensions.AchievmentsEngine.conditions;
  689. +
  690. +import Extensions.AchievmentsEngine.base.Condition;
  691. +
  692. +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
  693. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  694. +
  695. +/**
  696. + *
  697. + *
  698. + *
  699. + */
  700. +public class RaidPoints extends Condition
  701. +{
  702. +   public RaidPoints(Object value)
  703. +   {
  704. +       super(value);
  705. +       setName("Raid Points");
  706. +   }
  707. +
  708. +   @Override
  709. +   public boolean meetConditionRequirements(L2PcInstance player)
  710. +   {
  711. +       if (getValue() == null)
  712. +           return false;
  713. +      
  714. +       int val = Integer.parseInt(getValue().toString());
  715. +
  716. +       RaidBossPointsManager.getInstance();
  717. +       if(RaidBossPointsManager.getPointsByOwnerId(player.getObjectId())>=val)
  718. +           return true;
  719. +       return false;
  720. +   }
  721. +}
  722. \ No newline at end of file
  723. Index: java/Extensions/AchievmentsEngine/conditions/HeroCount.java
  724. ===================================================================
  725. --- java/Extensions/AchievmentsEngine/conditions/HeroCount.java (revision 0)
  726. +++ java/Extensions/AchievmentsEngine/conditions/HeroCount.java (working copy)
  727. @@ -0,0 +1,43 @@
  728. +package Extensions.AchievmentsEngine.conditions;
  729. +
  730. +import Extensions.AchievmentsEngine.base.Condition;
  731. +
  732. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  733. +import com.l2jhellas.gameserver.model.entity.Hero;
  734. +import com.l2jhellas.gameserver.model.entity.Olympiad;
  735. +import com.l2jhellas.gameserver.templates.StatsSet;
  736. +/**
  737. + *
  738. + *
  739. + *
  740. + */
  741. +public class HeroCount extends Condition
  742. +{
  743. +   public HeroCount(Object value)
  744. +   {
  745. +       super(value);
  746. +       setName("Hero Count");
  747. +   }
  748. +
  749. +   @Override
  750. +   public boolean meetConditionRequirements(L2PcInstance player)
  751. +   {
  752. +       if (getValue() == null)
  753. +           return false;
  754. +      
  755. +       int val = Integer.parseInt(getValue().toString());
  756. +       for(int hero: Hero.getInstance().getHeroes().keySet())
  757. +       {
  758. +           if(hero==player.getObjectId())
  759. +           {
  760. +               StatsSet sts = Hero.getInstance().getHeroes().get(hero);
  761. +               if(sts.getString(Olympiad.CHAR_NAME).equals(player.getName()))
  762. +               {
  763. +                   if(sts.getInteger(Hero.COUNT)>=val)
  764. +                       return true;
  765. +               }
  766. +           }
  767. +       }
  768. +       return false;
  769. +   }
  770. +}
  771. \ No newline at end of file
  772. Index: java/com/l2jhellas/gameserver/GameServer.java
  773. ===================================================================
  774. --- java/com/l2jhellas/gameserver/GameServer.java   (revision 218)
  775. +++ java/com/l2jhellas/gameserver/GameServer.java   (working copy)
  776. @@ -23,6 +23,7 @@
  777.  import java.util.logging.LogManager;
  778.  import java.util.logging.Logger;
  779.  
  780. +import Extensions.AchievmentsEngine.AchievementsManager;
  781.  import Extensions.Balancer.BalanceLoad;
  782.  import Extensions.RankSystem.PvpTable;
  783.  import Extensions.RankSystem.RankCharacterRewardTable;
  784. @@ -370,6 +371,7 @@
  785.  
  786.         Util.printSection("Customs");
  787.         // we could add general custom config?
  788. +       AchievementsManager.getInstance();
  789.         PcColorTable.getInstance();
  790.         MaxCheatersTable.getInstance();
  791.         Hitman.start();
  792. Index: java/Extensions/AchievmentsEngine/conditions/Castle.java
  793. ===================================================================
  794. --- java/Extensions/AchievmentsEngine/conditions/Castle.java    (revision 0)
  795. +++ java/Extensions/AchievmentsEngine/conditions/Castle.java    (working copy)
  796. @@ -0,0 +1,32 @@
  797. +package Extensions.AchievmentsEngine.conditions;
  798. +
  799. +import Extensions.AchievmentsEngine.base.Condition;
  800. +
  801. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  802. +
  803. +/**
  804. + *
  805. + *
  806. + */
  807. +public class Castle extends Condition
  808. +{
  809. +   public Castle(Object value)
  810. +   {
  811. +       super(value);
  812. +       setName("Have Castle");
  813. +   }
  814. +
  815. +   @Override
  816. +   public boolean meetConditionRequirements(L2PcInstance player)
  817. +   {
  818. +       if (getValue() == null)
  819. +           return false;
  820. +      
  821. +       if (player.getClan() != null)
  822. +       {
  823. +           if (player.isCastleLord(5) || player.isCastleLord(3) || player.isCastleLord(7))
  824. +               return true;
  825. +       }
  826. +       return false;
  827. +   }
  828. +}
  829. \ No newline at end of file
  830. Index: java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java
  831. ===================================================================
  832. --- java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (revision 218)
  833. +++ java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  834. @@ -16,6 +16,7 @@
  835.  import java.sql.PreparedStatement;
  836.  import java.sql.ResultSet;
  837.  import java.sql.SQLException;
  838. +import java.sql.Statement;
  839.  import java.util.Calendar;
  840.  import java.util.Collection;
  841.  import java.util.Date;
  842. @@ -32,6 +33,7 @@
  843.  
  844.  import javolution.util.FastList;
  845.  import javolution.util.FastMap;
  846. +import Extensions.AchievmentsEngine.AchievementsManager;
  847.  import Extensions.RaidEvent.L2EventChecks;
  848.  import Extensions.RaidEvent.L2RaidEvent;
  849.  import Extensions.RankSystem.RankPvpSystem;
  850. @@ -3274,7 +3276,134 @@
  851.             }
  852.         }
  853.     }
  854. -  
  855. +    /*
  856. +     * Conversion to long (Only For Achievement Manager)
  857. +     *
  858. +     */
  859. +    public void addItem(String process, int itemId, long countL, L2Object reference, boolean sendMessage)
  860. +    {      
  861. +            int count = 0;
  862. +            count = (int)countL;
  863. +            if(count!=countL)
  864. +            {
  865. +                    count = 1;
  866. +            }
  867. +          
  868. +            if(count > 0)
  869. +            {
  870. +                    // Sends message to client if requested
  871. +                    if(sendMessage && (!isCastingNow()
  872. +                                    && ItemTable.getInstance().createDummyItem(itemId).getItemType() == L2EtcItemType.HERB
  873. +                                    || ItemTable.getInstance().createDummyItem(itemId).getItemType() != L2EtcItemType.HERB))
  874. +                    {
  875. +                            if(count > 1)
  876. +                            {
  877. +                                    if(process.equalsIgnoreCase("sweep") || process.equalsIgnoreCase("Quest"))
  878. +                                    {
  879. +                                            SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
  880. +                                            sm.addItemName(itemId);
  881. +                                            sm.addNumber(count);
  882. +                                            sendPacket(sm);
  883. +                                            sm = null;
  884. +                                    }
  885. +                                    else
  886. +                                    {
  887. +                                            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
  888. +                                            sm.addItemName(itemId);
  889. +                                            sm.addNumber(count);
  890. +                                            sendPacket(sm);
  891. +                                            sm = null;
  892. +                                    }
  893. +                            }
  894. +                            else
  895. +                            {
  896. +                                    if(process.equalsIgnoreCase("sweep") || process.equalsIgnoreCase("Quest"))
  897. +                                    {
  898. +                                            SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
  899. +                                            sm.addItemName(itemId);
  900. +                                            sendPacket(sm);
  901. +                                            sm = null;
  902. +                                    }
  903. +                                    else
  904. +                                    {
  905. +                                            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1);
  906. +                                            sm.addItemName(itemId);
  907. +                                            sendPacket(sm);
  908. +                                            sm = null;
  909. +                                    }
  910. +                            }
  911. +                    }
  912. +                    //Auto use herbs - autoloot
  913. +                    if(ItemTable.getInstance().createDummyItem(itemId).getItemType() == L2EtcItemType.HERB) //If item is herb dont add it to iv :]
  914. +                    {
  915. +                            if(!isCastingNow())
  916. +                            {
  917. +                                    L2ItemInstance herb = new L2ItemInstance(_charId, itemId);
  918. +                                    IItemHandler handler = ItemHandler.getInstance().getItemHandler(herb.getItemId());
  919. +
  920. +                                    if(handler == null)
  921. +                                    {
  922. +                                            _log.warning("No item handler registered for Herb - item ID " + herb.getItemId() + ".");
  923. +                                    }
  924. +                                    else
  925. +                                    {
  926. +                                            handler.useItem(this, herb);
  927. +
  928. +                                            if(_herbstask >= 100)
  929. +                                            {
  930. +                                                    _herbstask -= 100;
  931. +                                            }
  932. +
  933. +                                            handler = null;
  934. +                                    }
  935. +
  936. +                                    herb = null;
  937. +                            }
  938. +                            else
  939. +                            {
  940. +                                    _herbstask += 100;
  941. +                                    ThreadPoolManager.getInstance().scheduleAi(new HerbTask(process, itemId, count, reference, sendMessage), _herbstask);
  942. +                            }
  943. +                    }
  944. +                    else
  945. +                    {
  946. +                            // Add the item to inventory
  947. +                            L2ItemInstance item = _inventory.addItem(process, itemId, count, this, reference);
  948. +
  949. +                            // Send inventory update packet
  950. +                            if(!Config.FORCE_INVENTORY_UPDATE)
  951. +                            {
  952. +                                    InventoryUpdate playerIU = new InventoryUpdate();
  953. +                                    playerIU.addItem(item);
  954. +                                    sendPacket(playerIU);
  955. +                                    playerIU = null;
  956. +                            }
  957. +                            else
  958. +                            {
  959. +                                    sendPacket(new ItemList(this, false));
  960. +                            }
  961. +
  962. +                            // Update current load as well
  963. +                            StatusUpdate su = new StatusUpdate(getObjectId());
  964. +                            su.addAttribute(StatusUpdate.CUR_LOAD, getCurrentLoad());
  965. +                            sendPacket(su);
  966. +                            su = null;
  967. +
  968. +                            // If over capacity, drop the item
  969. +                            if(!isGM() && !_inventory.validateCapacity(item))
  970. +                            {
  971. +                                    dropItem("InvDrop", item, null, true);
  972. +                            }
  973. +                            else if(CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
  974. +                            {
  975. +                                    CursedWeaponsManager.getInstance().activate(this, item);
  976. +                            }
  977. +
  978. +                            item = null;
  979. +                    }
  980. +            }
  981. +    }
  982. +    
  983.     /**
  984.      * Adds item to Inventory and send a Server->Client InventoryUpdate packet
  985.      * to the L2PcInstance.
  986. @@ -13319,4 +13448,127 @@
  987.         else
  988.             return;
  989.     }
  990. +private List<Integer> _completedAchievements = new FastList<>();
  991. +  
  992. +   public long getOnlineTime()
  993. +   {
  994. +       return _onlineTime;
  995. +   }
  996. +  
  997. +   public List<Integer> getCompletedAchievements()
  998. +   {
  999. +       return _completedAchievements;
  1000. +   }
  1001. +  
  1002. +   public boolean readyAchievementsList()
  1003. +   {
  1004. +       if (_completedAchievements.isEmpty())
  1005. +           return false;
  1006. +       return true;
  1007. +   }
  1008. +  
  1009. +   public void saveAchievemntData()
  1010. +   {
  1011. +          
  1012. +   }
  1013. +  
  1014. +   public void getAchievemntData()
  1015. +   {
  1016. +       Connection con = null;
  1017. +       try
  1018. +       {          
  1019. +           PreparedStatement statement;
  1020. +           PreparedStatement insertStatement;
  1021. +           ResultSet rs;
  1022. +           con = L2DatabaseFactory.getInstance().getConnection();
  1023. +              
  1024. +               statement = con.prepareStatement("SELECT * from achievements WHERE owner_id=" + getObjectId());
  1025. +              
  1026. +               rs = statement.executeQuery();  
  1027. +              
  1028. +               String values = "owner_id";
  1029. +               String in = Integer.toString(getObjectId());
  1030. +               String questionMarks = in;
  1031. +               int ilosc = AchievementsManager.getInstance().getAchievementList().size();
  1032. +              
  1033. +               if (rs.next())
  1034. +               {  
  1035. +                   _completedAchievements.clear();
  1036. +                   for (int i=1; i <=ilosc; i++)
  1037. +                   {
  1038. +                       int a = rs.getInt("a" + i);
  1039. +                      
  1040. +                       if (!_completedAchievements.contains(i))
  1041. +                           if (a == 1 || String.valueOf(a).startsWith("1"))
  1042. +                               _completedAchievements.add(i);
  1043. +                   }
  1044. +               }
  1045. +               else
  1046. +               {
  1047. +                   //Player hasnt entry in database, means we have to create it.
  1048. +                  
  1049. +                   for (int i=1; i <=ilosc; i++)
  1050. +                   {
  1051. +                       values += ", a" + i;
  1052. +                       questionMarks += ", 0";
  1053. +                   }
  1054. +                  
  1055. +                   String s = "INSERT INTO achievements(" + values + ") VALUES (" + questionMarks + ")";
  1056. +                   insertStatement = con.prepareStatement(s);
  1057. +                  
  1058. +                   insertStatement.execute();
  1059. +                   insertStatement.close();
  1060. +               }
  1061. +           }
  1062. +           catch (SQLException e)
  1063. +           {
  1064. +               _log.warning("[ACHIEVEMENTS ENGINE GETDATA]" + e);
  1065. +           }
  1066. +           finally
  1067. +           {
  1068. +               try
  1069. +               {
  1070. +                   con.close();
  1071. +               }
  1072. +               catch (Exception e)
  1073. +               {
  1074. +               }
  1075. +           }
  1076. +       }
  1077. +      
  1078. +   public void saveAchievementData(int achievementID,int objid)
  1079. +   {
  1080. +       Connection con = null;
  1081. +      
  1082. +       try
  1083. +       {          
  1084. +           con = L2DatabaseFactory.getInstance().getConnection();
  1085. +           Statement statement = con.createStatement();
  1086. +           if (achievementID==4 || achievementID==6 || achievementID==11 || achievementID==13)
  1087. +           {
  1088. +            statement.executeUpdate("UPDATE achievements SET a" + achievementID + "=1"+objid+" WHERE owner_id=" + getObjectId());
  1089. +           }
  1090. +           else
  1091. +               statement.executeUpdate("UPDATE achievements SET a" + achievementID + "=1 WHERE owner_id=" + getObjectId());
  1092. +          
  1093. +           statement.close();
  1094. +          
  1095. +           if (!_completedAchievements.contains(achievementID))
  1096. +               _completedAchievements.add(achievementID);
  1097. +       }
  1098. +       catch (SQLException e)
  1099. +       {
  1100. +           _log.warning("[ACHIEVEMENTS SAVE GETDATA]" + e);
  1101. +       }
  1102. +       finally
  1103. +       {
  1104. +           try
  1105. +           {
  1106. +               con.close();
  1107. +           }
  1108. +           catch (Exception e)
  1109. +           {
  1110. +           }
  1111. +       }
  1112. +   }
  1113.  }
  1114. Index: java/com/l2jhellas/gameserver/instancemanager/RaidBossPointsManager.java
  1115. ===================================================================
  1116. --- java/com/l2jhellas/gameserver/instancemanager/RaidBossPointsManager.java    (revision 218)
  1117. +++ java/com/l2jhellas/gameserver/instancemanager/RaidBossPointsManager.java    (working copy)
  1118. @@ -29,6 +29,7 @@
  1119.  import javolution.util.FastList;
  1120.  import javolution.util.FastMap;
  1121.  
  1122. +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
  1123.  import com.l2jhellas.Config;
  1124.  import com.l2jhellas.L2DatabaseFactory;
  1125.  import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1126. @@ -99,6 +100,11 @@
  1127.         }
  1128.     }
  1129.  
  1130. +   public static final RaidBossPointsManager getInstance()
  1131. +   {
  1132. +       return SingletonHolder._instance;
  1133. +   }
  1134. +  
  1135.     public final static void updatePointsInDB(L2PcInstance player, int raidId, int points)
  1136.     {
  1137.         Connection con = null;
  1138. @@ -278,4 +284,9 @@
  1139.  
  1140.         return tmpRanking;
  1141.     }
  1142. +  
  1143. +   private static class SingletonHolder
  1144. +   {
  1145. +       protected static final RaidBossPointsManager _instance = new RaidBossPointsManager();
  1146. +   }
  1147.  }
  1148. \ No newline at end of file
  1149. Index: java/Extensions/AchievmentsEngine/conditions/SkillEnchant.java
  1150. ===================================================================
  1151. --- java/Extensions/AchievmentsEngine/conditions/SkillEnchant.java  (revision 0)
  1152. +++ java/Extensions/AchievmentsEngine/conditions/SkillEnchant.java  (working copy)
  1153. @@ -0,0 +1,42 @@
  1154. +package Extensions.AchievmentsEngine.conditions;
  1155. +
  1156. +import Extensions.AchievmentsEngine.base.Condition;
  1157. +
  1158. +import com.l2jhellas.gameserver.model.L2Skill;
  1159. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1160. +
  1161. +/**
  1162. + *
  1163. + *
  1164. + *
  1165. + */
  1166. +public class SkillEnchant extends Condition
  1167. +{
  1168. +   public SkillEnchant(Object value)
  1169. +   {
  1170. +       super(value);
  1171. +       setName("Skill Enchant");
  1172. +   }
  1173. +
  1174. +   @Override
  1175. +   public boolean meetConditionRequirements(L2PcInstance player)
  1176. +   {
  1177. +       if (getValue() == null)
  1178. +           return false;
  1179. +      
  1180. +       int val = Integer.parseInt(getValue().toString());
  1181. +      
  1182. +       for(L2Skill s : player.getAllSkills())
  1183. +       {
  1184. +           String lvl = String.valueOf(s.getLevel());
  1185. +           if(lvl.length() > 2)
  1186. +           {
  1187. +               int sklvl = Integer.parseInt(lvl.substring(1));
  1188. +               if(sklvl>=val)
  1189. +                   return true;
  1190. +           }
  1191. +       }
  1192. +  
  1193. +       return false;
  1194. +   }
  1195. +}
  1196. \ No newline at end of file
  1197. Index: java/Extensions/AchievmentsEngine/base/Achievement.java
  1198. ===================================================================
  1199. --- java/Extensions/AchievmentsEngine/base/Achievement.java (revision 0)
  1200. +++ java/Extensions/AchievmentsEngine/base/Achievement.java (working copy)
  1201. @@ -0,0 +1,111 @@
  1202. +package Extensions.AchievmentsEngine.base;
  1203. +
  1204. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1205. +
  1206. +import java.util.logging.Logger;
  1207. +
  1208. +
  1209. +import javolution.util.FastList;
  1210. +import javolution.util.FastMap;
  1211. +
  1212. +/**
  1213. + *
  1214. + *
  1215. + */
  1216. +public class Achievement
  1217. +{
  1218. +   private int _id;
  1219. +   private String _name;
  1220. +   private String _reward;
  1221. +   private String _description = "No Description!";
  1222. +   private boolean _repeatable;
  1223. +  
  1224. +   private FastMap<Integer, Long> _rewardList;
  1225. +   private FastList<Condition> _conditions;
  1226. +  
  1227. +   private static Logger _log = Logger.getLogger(Achievement.class.getName());
  1228. +  
  1229. +   @SuppressWarnings("unused")
  1230. +   public Achievement(int id, String name, String description, String reward, boolean repeatable, FastList<Condition> conditions)
  1231. +   {
  1232. +       _rewardList = new FastMap<Integer, Long>();
  1233. +       _id = id;
  1234. +       _name = name;
  1235. +       _description = description;
  1236. +       _reward = reward;
  1237. +       _conditions = conditions;
  1238. +       _repeatable = repeatable;
  1239. +
  1240. +       createRewardList();
  1241. +   }
  1242. +  
  1243. +   private void createRewardList()
  1244. +   {
  1245. +       for (String s : _reward.split(";"))
  1246. +       {
  1247. +           if (s == null || s.isEmpty())
  1248. +               continue;
  1249. +          
  1250. +           String[] split = s.split(",");
  1251. +           Integer item = 0;
  1252. +           Long count = new Long(0);
  1253. +           try
  1254. +           {
  1255. +               item = Integer.valueOf(split[0]);
  1256. +               count = Long.valueOf(split[1]);
  1257. +           }
  1258. +           catch(NumberFormatException nfe)
  1259. +           {
  1260. +               _log.warning("[AchievementsEngine] Error: Wrong reward " + nfe);
  1261. +           }
  1262. +           _rewardList.put(item, count);
  1263. +       }
  1264. +   }
  1265. +  
  1266. +   public boolean meetAchievementRequirements(L2PcInstance player)
  1267. +   {
  1268. +       for (Condition c: getConditions())
  1269. +       {
  1270. +           if (!c.meetConditionRequirements(player))
  1271. +           {
  1272. +               return false;
  1273. +           }
  1274. +       }
  1275. +       return true;
  1276. +   }
  1277. +  
  1278. +   public int getID()
  1279. +   {
  1280. +       return _id;
  1281. +   }
  1282. +  
  1283. +   public String getName()
  1284. +   {
  1285. +       return _name;
  1286. +   }
  1287. +  
  1288. +   public String getDescription()
  1289. +   {
  1290. +       return _description;
  1291. +   }
  1292. +  
  1293. +   public String getReward()
  1294. +   {
  1295. +       return _reward;
  1296. +   }
  1297. +  
  1298. +   public boolean isRepeatable()
  1299. +   {
  1300. +       return _repeatable;
  1301. +   }
  1302. +  
  1303. +   public FastMap<Integer, Long> getRewardList()
  1304. +   {
  1305. +       return _rewardList;
  1306. +   }
  1307. +  
  1308. +   public FastList<Condition> getConditions()
  1309. +   {
  1310. +       return _conditions;
  1311. +   }
  1312. +}
  1313. \ No newline at end of file
  1314. Index: java/Extensions/AchievmentsEngine/conditions/Level.java
  1315. ===================================================================
  1316. --- java/Extensions/AchievmentsEngine/conditions/Level.java (revision 0)
  1317. +++ java/Extensions/AchievmentsEngine/conditions/Level.java (working copy)
  1318. @@ -0,0 +1,33 @@
  1319. +package Extensions.AchievmentsEngine.conditions;
  1320. +
  1321. +import Extensions.AchievmentsEngine.base.Condition;
  1322. +
  1323. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1324. +
  1325. +/**
  1326. + *
  1327. + *
  1328. + */
  1329. +public class Level extends Condition
  1330. +{
  1331. +   public Level(Object value)
  1332. +   {
  1333. +       super(value);
  1334. +       setName("Level");
  1335. +   }
  1336. +  
  1337. +   @Override
  1338. +   public boolean meetConditionRequirements(L2PcInstance player)
  1339. +   {
  1340. +       if (getValue() == null)
  1341. +           return false;
  1342. +       else
  1343. +       {
  1344. +           int val = Integer.parseInt(getValue().toString());
  1345. +          
  1346. +           if (player.getLevel() >= val)
  1347. +               return true;
  1348. +       }
  1349. +       return false;
  1350. +   }
  1351. +}
  1352. \ No newline at end of file
  1353. Index: java/Extensions/AchievmentsEngine/conditions/Adena.java
  1354. ===================================================================
  1355. --- java/Extensions/AchievmentsEngine/conditions/Adena.java (revision 0)
  1356. +++ java/Extensions/AchievmentsEngine/conditions/Adena.java (working copy)
  1357. @@ -0,0 +1,33 @@
  1358. +package Extensions.AchievmentsEngine.conditions;
  1359. +
  1360. +import Extensions.AchievmentsEngine.base.Condition;
  1361. +
  1362. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1363. +
  1364. +/**
  1365. + *
  1366. + *
  1367. + */
  1368. +public class Adena extends Condition
  1369. +{
  1370. +   public Adena(Object value)
  1371. +   {
  1372. +       super(value);
  1373. +       setName("Adena");
  1374. +   }
  1375. +
  1376. +   @Override
  1377. +   public boolean meetConditionRequirements(L2PcInstance player)
  1378. +   {
  1379. +       if (getValue() == null)
  1380. +           return false;
  1381. +       else
  1382. +       {
  1383. +           long val = Integer.parseInt(getValue().toString());
  1384. +          
  1385. +           if (player.getInventory().getAdena() >= val)
  1386. +               return true;
  1387. +       }
  1388. +       return false;
  1389. +   }
  1390. +}
  1391. \ No newline at end of file
  1392. Index: java/Extensions/AchievmentsEngine/conditions/Pk.java
  1393. ===================================================================
  1394. --- java/Extensions/AchievmentsEngine/conditions/Pk.java    (revision 0)
  1395. +++ java/Extensions/AchievmentsEngine/conditions/Pk.java    (working copy)
  1396. @@ -0,0 +1,32 @@
  1397. +package Extensions.AchievmentsEngine.conditions;
  1398. +
  1399. +import Extensions.AchievmentsEngine.base.Condition;
  1400. +
  1401. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1402. +
  1403. +/**
  1404. + *
  1405. + *
  1406. + */
  1407. +public class Pk extends Condition
  1408. +{
  1409. +   public Pk(Object value)
  1410. +   {
  1411. +       super(value);
  1412. +       setName("PK Count");
  1413. +   }
  1414. +
  1415. +   @Override
  1416. +   public boolean meetConditionRequirements(L2PcInstance player)
  1417. +   {
  1418. +       if (getValue() == null)
  1419. +           return false;
  1420. +      
  1421. +       int val = Integer.parseInt(getValue().toString());
  1422. +      
  1423. +       if (player.getPkKills() >= val)
  1424. +           return true;
  1425. +      
  1426. +       return false;
  1427. +   }
  1428. +}
  1429. \ No newline at end of file
  1430. Index: java/com/l2jhellas/gameserver/model/actor/instance/L2AchievementsInstance.java
  1431. ===================================================================
  1432. --- java/com/l2jhellas/gameserver/model/actor/instance/L2AchievementsInstance.java  (revision 0)
  1433. +++ java/com/l2jhellas/gameserver/model/actor/instance/L2AchievementsInstance.java  (working copy)
  1434. @@ -0,0 +1,338 @@
  1435. +package com.l2jhellas.gameserver.model.actor.instance;
  1436. +
  1437. +import com.l2jhellas.gameserver.skills.SkillTable;
  1438. +import com.l2jhellas.gameserver.model.L2Clan;
  1439. +import com.l2jhellas.gameserver.model.L2ItemInstance;
  1440. +import com.l2jhellas.gameserver.model.L2Skill;
  1441. +import com.l2jhellas.gameserver.model.actor.instance.L2NpcInstance;
  1442. +import Extensions.AchievmentsEngine.AchievementsManager;
  1443. +import Extensions.AchievmentsEngine.base.Achievement;
  1444. +import Extensions.AchievmentsEngine.base.Condition;
  1445. +import Extensions.AchievmentsEngine.conditions.WeaponEnchant;
  1446. +import com.l2jhellas.gameserver.model.Inventory;
  1447. +import com.l2jhellas.gameserver.network.serverpackets.NpcHtmlMessage;
  1448. +import com.l2jhellas.gameserver.templates.L2NpcTemplate;
  1449. +
  1450. +import java.util.StringTokenizer;
  1451. +
  1452. +import javolution.text.TextBuilder;
  1453. +
  1454. +
  1455. +/**
  1456. + *
  1457. + *
  1458. + */
  1459. +@SuppressWarnings("unused")
  1460. +public class L2AchievementsInstance extends L2NpcInstance
  1461. +{
  1462. +   public L2AchievementsInstance(int objectId, L2NpcTemplate template)
  1463. +   {
  1464. +       super(objectId, template);
  1465. +   }
  1466. +   private boolean first=true;
  1467. +   @Override
  1468. +   public void onBypassFeedback(L2PcInstance player, String command)
  1469. +   {
  1470. +       if (player == null)  
  1471. +       {
  1472. +           return;
  1473. +       }
  1474. +       if (command.startsWith("showMyAchievements"))
  1475. +       {          
  1476. +           player.getAchievemntData();
  1477. +           showMyAchievements(player);
  1478. +       }
  1479. +       else if (command.startsWith("achievementInfo"))
  1480. +       {          
  1481. +           StringTokenizer st = new StringTokenizer(command, " ");
  1482. +           st.nextToken();
  1483. +           int id = Integer.parseInt(st.nextToken());
  1484. +          
  1485. +           showAchievementInfo(id, player);
  1486. +       }
  1487. +       else if (command.startsWith("topList"))
  1488. +       {          
  1489. +           showTopListWindow(player);
  1490. +       }
  1491. +       else if (command.startsWith("showMainWindow"))
  1492. +       {
  1493. +           showChatWindow(player, 0);
  1494. +       }
  1495. +       else if (command.startsWith("getReward"))
  1496. +       {
  1497. +           StringTokenizer st = new StringTokenizer(command, " ");
  1498. +           st.nextToken();
  1499. +           int id = Integer.parseInt(st.nextToken());
  1500. +           if (id == 10)
  1501. +           {
  1502. +               player.destroyItemByItemId("", 8787, 200, this, true);
  1503. +               AchievementsManager.getInstance().rewardForAchievement(id, player);
  1504. +           }
  1505. +           else if(id==4 || id==19)
  1506. +           {
  1507. +             L2ItemInstance weapon = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  1508. +             if(weapon!=null)
  1509. +             {
  1510. +                 int objid = weapon.getObjectId();
  1511. +                 if(AchievementsManager.getInstance().getAchievementList().get(id).meetAchievementRequirements(player))
  1512. +                 {
  1513. +                  if(!AchievementsManager.getInstance().isBinded(objid,id))
  1514. +                  {
  1515. +                   AchievementsManager.getInstance().getBinded().add(objid+"@"+id);
  1516. +                   player.saveAchievementData(id,objid);
  1517. +                   AchievementsManager.getInstance().rewardForAchievement(id, player);
  1518. +                  }
  1519. +                  else
  1520. +                   player.sendMessage("This item was already used to earn this achievement");
  1521. +                 }
  1522. +                 else
  1523. +                 {
  1524. +                     player.sendMessage("Seems you don't meet the achievements requirements now.");
  1525. +                 }
  1526. +            }
  1527. +             else
  1528. +                 player.sendMessage("You must equip your weapon in order to get rewarded.");
  1529. +           }
  1530. +           else if(id==6 || id==18)
  1531. +           {
  1532. +             int clid = player.getClan().getClanId();
  1533. +            
  1534. +               if(!AchievementsManager.getInstance().isBinded(clid,id))
  1535. +                  {
  1536. +                   AchievementsManager.getInstance().getBinded().add(clid+"@"+id);
  1537. +                   player.saveAchievementData(id,clid);
  1538. +                   AchievementsManager.getInstance().rewardForAchievement(id, player);
  1539. +                  }
  1540. +               else
  1541. +                   player.sendMessage("Current clan was already rewarded for this achievement.");
  1542. +           }
  1543. +           else
  1544. +           {
  1545. +            player.saveAchievementData(id,0);
  1546. +            AchievementsManager.getInstance().rewardForAchievement(id, player);
  1547. +           }
  1548. +           showMyAchievements(player);
  1549. +       }
  1550. +       else if (command.startsWith ("showMyStats"))
  1551. +       {
  1552. +           showMyStatsWindow(player);
  1553. +       }
  1554. +       else if (command.startsWith("showHelpWindow"))
  1555. +       {
  1556. +           showHelpWindow(player);
  1557. +       }
  1558. +   }
  1559. +
  1560. +   @Override
  1561. +   public void showChatWindow(L2PcInstance player, int val)
  1562. +   {
  1563. +       if(first)
  1564. +       {
  1565. +           AchievementsManager.getInstance().loadUsed();
  1566. +           first=false;
  1567. +       }
  1568. +       TextBuilder tb = new TextBuilder();
  1569. +       tb.append("<html><title>Achievements Manager</title><body><center><br>");
  1570. +       tb.append("Hello <font color=\"LEVEL\">" + player.getName() + "</font><br>Are you looking for challenge?");
  1571. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
  1572. +       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>");
  1573. +       tb.append("<button value=\"Statistics\" action=\"bypass -h npc_%objectId%_showMyStats\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21>");
  1574. +       tb.append("<button value=\"Help\" action=\"bypass -h npc_%objectId%_showHelpWindow\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21>");
  1575. +      
  1576. +       NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  1577. +       msg.setHtml(tb.toString());
  1578. +       msg.replace("%objectId%", String.valueOf(this.getObjectId()));
  1579. +  
  1580. +       player.sendPacket(msg);
  1581. +   }
  1582. +  
  1583. +   private void showMyAchievements(L2PcInstance player)
  1584. +   {
  1585. +       TextBuilder tb = new TextBuilder();
  1586. +       tb.append("<html><title>Achievements Manager</title><body><br>");
  1587. +      
  1588. +       tb.append("<center><font color=\"LEVEL\">My achievements</font>:</center><br>");
  1589. +      
  1590. +       if (AchievementsManager.getInstance().getAchievementList().isEmpty())
  1591. +       {
  1592. +           tb.append("There are no Achievements created yet!");
  1593. +       }
  1594. +       else
  1595. +       {
  1596. +           int i = 0;
  1597. +          
  1598. +           tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
  1599. +           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>");
  1600. +           tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
  1601. +          
  1602. +           for (Achievement a: AchievementsManager.getInstance().getAchievementList().values())
  1603. +           {
  1604. +               tb.append(getTableColor(i));
  1605. +               tb.append("<tr><td width=270 align=\"left\">" + a.getName() + "</td><td width=50 align=\"right\"><a action=\"bypass -h npc_%objectId%_achievementInfo "
  1606. +               + a.getID() + "\">info</a></td><td width=200 align=\"center\">" + getStatusString(a.getID(), player) + "</td></tr></table>");
  1607. +               i++;
  1608. +           }
  1609. +          
  1610. +           tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1611. +           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>");
  1612. +       }
  1613. +      
  1614. +       NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  1615. +       msg.setHtml(tb.toString());
  1616. +       msg.replace("%objectId%", String.valueOf(this.getObjectId()));
  1617. +  
  1618. +       player.sendPacket(msg);
  1619. +   }
  1620. +  
  1621. +   private void showAchievementInfo(int achievementID, L2PcInstance player)
  1622. +   {
  1623. +       Achievement a = AchievementsManager.getInstance().getAchievementList().get(achievementID);
  1624. +      
  1625. +       TextBuilder tb = new TextBuilder();
  1626. +       tb.append("<html><title>Achievements Manager</title><body><br>");
  1627. +      
  1628. +       tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
  1629. +       tb.append("<tr><td width=270 align=\"center\">" + a.getName() + "</td></tr></table><br>");
  1630. +       tb.append("<center>Status: " + getStatusString(achievementID, player));
  1631. +      
  1632. +       if (a.meetAchievementRequirements(player) && !player.getCompletedAchievements().contains(achievementID))
  1633. +       {
  1634. +           tb.append("<button value=\"Receive Reward!\" action=\"bypass -h npc_%objectId%_getReward "
  1635. +           + a.getID() + "\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21>");
  1636. +       }
  1637. +      
  1638. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1639. +      
  1640. +       tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
  1641. +       tb.append("<tr><td width=270 align=\"center\">Description</td></tr></table><br>");
  1642. +       tb.append(a.getDescription());
  1643. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1644. +      
  1645. +       tb.append("<table width=270 border=0 bgcolor=\"33FF33\">");
  1646. +       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>");
  1647. +       tb.append(getConditionsStatus(achievementID, player));
  1648. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1649. +       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>");
  1650. +      
  1651. +       NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  1652. +       msg.setHtml(tb.toString());
  1653. +       msg.replace("%objectId%", String.valueOf(this.getObjectId()));
  1654. +  
  1655. +       player.sendPacket(msg);
  1656. +   }
  1657. +  
  1658. +   private void showMyStatsWindow(L2PcInstance player)
  1659. +   {
  1660. +       TextBuilder tb = new TextBuilder();
  1661. +       tb.append("<html><title>Achievements Manager</title><body><center><br>");
  1662. +       tb.append("Check your <font color=\"LEVEL\">Achievements </font>statistics:");
  1663. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
  1664. +      
  1665. +       player.getAchievemntData();
  1666. +       int completedCount = player.getCompletedAchievements().size();
  1667. +      
  1668. +       tb.append("You have completed: " + completedCount + "/<font color=\"LEVEL\">" + AchievementsManager.getInstance().getAchievementList().size() + "</font>");
  1669. +      
  1670. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1671. +       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>");
  1672. +      
  1673. +       NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  1674. +       msg.setHtml(tb.toString());
  1675. +       msg.replace("%objectId%", String.valueOf(this.getObjectId()));
  1676. +  
  1677. +       player.sendPacket(msg);
  1678. +   }
  1679. +  
  1680. +   private void showTopListWindow(L2PcInstance player)
  1681. +   {
  1682. +       TextBuilder tb = new TextBuilder();
  1683. +       tb.append("<html><title>Achievements Manager</title><body><center><br>");
  1684. +       tb.append("Check your <font color=\"LEVEL\">Achievements </font>Top List:");
  1685. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
  1686. +      
  1687. +       tb.append("Not implemented yet!");
  1688. +      
  1689. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1690. +       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>");
  1691. +      
  1692. +       NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  1693. +       msg.setHtml(tb.toString());
  1694. +       msg.replace("%objectId%", String.valueOf(this.getObjectId()));
  1695. +  
  1696. +       player.sendPacket(msg);
  1697. +   }
  1698. +  
  1699. +   private void showHelpWindow(L2PcInstance player)
  1700. +   {
  1701. +       TextBuilder tb = new TextBuilder();
  1702. +       tb.append("<html><title>Achievements Manager</title><body><center><br>");
  1703. +       tb.append("Achievements <font color=\"LEVEL\">Help </font>page:");
  1704. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1\"><br>");
  1705. +      
  1706. +       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>");
  1707. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1708. +       tb.append("<table><tr><td><font color=\"FF0000\">Not Completed</font> - you did not meet the achivement requirements.</td></tr>");
  1709. +       tb.append("<tr><td><font color=\"LEVEL\">Get Reward</font> - you may receive reward, click info.</td></tr>");
  1710. +       tb.append("<tr><td><font color=\"5EA82E\">Completed</font> - achievement completed, reward received.</td></tr></table>");
  1711. +      
  1712. +       tb.append("<br><img src=\"l2ui.squaregray\" width=\"270\" height=\"1s\"><br>");
  1713. +       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>");
  1714. +      
  1715. +       NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  1716. +       msg.setHtml(tb.toString());
  1717. +       msg.replace("%objectId%", String.valueOf(this.getObjectId()));
  1718. +  
  1719. +       player.sendPacket(msg);
  1720. +   }
  1721. +  
  1722. +   @SuppressWarnings("static-method")
  1723. +   private String getStatusString(int achievementID, L2PcInstance player)
  1724. +   {
  1725. +       if (player.getCompletedAchievements().contains(achievementID))
  1726. +       {
  1727. +           return "<font color=\"5EA82E\">Completed</font>";
  1728. +       }
  1729. +       else
  1730. +       {
  1731. +           if (AchievementsManager.getInstance().getAchievementList().get(achievementID).meetAchievementRequirements(player))
  1732. +           {
  1733. +               return "<font color=\"LEVEL\">Get Reward</font>";
  1734. +           }
  1735. +           else
  1736. +           {
  1737. +               return "<font color=\"FF0000\">Not Completed</font>";
  1738. +           }
  1739. +       }
  1740. +   }
  1741. +  
  1742. +   @SuppressWarnings("static-method")
  1743. +   private String getTableColor(int i)
  1744. +   {
  1745. +       if (i % 2 == 0)
  1746. +           return "<table width=270 border=0 bgcolor=\"444444\">";
  1747. +       else
  1748. +           return "<table width=270 border=0>";
  1749. +   }
  1750. +  
  1751. +   private String getConditionsStatus(int achievementID, L2PcInstance player)
  1752. +   {
  1753. +       int i = 0;
  1754. +       String s = "</center>";
  1755. +       Achievement a = AchievementsManager.getInstance().getAchievementList().get(achievementID);
  1756. +       String completed = "<font color=\"5EA82E\">Completed</font></td></tr></table>";
  1757. +       String notcompleted = "<font color=\"FF0000\">Not Completed</font></td></tr></table>";
  1758. +      
  1759. +       for (Condition c: a.getConditions())
  1760. +       {
  1761. +           s+= getTableColor(i);
  1762. +           s+= "<tr><td width=270 align=\"left\">" + c.getName() + "</td><td width=100 align=\"left\">" + c.getValue() + "</td><td width=200 align=\"center\">";
  1763. +           i++;
  1764. +          
  1765. +           if (c.meetConditionRequirements(player))
  1766. +               s+= completed;
  1767. +           else
  1768. +               s+= notcompleted;
  1769. +       }
  1770. +       return s;
  1771. +   }
  1772. +}
  1773. \ No newline at end of file
  1774. Index: java/Extensions/AchievmentsEngine/conditions/Marry.java
  1775. ===================================================================
  1776. --- java/Extensions/AchievmentsEngine/conditions/Marry.java (revision 0)
  1777. +++ java/Extensions/AchievmentsEngine/conditions/Marry.java (working copy)
  1778. @@ -0,0 +1,30 @@
  1779. +package Extensions.AchievmentsEngine.conditions;
  1780. +
  1781. +import Extensions.AchievmentsEngine.base.Condition;
  1782. +
  1783. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1784. +
  1785. +/**
  1786. + *
  1787. + *
  1788. + */
  1789. +public class Marry extends Condition
  1790. +{
  1791. +   public Marry(Object value)
  1792. +   {
  1793. +       super(value);
  1794. +       setName("Married");
  1795. +   }
  1796. +
  1797. +   @Override
  1798. +   public boolean meetConditionRequirements(L2PcInstance player)
  1799. +   {
  1800. +       if (getValue() == null)
  1801. +           return false;
  1802. +      
  1803. +       if (player.isMarried())
  1804. +           return true;
  1805. +          
  1806. +       return false;
  1807. +   }
  1808. +}
  1809. \ No newline at end of file
  1810. Index: java/com/l2jhellas/gameserver/model/entity/Siege.java
  1811. ===================================================================
  1812. --- java/com/l2jhellas/gameserver/model/entity/Siege.java   (revision 218)
  1813. +++ java/com/l2jhellas/gameserver/model/entity/Siege.java   (working copy)
  1814. @@ -36,6 +36,7 @@
  1815.  import com.l2jhellas.gameserver.instancemanager.SiegeReward;
  1816.  import com.l2jhellas.gameserver.model.L2Character;
  1817.  import com.l2jhellas.gameserver.model.L2Clan;
  1818. +import com.l2jhellas.gameserver.model.L2ClanMember;
  1819.  import com.l2jhellas.gameserver.model.L2Object;
  1820.  import com.l2jhellas.gameserver.model.L2SiegeClan;
  1821.  import com.l2jhellas.gameserver.model.L2SiegeClan.SiegeClanType;
  1822. @@ -267,6 +268,16 @@
  1823.                 _siegeGuardManager.removeMercs();
  1824.             getCastle().spawnDoor(); // Respawn door to castle
  1825.             getCastle().getZone().updateZoneStatusForCharactersInside();
  1826. +           L2Clan clan = ClanTable.getInstance().getClan(getCastle().getOwnerId());
  1827. +           for (L2ClanMember member : clan.getMembers())
  1828. +           {
  1829. +               if (member != null)
  1830. +               {
  1831. +                   L2PcInstance player = member.getPlayerInstance();
  1832. +                   if (player != null && player.isNoble())
  1833. +                       Hero.getInstance().setCastleTaken(player.getObjectId(), getCastle().getCastleId());
  1834. +               }
  1835. +           }
  1836.         }
  1837.     }
  1838.  
  1839. Index: java/Extensions/AchievmentsEngine/conditions/ClanLeader.java
  1840. ===================================================================
  1841. --- java/Extensions/AchievmentsEngine/conditions/ClanLeader.java    (revision 0)
  1842. +++ java/Extensions/AchievmentsEngine/conditions/ClanLeader.java    (working copy)
  1843. @@ -0,0 +1,31 @@
  1844. +package Extensions.AchievmentsEngine.conditions;
  1845. +
  1846. +import Extensions.AchievmentsEngine.base.Condition;
  1847. +
  1848. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1849. +
  1850. +/**
  1851. + *
  1852. + *
  1853. + */
  1854. +public class ClanLeader extends Condition
  1855. +{
  1856. +   public ClanLeader(Object value)
  1857. +   {
  1858. +       super(value);
  1859. +       setName("Be Clan Leader");
  1860. +   }
  1861. +
  1862. +   @Override
  1863. +   public boolean meetConditionRequirements(L2PcInstance player)
  1864. +   {
  1865. +       if (getValue() == null)
  1866. +           return false;
  1867. +      
  1868. +       if (player.getClan() != null)
  1869. +           if (player.isClanLeader())
  1870. +               return true;
  1871. +      
  1872. +       return false;
  1873. +   }
  1874. +}
  1875. \ No newline at end of file
  1876. Index: java/Extensions/AchievmentsEngine/conditions/eventWins.java
  1877. ===================================================================
  1878. --- java/Extensions/AchievmentsEngine/conditions/eventWins.java (revision 0)
  1879. +++ java/Extensions/AchievmentsEngine/conditions/eventWins.java (working copy)
  1880. @@ -0,0 +1,33 @@
  1881. +package Extensions.AchievmentsEngine.conditions;
  1882. +
  1883. +import Extensions.AchievmentsEngine.base.Condition;
  1884. +
  1885. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1886. +
  1887. +/**
  1888. + *
  1889. + *
  1890. + */
  1891. +public class eventWins extends Condition
  1892. +{
  1893. +   public eventWins(Object value)
  1894. +   {
  1895. +       super(value);
  1896. +       setName("Event Wins");
  1897. +   }
  1898. +
  1899. +   @Override
  1900. +   public boolean meetConditionRequirements(L2PcInstance player)
  1901. +   {
  1902. +       if (getValue() == null)
  1903. +           return false;
  1904. +      
  1905. +       @SuppressWarnings("unused")
  1906. +       int val = Integer.parseInt(getValue().toString());
  1907. +      
  1908. +       //if (EventStats.getInstance().getEventWins(player.getObjectId()) >= val)
  1909. +       //  return true;
  1910. +      
  1911. +       return false;
  1912. +   }
  1913. +}
  1914. \ No newline at end of file
  1915. Index: java/Extensions/AchievmentsEngine/conditions/Crp.java
  1916. ===================================================================
  1917. --- java/Extensions/AchievmentsEngine/conditions/Crp.java   (revision 0)
  1918. +++ java/Extensions/AchievmentsEngine/conditions/Crp.java   (working copy)
  1919. @@ -0,0 +1,34 @@
  1920. +package Extensions.AchievmentsEngine.conditions;
  1921. +
  1922. +import Extensions.AchievmentsEngine.base.Condition;
  1923. +
  1924. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  1925. +
  1926. +/**
  1927. + *
  1928. + *
  1929. + */
  1930. +public class Crp extends Condition
  1931. +{
  1932. +   public Crp(Object value)
  1933. +   {
  1934. +       super(value);
  1935. +       setName("Clan Reputation");
  1936. +   }
  1937. +
  1938. +   @Override
  1939. +   public boolean meetConditionRequirements(L2PcInstance player)
  1940. +   {
  1941. +       if (getValue() == null)
  1942. +           return false;
  1943. +      
  1944. +       if (player.getClan() != null)
  1945. +       {
  1946. +           int val = Integer.parseInt(getValue().toString());
  1947. +          
  1948. +           if (player.getClan().getReputationScore() >= val)
  1949. +               return true;
  1950. +       }
  1951. +       return false;
  1952. +   }
  1953. +}
  1954. \ No newline at end of file
  1955. Index: java/com/l2jhellas/gameserver/model/actor/instance/L2RaidBossInstance.java
  1956. ===================================================================
  1957. --- java/com/l2jhellas/gameserver/model/actor/instance/L2RaidBossInstance.java  (revision 218)
  1958. +++ java/com/l2jhellas/gameserver/model/actor/instance/L2RaidBossInstance.java  (working copy)
  1959. @@ -15,9 +15,11 @@
  1960.  package com.l2jhellas.gameserver.model.actor.instance;
  1961.  
  1962.  import com.l2jhellas.gameserver.ThreadPoolManager;
  1963. +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
  1964.  import com.l2jhellas.gameserver.instancemanager.RaidBossSpawnManager;
  1965.  import com.l2jhellas.gameserver.model.L2Character;
  1966.  import com.l2jhellas.gameserver.model.L2Spawn;
  1967. +import com.l2jhellas.gameserver.model.entity.Hero;
  1968.  import com.l2jhellas.gameserver.network.SystemMessageId;
  1969.  import com.l2jhellas.gameserver.network.serverpackets.SystemMessage;
  1970.  import com.l2jhellas.gameserver.templates.L2NpcTemplate;
  1971. @@ -68,8 +70,19 @@
  1972.             return false;
  1973.         if(killer instanceof L2PlayableInstance)
  1974.          {
  1975. -           SystemMessage msg = new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL);
  1976. -           broadcastPacket(msg);
  1977. +           if (killer.isInParty())
  1978. +           {
  1979. +               for (L2PcInstance member : killer.getParty().getPartyMembers())
  1980. +               {
  1981. +                   Hero.getInstance().setRBkilled(member.getObjectId(), getNpcId());
  1982. +               }
  1983. +           }
  1984. +           else
  1985. +           {
  1986. +               Hero.getInstance().setRBkilled(killer.getObjectId(), getNpcId());
  1987. +           }
  1988. +       SystemMessage msg = new SystemMessage(SystemMessageId.RAID_WAS_SUCCESSFUL);
  1989. +        broadcastPacket(msg);
  1990.          }
  1991.  
  1992.          RaidBossSpawnManager.getInstance().updateStatus(this, true);
  1993. Index: java/Extensions/AchievmentsEngine/conditions/Mage.java
  1994. ===================================================================
  1995. --- java/Extensions/AchievmentsEngine/conditions/Mage.java  (revision 0)
  1996. +++ java/Extensions/AchievmentsEngine/conditions/Mage.java  (working copy)
  1997. @@ -0,0 +1,30 @@
  1998. +package Extensions.AchievmentsEngine.conditions;
  1999. +
  2000. +import Extensions.AchievmentsEngine.base.Condition;
  2001. +
  2002. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2003. +
  2004. +/**
  2005. + *
  2006. + *
  2007. + */
  2008. +public class Mage extends Condition
  2009. +{
  2010. +   public Mage(Object value)
  2011. +   {
  2012. +       super(value);
  2013. +       setName("Be Mage");
  2014. +   }
  2015. +
  2016. +   @Override
  2017. +   public boolean meetConditionRequirements(L2PcInstance player)
  2018. +   {
  2019. +       if (getValue() == null)
  2020. +           return false;
  2021. +      
  2022. +       if (player.isMageClass())
  2023. +           return true;
  2024. +          
  2025. +       return false;
  2026. +   }
  2027. +}
  2028. \ No newline at end of file
  2029. Index: java/Extensions/AchievmentsEngine/conditions/MinCMcount.java
  2030. ===================================================================
  2031. --- java/Extensions/AchievmentsEngine/conditions/MinCMcount.java    (revision 0)
  2032. +++ java/Extensions/AchievmentsEngine/conditions/MinCMcount.java    (working copy)
  2033. @@ -0,0 +1,34 @@
  2034. +package Extensions.AchievmentsEngine.conditions;
  2035. +
  2036. +import Extensions.AchievmentsEngine.base.Condition;
  2037. +
  2038. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2039. +
  2040. +/**
  2041. + *
  2042. + *
  2043. + */
  2044. +public class MinCMcount extends Condition
  2045. +{
  2046. +   public MinCMcount(Object value)
  2047. +   {
  2048. +       super(value);
  2049. +       setName("Clan Members Count");
  2050. +   }
  2051. +
  2052. +   @Override
  2053. +   public boolean meetConditionRequirements(L2PcInstance player)
  2054. +   {
  2055. +       if (getValue() == null)
  2056. +           return false;
  2057. +      
  2058. +       if (player.getClan() != null)
  2059. +       {
  2060. +           int val = Integer.parseInt(getValue().toString());
  2061. +          
  2062. +           if (player.getClan().getMembersCount() >= val)
  2063. +               return true;
  2064. +       }
  2065. +       return false;
  2066. +   }
  2067. +}
  2068. \ No newline at end of file
  2069. Index: java/Extensions/AchievmentsEngine/conditions/CompleteAchievements.java
  2070. ===================================================================
  2071. --- java/Extensions/AchievmentsEngine/conditions/CompleteAchievements.java  (revision 0)
  2072. +++ java/Extensions/AchievmentsEngine/conditions/CompleteAchievements.java  (working copy)
  2073. @@ -0,0 +1,32 @@
  2074. +package Extensions.AchievmentsEngine.conditions;
  2075. +
  2076. +import Extensions.AchievmentsEngine.base.Condition;
  2077. +
  2078. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2079. +
  2080. +/**
  2081. + *
  2082. + *
  2083. + */
  2084. +public class CompleteAchievements extends Condition
  2085. +{
  2086. +   public CompleteAchievements(Object value)
  2087. +   {
  2088. +       super(value);
  2089. +       setName("Complete Achievements");
  2090. +   }
  2091. +
  2092. +   @Override
  2093. +   public boolean meetConditionRequirements(L2PcInstance player)
  2094. +   {
  2095. +       if (getValue() == null)
  2096. +           return false;
  2097. +      
  2098. +       int val = Integer.parseInt(getValue().toString());
  2099. +      
  2100. +       if (player.getCompletedAchievements().size() >= val)
  2101. +           return true;
  2102. +          
  2103. +       return false;
  2104. +   }
  2105. +}
  2106. \ No newline at end of file
  2107. Index: java/Extensions/AchievmentsEngine/conditions/OnlineTime.java
  2108. ===================================================================
  2109. --- java/Extensions/AchievmentsEngine/conditions/OnlineTime.java    (revision 0)
  2110. +++ java/Extensions/AchievmentsEngine/conditions/OnlineTime.java    (working copy)
  2111. @@ -0,0 +1,34 @@
  2112. +package Extensions.AchievmentsEngine.conditions;
  2113. +
  2114. +import Extensions.AchievmentsEngine.base.Condition;
  2115. +
  2116. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2117. +
  2118. +/**
  2119. + *
  2120. + *
  2121. + *
  2122. + */
  2123. +public class OnlineTime extends Condition
  2124. +{
  2125. +   public OnlineTime(Object value)
  2126. +   {
  2127. +       super(value);
  2128. +       setName("Online Time");
  2129. +   }
  2130. +
  2131. +   @Override
  2132. +   public boolean meetConditionRequirements(L2PcInstance player)
  2133. +   {
  2134. +       if (getValue() == null)
  2135. +           return false;
  2136. +      
  2137. +       int val = Integer.parseInt(getValue().toString());
  2138. +      
  2139. +        if(player.getOnlineTime()>=val*24*60*60*1000)
  2140. +        {
  2141. +         return true;
  2142. +       }
  2143. +       return false;
  2144. +   }
  2145. +}
  2146. \ No newline at end of file
  2147. Index: java/com/l2jhellas/gameserver/model/entity/Hero.java
  2148. ===================================================================
  2149. --- java/com/l2jhellas/gameserver/model/entity/Hero.java    (revision 218)
  2150. +++ java/com/l2jhellas/gameserver/model/entity/Hero.java    (working copy)
  2151. @@ -18,17 +18,23 @@
  2152.  import java.sql.PreparedStatement;
  2153.  import java.sql.ResultSet;
  2154.  import java.sql.SQLException;
  2155. +import java.text.SimpleDateFormat;
  2156.  import java.util.Arrays;
  2157. +import java.util.Date;
  2158.  import java.util.List;
  2159.  import java.util.Map;
  2160.  import java.util.logging.Level;
  2161.  import java.util.logging.Logger;
  2162.  
  2163. +import javolution.util.FastList;
  2164.  import javolution.util.FastMap;
  2165.  
  2166.  import com.l2jhellas.Config;
  2167.  import com.l2jhellas.L2DatabaseFactory;
  2168. +import com.l2jhellas.gameserver.datatables.sql.CharNameTable;
  2169.  import com.l2jhellas.gameserver.datatables.sql.ClanTable;
  2170. +import com.l2jhellas.gameserver.datatables.sql.NpcTable;
  2171. +import com.l2jhellas.gameserver.instancemanager.CastleManager;
  2172.  import com.l2jhellas.gameserver.model.L2Clan;
  2173.  import com.l2jhellas.gameserver.model.L2ItemInstance;
  2174.  import com.l2jhellas.gameserver.model.L2World;
  2175. @@ -39,6 +45,7 @@
  2176.  import com.l2jhellas.gameserver.network.serverpackets.SystemMessage;
  2177.  import com.l2jhellas.gameserver.network.serverpackets.UserInfo;
  2178.  import com.l2jhellas.gameserver.templates.L2Item;
  2179. +import com.l2jhellas.gameserver.templates.L2NpcTemplate;
  2180.  import com.l2jhellas.gameserver.templates.StatsSet;
  2181.  
  2182.  
  2183. @@ -60,11 +67,18 @@
  2184.              "(6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621) " +
  2185.   "AND owner_id NOT IN (SELECT obj_Id FROM characters WHERE accesslevel > 0)";
  2186.  
  2187. +   private static final String GET_DIARIES = "SELECT * FROM  heroes_diary WHERE char_id=? ORDER BY time ASC";
  2188. +   private static final String UPDATE_DIARIES = "INSERT INTO heroes_diary (char_id, time, action, param) values(?,?,?,?)";
  2189. +
  2190. +    
  2191.      private static final int[] _heroItems = {6842, 6611, 6612, 6613, 6614, 6615, 6616,
  2192.                                               6617, 6618, 6619, 6620, 6621
  2193.      };
  2194.      private static Map<Integer, StatsSet> _heroes;
  2195.      private static Map<Integer, StatsSet> _completeHeroes;
  2196. +    
  2197. +   private static Map<Integer, List<StatsSet>> _herodiary;
  2198. +   private static List<StatsSet> _diary;
  2199.  
  2200.      public static final String COUNT = "count";
  2201.      public static final String PLAYED = "played";
  2202. @@ -73,6 +87,10 @@
  2203.      public static final String ALLY_NAME = "ally_name";
  2204.      public static final String ALLY_CREST = "ally_crest";
  2205.  
  2206. +   public static final int ACTION_RAID_KILLED = 1;
  2207. +   public static final int ACTION_HERO_GAINED = 2;
  2208. +   public static final int ACTION_CASTLE_TAKEN = 3;
  2209. +    
  2210.      public static Hero getInstance()
  2211.      {
  2212.          if (_instance == null)
  2213. @@ -89,7 +107,8 @@
  2214.      {
  2215.          _heroes = new FastMap<Integer, StatsSet>();
  2216.          _completeHeroes = new FastMap<Integer, StatsSet>();
  2217. -
  2218. +        _herodiary = new FastMap<>();
  2219. +        
  2220.          PreparedStatement statement;
  2221.          PreparedStatement statement2;
  2222.  
  2223. @@ -539,4 +558,133 @@
  2224.              try{con.close();}catch(SQLException e){e.printStackTrace();}
  2225.          }
  2226.      }
  2227. +    
  2228. +   public void setDiaryData(int charId, int action, int param)
  2229. +   {
  2230. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  2231. +       {
  2232. +           PreparedStatement statement = con.prepareStatement(UPDATE_DIARIES);
  2233. +           statement.setInt(1, charId);
  2234. +           statement.setLong(2, System.currentTimeMillis());
  2235. +           statement.setInt(3, action);
  2236. +           statement.setInt(4, param);
  2237. +           statement.execute();
  2238. +           statement.close();
  2239. +       }
  2240. +       catch (SQLException e)
  2241. +       {
  2242. +           if (_log.isLoggable(Level.SEVERE))
  2243. +               _log.log(Level.SEVERE, "SQL exception while saving DiaryData.", e);
  2244. +       }
  2245. +   }
  2246. +  
  2247. +   public void loadDiary(int charId)
  2248. +   {
  2249. +       _diary = new FastList<>();
  2250. +      
  2251. +       int diaryentries = 0;
  2252. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  2253. +       {
  2254. +           PreparedStatement statement = con.prepareStatement(GET_DIARIES);
  2255. +           statement.setInt(1, charId);
  2256. +           ResultSet rset = statement.executeQuery();
  2257. +          
  2258. +           while (rset.next())
  2259. +           {
  2260. +               StatsSet _diaryentry = new StatsSet();
  2261. +              
  2262. +               long time = rset.getLong("time");
  2263. +               int action = rset.getInt("action");
  2264. +               int param = rset.getInt("param");
  2265. +              
  2266. +               String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(time));
  2267. +               _diaryentry.set("date", date);
  2268. +              
  2269. +               if (action == ACTION_RAID_KILLED)
  2270. +               {
  2271. +                   L2NpcTemplate template = NpcTable.getInstance().getTemplate(param);
  2272. +                   if (template != null)
  2273. +                       _diaryentry.set("action", template.getName() + " was defeated");
  2274. +               }
  2275. +               else if (action == ACTION_HERO_GAINED)
  2276. +                   _diaryentry.set("action", "Gained Hero status");
  2277. +               else if (action == ACTION_CASTLE_TAKEN)
  2278. +               {
  2279. +                   Castle castle = CastleManager.getInstance().getCastleById(param);
  2280. +                   if (castle != null)
  2281. +                       _diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
  2282. +               }
  2283. +               _diary.add(_diaryentry);
  2284. +               diaryentries++;
  2285. +           }
  2286. +           rset.close();
  2287. +           statement.close();
  2288. +          
  2289. +           _herodiary.put(charId, _diary);
  2290. +          
  2291. +           _log.info("Hero System: Loaded " + diaryentries + " diary entries for Hero: " + CharNameTable.getInstance().getNameById(charId));
  2292. +       }
  2293. +       catch (SQLException e)
  2294. +       {
  2295. +           _log.warning("Hero System: Couldnt load Hero Diary for char_id: " + charId);
  2296. +           if (Config.DEBUG)
  2297. +               _log.log(Level.WARNING, "", e);
  2298. +       }
  2299. +   }
  2300. +  
  2301. +   public void setRBkilled(int charId, int npcId)
  2302. +   {
  2303. +       setDiaryData(charId, ACTION_RAID_KILLED, npcId);
  2304. +      
  2305. +       L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
  2306. +      
  2307. +       if (_herodiary.containsKey(charId) && (template != null))
  2308. +       {
  2309. +           // Get Data
  2310. +           List<StatsSet> _list = _herodiary.get(charId);
  2311. +          
  2312. +           // Clear old data
  2313. +           _herodiary.remove(charId);
  2314. +          
  2315. +           // Prepare new data
  2316. +           StatsSet _diaryentry = new StatsSet();
  2317. +           String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
  2318. +           _diaryentry.set("date", date);
  2319. +           _diaryentry.set("action", template.getName() + " was defeated");
  2320. +          
  2321. +           // Add to old list
  2322. +           _list.add(_diaryentry);
  2323. +          
  2324. +           // Put new list into diary
  2325. +           _herodiary.put(charId, _list);
  2326. +       }
  2327. +   }
  2328. +  
  2329. +   public void setCastleTaken(int charId, int castleId)
  2330. +   {
  2331. +       setDiaryData(charId, ACTION_CASTLE_TAKEN, castleId);
  2332. +      
  2333. +       Castle castle = CastleManager.getInstance().getCastleById(castleId);
  2334. +      
  2335. +       if (_herodiary.containsKey(charId) && (castle != null))
  2336. +       {
  2337. +           // Get Data
  2338. +           List<StatsSet> _list = _herodiary.get(charId);
  2339. +          
  2340. +           // Clear old data
  2341. +           _herodiary.remove(charId);
  2342. +          
  2343. +           // Prepare new data
  2344. +           StatsSet _diaryentry = new StatsSet();
  2345. +           String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
  2346. +           _diaryentry.set("date", date);
  2347. +           _diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
  2348. +          
  2349. +           // Add to old list
  2350. +           _list.add(_diaryentry);
  2351. +          
  2352. +           // Put new list into diary
  2353. +           _herodiary.put(charId, _list);
  2354. +       }
  2355. +   }
  2356.  }
  2357. Index: java/Extensions/AchievmentsEngine/conditions/ClanLevel.java
  2358. ===================================================================
  2359. --- java/Extensions/AchievmentsEngine/conditions/ClanLevel.java (revision 0)
  2360. +++ java/Extensions/AchievmentsEngine/conditions/ClanLevel.java (working copy)
  2361. @@ -0,0 +1,34 @@
  2362. +package Extensions.AchievmentsEngine.conditions;
  2363. +
  2364. +import Extensions.AchievmentsEngine.base.Condition;
  2365. +
  2366. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2367. +
  2368. +/**
  2369. + *
  2370. + *
  2371. + */
  2372. +public class ClanLevel extends Condition
  2373. +{
  2374. +   public ClanLevel(Object value)
  2375. +   {
  2376. +       super(value);
  2377. +       setName("Clan Level");
  2378. +   }
  2379. +
  2380. +   @Override
  2381. +   public boolean meetConditionRequirements(L2PcInstance player)
  2382. +   {
  2383. +       if (getValue() == null)
  2384. +           return false;
  2385. +      
  2386. +       if (player.getClan() != null)
  2387. +       {
  2388. +           int val = Integer.parseInt(getValue().toString());
  2389. +          
  2390. +           if (player.getClan().getLevel() >= val)
  2391. +               return true;
  2392. +       }
  2393. +       return false;
  2394. +   }
  2395. +}
  2396. \ No newline at end of file
  2397. Index: java/Extensions/AchievmentsEngine/base/Condition.java
  2398. ===================================================================
  2399. --- java/Extensions/AchievmentsEngine/base/Condition.java   (revision 0)
  2400. +++ java/Extensions/AchievmentsEngine/base/Condition.java   (working copy)
  2401. @@ -0,0 +1,35 @@
  2402. +package Extensions.AchievmentsEngine.base;
  2403. +
  2404. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2405. +
  2406. +/**
  2407. + *
  2408. + *
  2409. + */
  2410. +public abstract class Condition
  2411. +{
  2412. +   private Object _value;
  2413. +   private String _name;
  2414. +  
  2415. +   public Condition(Object value)
  2416. +   {
  2417. +       _value = value;
  2418. +   }
  2419. +  
  2420. +   public abstract boolean meetConditionRequirements(L2PcInstance player);
  2421. +  
  2422. +   public Object getValue()
  2423. +   {
  2424. +       return _value;
  2425. +   }
  2426. +  
  2427. +   public void setName(String s)
  2428. +   {
  2429. +       _name = s;
  2430. +   }
  2431. +  
  2432. +   public String getName()
  2433. +   {
  2434. +       return _name;
  2435. +   }
  2436. +}
  2437. \ No newline at end of file
  2438. Index: java/Extensions/AchievmentsEngine/conditions/Sub.java
  2439. ===================================================================
  2440. --- java/Extensions/AchievmentsEngine/conditions/Sub.java   (revision 0)
  2441. +++ java/Extensions/AchievmentsEngine/conditions/Sub.java   (working copy)
  2442. @@ -0,0 +1,32 @@
  2443. +package Extensions.AchievmentsEngine.conditions;
  2444. +
  2445. +import Extensions.AchievmentsEngine.base.Condition;
  2446. +
  2447. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2448. +
  2449. +/**
  2450. + *
  2451. + *
  2452. + */
  2453. +public class Sub extends Condition
  2454. +{
  2455. +   public Sub(Object value)
  2456. +   {
  2457. +       super(value);
  2458. +       setName("Subclass Count");
  2459. +   }
  2460. +
  2461. +   @Override
  2462. +   public boolean meetConditionRequirements(L2PcInstance player)
  2463. +   {
  2464. +       if (getValue() == null)
  2465. +           return false;
  2466. +      
  2467. +       int val = Integer.parseInt(getValue().toString());
  2468. +      
  2469. +       if (player.getSubClasses().size() >= val)
  2470. +           return true;
  2471. +      
  2472. +       return false;
  2473. +   }
  2474. +}
  2475. \ No newline at end of file
  2476. Index: java/Extensions/AchievmentsEngine/conditions/RaidKill.java
  2477. ===================================================================
  2478. --- java/Extensions/AchievmentsEngine/conditions/RaidKill.java  (revision 0)
  2479. +++ java/Extensions/AchievmentsEngine/conditions/RaidKill.java  (working copy)
  2480. @@ -0,0 +1,64 @@
  2481. +/*
  2482. + * This program is free software; you can redistribute it and/or modify
  2483. + * it under the terms of the GNU General Public License as published by
  2484. + * the Free Software Foundation; either version 2, or (at your option)
  2485. + * any later version.
  2486. + *
  2487. + * This program is distributed in the hope that it will be useful,
  2488. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2489. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2490. + * GNU General Public License for more details.
  2491. + *
  2492. + * You should have received a copy of the GNU General Public License
  2493. + * along with this program; if not, write to the Free Software
  2494. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  2495. + * 02111-1307, USA.
  2496. + *
  2497. + * http://www.gnu.org/copyleft/gpl.html
  2498. + */
  2499. +package Extensions.AchievmentsEngine.conditions;
  2500. +
  2501. +import Extensions.AchievmentsEngine.base.Condition;
  2502. +
  2503. +import com.l2jhellas.gameserver.instancemanager.RaidBossPointsManager;
  2504. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  2505. +
  2506. +import java.util.Map;
  2507. +
  2508. +
  2509. +/**
  2510. + *
  2511. + *
  2512. + *
  2513. + */
  2514. +public class RaidKill extends Condition
  2515. +{
  2516. +   public RaidKill(Object value)
  2517. +   {
  2518. +       super(value);
  2519. +       setName("Raid Kill");
  2520. +   }
  2521. +
  2522. +   @Override
  2523. +   public boolean meetConditionRequirements(L2PcInstance player)
  2524. +   {
  2525. +       if (getValue() == null)
  2526. +           return false;
  2527. +      
  2528. +       int val = Integer.parseInt(getValue().toString());
  2529. +      
  2530. +       Map<Integer,Integer> list = RaidBossPointsManager.getList(player);
  2531. +       if(list!=null)
  2532. +       {
  2533. +        for(int bid: list.keySet())
  2534. +        {
  2535. +           if(bid==val)
  2536. +           {
  2537. +           if(RaidBossPointsManager.getList(player).get(bid)>0)
  2538. +            return true;
  2539. +           }
  2540. +        }
  2541. +       }
  2542. +       return false;
  2543. +   }
  2544. +}
  2545. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement