Guest User

Untitled

a guest
Jul 29th, 2018
390
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: java/net/sf/l2j/donation/packages/DiamondPackage.java
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- java/net/sf/l2j/donation/packages/DiamondPackage.java   (date 1532879453950)
  7. +++ java/net/sf/l2j/donation/packages/DiamondPackage.java   (date 1532879453950)
  8. @@ -0,0 +1,16 @@
  9. +package net.sf.l2j.donation.packages;
  10. +
  11. +import net.sf.l2j.donation.DonationItem;
  12. +import net.sf.l2j.donation.DonationMisc;
  13. +import net.sf.l2j.donation.DonationPackage;
  14. +
  15. +import java.util.List;
  16. +
  17. +public class DiamondPackage extends DonationPackage
  18. +{
  19. +
  20. +    public DiamondPackage(int cost, List<DonationItem> items, DonationMisc misc)
  21. +    {
  22. +        super(cost, items, misc);
  23. +    }
  24. +}
  25. \ No newline at end of file
  26. Index: java/net/sf/l2j/donation/DonationStats.java
  27. IDEA additional info:
  28. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  29. <+>UTF-8
  30. ===================================================================
  31. --- java/net/sf/l2j/donation/DonationStats.java (date 1532878797369)
  32. +++ java/net/sf/l2j/donation/DonationStats.java (date 1532878797369)
  33. @@ -0,0 +1,114 @@
  34. +package net.sf.l2j.donation;
  35. +
  36. +import net.sf.l2j.commons.data.xml.XMLDocument;
  37. +import org.w3c.dom.Document;
  38. +import org.w3c.dom.NamedNodeMap;
  39. +import org.w3c.dom.Node;
  40. +
  41. +import java.io.File;
  42. +import java.lang.reflect.Constructor;
  43. +import java.util.ArrayList;
  44. +import java.util.List;
  45. +import java.util.logging.Level;
  46. +import java.util.logging.Logger;
  47. +
  48. +public class DonationStats extends XMLDocument
  49. +{
  50. +    private static Logger _log = Logger.getLogger(DonationStats.class.getName());
  51. +
  52. +    private DonationStats()
  53. +    {
  54. +        load();
  55. +    }
  56. +
  57. +    @Override
  58. +    protected void load()
  59. +    {
  60. +        loadDocument("./data/xml/donatePackets.xml");
  61. +    }
  62. +
  63. +    @Override
  64. +    protected void parseDocument(Document doc, File f)
  65. +    {
  66. +        final Node n = doc.getFirstChild();
  67. +        int pos = 1;
  68. +        for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
  69. +        {
  70. +            if (!o.getNodeName().equalsIgnoreCase("Donation"))
  71. +                continue;
  72. +
  73. +            final String category = o.getAttributes().getNamedItem("category").getNodeValue();
  74. +            final int price = Integer.parseInt(o.getAttributes().getNamedItem("price").getNodeValue());
  75. +
  76. +            assert price > 0 : " Price " + price;
  77. +
  78. +            final List<DonationItem> items = new ArrayList<>();
  79. +            boolean noblesse = false;
  80. +            boolean autoDyes = false;
  81. +            int rec = 0;
  82. +
  83. +            for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
  84. +            {
  85. +                if (!d.getNodeName().equalsIgnoreCase("Package"))
  86. +                    continue;
  87. +
  88. +                final NamedNodeMap attrs = d.getAttributes();
  89. +
  90. +                if (attrs.getNamedItem("item") != null)
  91. +                {
  92. +                    final String[] item = attrs.getNamedItem("item").getNodeValue().split(",");
  93. +                    int enchant = 0;
  94. +
  95. +                    if (attrs.getNamedItem("enchant") != null)
  96. +                        enchant = Integer.parseInt(attrs.getNamedItem("enchant").getNodeValue());
  97. +
  98. +                    items.add(new DonationItem(Integer.parseInt(item[0]), Integer.parseInt(item[1]), enchant));
  99. +                }
  100. +
  101. +                if (attrs.getNamedItem("noblesse") != null) {
  102. +                    noblesse = Boolean.parseBoolean(attrs.getNamedItem("noblesse").getNodeValue());
  103. +                }
  104. +
  105. +                if (attrs.getNamedItem("autoDyes") != null) {
  106. +                    autoDyes = Boolean.parseBoolean(attrs.getNamedItem("autoDyes").getNodeValue());
  107. +                }
  108. +
  109. +                if (attrs.getNamedItem("rec") != null) {
  110. +                    rec = Integer.parseInt(attrs.getNamedItem("rec").getNodeValue());
  111. +                }
  112. +            }
  113. +
  114. +            try
  115. +            {
  116. +                Constructor<?> constructor = Class.forName("net.sf.l2j.donation.packages." + category).getConstructors()[0];
  117. +                DonationHolder.INSTANCE.add(pos++, (DonationPackage) constructor.newInstance(price, items, new DonationMisc(noblesse, autoDyes, rec)));
  118. +            }
  119. +            catch (Exception e)
  120. +            {
  121. +                _log.log(Level.SEVERE, "Could not parse donatePackets.xml", e);
  122. +            }
  123. +        }
  124. +    }
  125. +
  126. +    public static DonationStats getInstance()
  127. +    {
  128. +        return SingletonHolder._instance;
  129. +    }
  130. +
  131. +    private static class SingletonHolder
  132. +    {
  133. +        protected static final DonationStats _instance = new DonationStats();
  134. +    }
  135. +
  136. +    public int size()
  137. +    {
  138. +        return DonationHolder.INSTANCE.getSize();
  139. +    }
  140. +
  141. +    public void reload()
  142. +    {
  143. +        DonationHolder.INSTANCE.clear();
  144. +        load();
  145. +    }
  146. +
  147. +}
  148. \ No newline at end of file
  149. Index: java/net/sf/l2j/donation/packages/GrandmasterPackage.java
  150. IDEA additional info:
  151. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  152. <+>UTF-8
  153. ===================================================================
  154. --- java/net/sf/l2j/donation/packages/GrandmasterPackage.java   (date 1532877946488)
  155. +++ java/net/sf/l2j/donation/packages/GrandmasterPackage.java   (date 1532877946488)
  156. @@ -0,0 +1,15 @@
  157. +package net.sf.l2j.donation.packages;
  158. +
  159. +import net.sf.l2j.donation.DonationItem;
  160. +import net.sf.l2j.donation.DonationMisc;
  161. +import net.sf.l2j.donation.DonationPackage;
  162. +
  163. +import java.util.List;
  164. +
  165. +public class GrandmasterPackage extends DonationPackage
  166. +{
  167. +    public GrandmasterPackage(int cost, List<DonationItem> items, DonationMisc misc)
  168. +    {
  169. +        super(cost, items, misc);
  170. +    }
  171. +}
  172. \ No newline at end of file
  173. Index: java/net/sf/l2j/donation/packages/GoldPackage.java
  174. IDEA additional info:
  175. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  176. <+>UTF-8
  177. ===================================================================
  178. --- java/net/sf/l2j/donation/packages/GoldPackage.java  (date 1532877601102)
  179. +++ java/net/sf/l2j/donation/packages/GoldPackage.java  (date 1532877601102)
  180. @@ -0,0 +1,16 @@
  181. +package net.sf.l2j.donation.packages;
  182. +
  183. +import net.sf.l2j.donation.DonationItem;
  184. +import net.sf.l2j.donation.DonationMisc;
  185. +import net.sf.l2j.donation.DonationPackage;
  186. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  187. +
  188. +import java.util.List;
  189. +
  190. +public class GoldPackage extends DonationPackage
  191. +{
  192. +    public GoldPackage(int cost, List<DonationItem> items, DonationMisc misc)
  193. +    {
  194. +        super(cost, items, misc);
  195. +    }
  196. +}
  197. \ No newline at end of file
  198. Index: java/net/sf/l2j/donation/DonationDyes.java
  199. IDEA additional info:
  200. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  201. <+>UTF-8
  202. ===================================================================
  203. --- java/net/sf/l2j/donation/DonationDyes.java  (date 1532877775983)
  204. +++ java/net/sf/l2j/donation/DonationDyes.java  (date 1532877775983)
  205. @@ -0,0 +1,74 @@
  206. +package net.sf.l2j.donation;
  207. +
  208. +import java.util.Arrays;
  209. +
  210. +class DonationDyes
  211. +{
  212. +    public enum AutoDyes
  213. +    {
  214. +        /** (id,symbolId,symbolId,symbolId) symbols can be found at data/xml/hennas.xml*/
  215. +        NONE(-1, -1, -1, -1),
  216. +        DUELIST(88, 158, 146, 172), // +3str -3dex / +2str -2dex / +4con -4dex
  217. +        DREADNOUGHT(89, 173, 171, -1), // +4dex -4str / +4con -4str
  218. +        PHOENIX_KNIGHT(90, 171, -1, -1), // +4con -4str
  219. +        HELL_KNIGHT(91, 170, 172, -1), // +4str -4dex / +4con -4dex
  220. +        SAGGITARIUS(92, 174, -1, -1), // +4dex -4con
  221. +        ADVENTURER(93, 173, 171, -1), // +4dex -4str / +4con -4str
  222. +        ARCHMAGE(94, 180, 175, 171), // +4wit -4men / +4int -4men / +4con -4str
  223. +        SOULTAKER(95, 180, 175, 171), // +4wit -4men / +4int -4men / +4con -4str
  224. +        ARCANA_LORD(96, 180, 175, 171), // +4wit -4men / +4int -4men / +4con -4str
  225. +        CARDINAL(97, 180, -1, 171), // +4wit -4men / +4con -4str
  226. +        HIEROPHANT(98, 180, -1, 171), // +4wit -4men / +4con -4str
  227. +
  228. +        EVAS_TEMPLAR(99, 170, 172, -1), // +4str -4dex / +4con -4dex
  229. +        SWORD_MUSE(100, 170, 148, -1), // +4str -4dex / +2con -2dex
  230. +        WIND_RIDER(101, 171, 173, -1), // +4con -4str / +4dex -4str
  231. +        MOONLIGHT_SENTINEL(102, 169, 179, -1), // +4str -4con / +4wit -4int
  232. +        MYSTIC_MUSE(103, 180, 175, 171), // +4wit -4men / +4int -4men / +4con -4str
  233. +        ELEMENTAL_MASTER(104, 180, 175, -1), // +4wit -4men / +4int -4men
  234. +        EVAS_SAINT(105, 180, 171, -1), // +4wit -4men / +4con -4str
  235. +
  236. +        SHILLIEN_TEMPLAR(106, 170, 172, -1), // +4str -4dex / +4con -4dex
  237. +        SPECTRAL_DANCER(107, 170, 172, -1), // +4str -4dex / +4con -4dex
  238. +        GHOST_HUNTER(108, 173, 171, -1), // +4dex -4str / +4con -4str
  239. +        GHOST_SENTINEL(109, 169, 174, -1), // +4str -4con / +4dex -4con
  240. +        STORM_SCREAMER(110, 180, 175, 171), // +4wit -4men / +4int -4men / +4con -4str
  241. +        SPECTRAL_MASTER(111, 180, 175, -1), // +4wit -4men / +4int -4men
  242. +        SHILLIEN_SAINT(112, 180, 171, -1), // +4wit -4men / +4con -4str
  243. +
  244. +        TITAN(113, 170, -1, -1), // +4con -4dex
  245. +        GRAND_KHAVATARI(114, 169, -1, -1), // +4str -4con
  246. +        DOMINATOR(115, 180, 171, -1), // +4wit -4men / +4con -4str
  247. +        DOOMCRYER(116, 180, 171, -1), // +4wit -4men / +4con -4str
  248. +
  249. +        FORTUNE_SEEKER(117, 174, -1, -1), // +4dex -4con
  250. +        MAESTRO(118, 174, -1, -1);// +4dex -4con
  251. +
  252. +        private int _classId;
  253. +        private int[] _dyes = new int[3];
  254. +
  255. +        AutoDyes(int classId, int dye1, int dye2, int dye3)
  256. +        {
  257. +            _classId = classId;
  258. +            _dyes[0] = dye1;
  259. +            _dyes[1] = dye2;
  260. +            _dyes[2] = dye3;
  261. +        }
  262. +
  263. +        public int getId()
  264. +        {
  265. +            return _classId;
  266. +        }
  267. +
  268. +        public int[] getDyes()
  269. +        {
  270. +            return _dyes;
  271. +        }
  272. +
  273. +        public static AutoDyes find(int val)
  274. +        {
  275. +            return Arrays.stream(AutoDyes.values()).filter(e -> e.getId() == val).findFirst().orElse(AutoDyes.NONE);
  276. +        }
  277. +    }
  278. +
  279. +}
  280. \ No newline at end of file
  281. Index: java/net/sf/l2j/gameserver/GameServer.java
  282. IDEA additional info:
  283. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  284. <+>UTF-8
  285. ===================================================================
  286. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 0cee4de6d3bf3c03152b92998337cece1191fad3)
  287. +++ java/net/sf/l2j/gameserver/GameServer.java  (date 1532877480425)
  288. @@ -19,6 +19,7 @@
  289.  
  290.  import net.sf.l2j.Config;
  291.  import net.sf.l2j.L2DatabaseFactory;
  292. +import net.sf.l2j.donation.DonationStats;
  293.  import net.sf.l2j.gameserver.cache.CrestCache;
  294.  import net.sf.l2j.gameserver.cache.HtmCache;
  295.  import net.sf.l2j.gameserver.communitybbs.Manager.ForumsBBSManager;
  296. @@ -279,7 +280,10 @@
  297.         _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
  298.         _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
  299.          _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
  300. -      
  301. +
  302. +        StringUtil.printSection("Donation Stats");
  303. +        _log.info("Loaded " + DonationStats.getInstance().size() + " Donation Packages.");
  304. +
  305.         StringUtil.printSection("System");
  306.         Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
  307.         ForumsBBSManager.getInstance();
  308. Index: java/net/sf/l2j/donation/DonationMisc.java
  309. IDEA additional info:
  310. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  311. <+>UTF-8
  312. ===================================================================
  313. --- java/net/sf/l2j/donation/DonationMisc.java  (date 1532878102104)
  314. +++ java/net/sf/l2j/donation/DonationMisc.java  (date 1532878102104)
  315. @@ -0,0 +1,40 @@
  316. +package net.sf.l2j.donation;
  317. +
  318. +public class DonationMisc
  319. +{
  320. +    private final boolean _noblesse;
  321. +    private final boolean _autoDyes;
  322. +    private final int _rec;
  323. +
  324. +    public DonationMisc(boolean noblesse, boolean autoDyes, int rec)
  325. +    {
  326. +        _noblesse = noblesse;
  327. +        _autoDyes = autoDyes;
  328. +        _rec = rec;
  329. +    }
  330. +
  331. +    public boolean isEmpty()
  332. +    {
  333. +        return !_noblesse && _rec <= 0 && !_autoDyes;
  334. +    }
  335. +
  336. +    public boolean haveNoblesse()
  337. +    {
  338. +        return _noblesse;
  339. +    }
  340. +
  341. +    public boolean haveRec()
  342. +    {
  343. +        return _rec > 0;
  344. +    }
  345. +
  346. +    public boolean haveDyes()
  347. +    {
  348. +        return _autoDyes;
  349. +    }
  350. +
  351. +    public int getRecs()
  352. +    {
  353. +        return _rec;
  354. +    }
  355. +}
  356. \ No newline at end of file
  357. Index: java/net/sf/l2j/donation/DonationItem.java
  358. IDEA additional info:
  359. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  360. <+>UTF-8
  361. ===================================================================
  362. --- java/net/sf/l2j/donation/DonationItem.java  (date 1532878094991)
  363. +++ java/net/sf/l2j/donation/DonationItem.java  (date 1532878094991)
  364. @@ -0,0 +1,30 @@
  365. +package net.sf.l2j.donation;
  366. +
  367. +public class DonationItem
  368. +{
  369. +    private final int _id;
  370. +    private final int _count;
  371. +    private final int _enchant;
  372. +
  373. +    public DonationItem(int id, int count, int enchant)
  374. +    {
  375. +        _id = id;
  376. +        _count = count;
  377. +        _enchant = enchant;
  378. +    }
  379. +
  380. +    public int getId()
  381. +    {
  382. +        return _id;
  383. +    }
  384. +
  385. +    public int getCount()
  386. +    {
  387. +        return _count;
  388. +    }
  389. +
  390. +    public int getEnchant()
  391. +    {
  392. +        return _enchant;
  393. +    }
  394. +}
  395. \ No newline at end of file
  396. Index: java/net/sf/l2j/donation/DonationHolder.java
  397. IDEA additional info:
  398. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  399. <+>UTF-8
  400. ===================================================================
  401. --- java/net/sf/l2j/donation/DonationHolder.java    (date 1532878080688)
  402. +++ java/net/sf/l2j/donation/DonationHolder.java    (date 1532878080688)
  403. @@ -0,0 +1,40 @@
  404. +package net.sf.l2j.donation;
  405. +
  406. +import java.util.Collection;
  407. +import java.util.HashMap;
  408. +import java.util.Map;
  409. +
  410. +public enum DonationHolder
  411. +{
  412. +    INSTANCE;
  413. +    private Map<Integer, DonationPackage> donates;
  414. +
  415. +    DonationHolder(){
  416. +        donates = new HashMap<>();
  417. +    }
  418. +
  419. +    public void add(int pos, DonationPackage packet)
  420. +    {
  421. +        donates.put(pos, packet);
  422. +    }
  423. +
  424. +    public int getSize()
  425. +    {
  426. +        return donates.size();
  427. +    }
  428. +
  429. +    public DonationPackage get(int val)
  430. +    {
  431. +        return donates.get(val);
  432. +    }
  433. +
  434. +    public Collection<DonationPackage> getPackages()
  435. +    {
  436. +        return donates.values();
  437. +    }
  438. +
  439. +    public void clear()
  440. +    {
  441. +        donates.clear();
  442. +    }
  443. +}
  444. \ No newline at end of file
  445. Index: java/net/sf/l2j/donation/packages/BronzePackage.java
  446. IDEA additional info:
  447. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  448. <+>UTF-8
  449. ===================================================================
  450. --- java/net/sf/l2j/donation/packages/BronzePackage.java    (date 1532877961872)
  451. +++ java/net/sf/l2j/donation/packages/BronzePackage.java    (date 1532877961872)
  452. @@ -0,0 +1,16 @@
  453. +package net.sf.l2j.donation.packages;
  454. +
  455. +import net.sf.l2j.donation.DonationItem;
  456. +import net.sf.l2j.donation.DonationMisc;
  457. +import net.sf.l2j.donation.DonationPackage;
  458. +
  459. +import java.util.List;
  460. +
  461. +public class BronzePackage extends DonationPackage
  462. +{
  463. +
  464. +    public BronzePackage(int cost, List<DonationItem> items, DonationMisc misc)
  465. +    {
  466. +        super(cost, items, misc);
  467. +    }
  468. +}
  469. \ No newline at end of file
  470. Index: java/net/sf/l2j/donation/packages/SilverPackage.java
  471. IDEA additional info:
  472. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  473. <+>UTF-8
  474. ===================================================================
  475. --- java/net/sf/l2j/donation/packages/SilverPackage.java    (date 1532877620940)
  476. +++ java/net/sf/l2j/donation/packages/SilverPackage.java    (date 1532877620940)
  477. @@ -0,0 +1,15 @@
  478. +package net.sf.l2j.donation.packages;
  479. +
  480. +import net.sf.l2j.donation.DonationItem;
  481. +import net.sf.l2j.donation.DonationMisc;
  482. +import net.sf.l2j.donation.DonationPackage;
  483. +
  484. +import java.util.List;
  485. +
  486. +public class SilverPackage extends DonationPackage
  487. +{
  488. +    public SilverPackage(int cost, List<DonationItem> items, DonationMisc misc)
  489. +    {
  490. +        super(cost, items, misc);
  491. +    }
  492. +}
  493. Index: java/net/sf/l2j/donation/packages/MasterPackage.java
  494. IDEA additional info:
  495. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  496. <+>UTF-8
  497. ===================================================================
  498. --- java/net/sf/l2j/donation/packages/MasterPackage.java    (date 1532877611931)
  499. +++ java/net/sf/l2j/donation/packages/MasterPackage.java    (date 1532877611931)
  500. @@ -0,0 +1,15 @@
  501. +package net.sf.l2j.donation.packages;
  502. +
  503. +import net.sf.l2j.donation.DonationItem;
  504. +import net.sf.l2j.donation.DonationMisc;
  505. +import net.sf.l2j.donation.DonationPackage;
  506. +
  507. +import java.util.List;
  508. +
  509. +public class MasterPackage extends DonationPackage {
  510. +
  511. +    public MasterPackage(int cost, List<DonationItem> items, DonationMisc misc)
  512. +    {
  513. +        super(cost, items, misc);
  514. +    }
  515. +}
  516. Index: java/net/sf/l2j/donation/DonationPackage.java
  517. IDEA additional info:
  518. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  519. <+>UTF-8
  520. ===================================================================
  521. --- java/net/sf/l2j/donation/DonationPackage.java   (date 1532877990216)
  522. +++ java/net/sf/l2j/donation/DonationPackage.java   (date 1532877990216)
  523. @@ -0,0 +1,134 @@
  524. +package net.sf.l2j.donation;
  525. +
  526. +import net.sf.l2j.donation.DonationDyes.AutoDyes;
  527. +import net.sf.l2j.gameserver.data.ItemTable;
  528. +import net.sf.l2j.gameserver.data.xml.HennaData;
  529. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  530. +import net.sf.l2j.gameserver.model.item.Henna;
  531. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  532. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  533. +
  534. +import java.util.List;
  535. +import java.util.logging.Logger;
  536. +
  537. +public abstract class DonationPackage
  538. +{
  539. +    private static Logger _log = Logger.getLogger(DonationPackage.class.getName());
  540. +
  541. +    private final int _cost;
  542. +    private final List<DonationItem> _items;
  543. +    private final DonationMisc _misc;
  544. +
  545. +    public DonationPackage(int cost, List<DonationItem> items, DonationMisc misc)
  546. +    {
  547. +        _cost = cost;
  548. +        _items = items;
  549. +        _misc = misc;
  550. +    }
  551. +
  552. +    public boolean haveMisc()
  553. +    {
  554. +        return !_misc.isEmpty();
  555. +    }
  556. +
  557. +    public List<DonationItem> getItems()
  558. +    {
  559. +        return _items;
  560. +    }
  561. +
  562. +    public int getCost()
  563. +    {
  564. +        return _cost;
  565. +    }
  566. +
  567. +    public String getPackage()
  568. +    {
  569. +        return this.getClass().getSimpleName();
  570. +    }
  571. +
  572. +    public void applyImprovements(Player player)
  573. +    {
  574. +        handleNoblessMisc(player);
  575. +        handleRecMisc(player);
  576. +        handleDyesMisc(player);
  577. +
  578. +    }
  579. +
  580. +    private void handleDyesMisc(Player player) {
  581. +        if (_misc.haveDyes())
  582. +            drawDyes(player);
  583. +    }
  584. +
  585. +    private void handleRecMisc(Player player) {
  586. +        if (_misc.haveRec())
  587. +        {
  588. +            player.setRecomHave(_misc.getRecs());
  589. +            player.broadcastUserInfo();
  590. +        }
  591. +    }
  592. +
  593. +    private void handleNoblessMisc(Player player) {
  594. +        if (!_misc.haveNoblesse())
  595. +            return;
  596. +
  597. +        player.setNoble(true, true);
  598. +        player.broadcastPacket(new SocialAction(player, 16));
  599. +        player.sendMessage("You granted with noblesse status!");
  600. +    }
  601. +
  602. +    public DonationMisc getMisc()
  603. +    {
  604. +        return _misc;
  605. +    }
  606. +
  607. +    private static void drawDyes(Player player)
  608. +    {
  609. +        removeOldDyes(player);
  610. +
  611. +        AutoDyes availableDyes = AutoDyes.find(player.getClassId().getId());
  612. +
  613. +        if (availableDyes == AutoDyes.NONE)
  614. +            return;
  615. +
  616. +        applyDyesToPlayer(player, availableDyes);
  617. +    }
  618. +
  619. +    private static void applyDyesToPlayer(Player player, AutoDyes availableDyes) {
  620. +        for (final int symbolId : availableDyes.getDyes())
  621. +        {
  622. +            if (symbolId == -1)
  623. +                continue;
  624. +            final Henna henna = HennaData.getInstance().getHenna(symbolId);
  625. +            if (henna.canBeUsedBy(player))
  626. +                player.addHenna(henna);
  627. +        }
  628. +    }
  629. +
  630. +    private static void removeOldDyes(Player player) {
  631. +        for (int i = 1; i <= 3; i++)
  632. +        {
  633. +            final Henna henna = player.getHenna(i);
  634. +            if (henna != null)
  635. +                player.removeHenna(i);
  636. +        }
  637. +    }
  638. +
  639. +    public void reward(Player player)
  640. +    {
  641. +        for (final DonationItem itemInfo : getItems())
  642. +        {
  643. +            final ItemInstance item = ItemTable.getInstance().createItem("donation", itemInfo.getId(), itemInfo.getCount(), player, null);
  644. +            if (item == null)
  645. +            {
  646. +                _log.info("Incorect item with id " + itemInfo.getId());
  647. +                continue;
  648. +            }
  649. +
  650. +            if (itemInfo.getEnchant() > 0)
  651. +                item.setEnchantLevel(itemInfo.getEnchant());
  652. +            player.addItem("donation", item, null, true, true);
  653. +        }
  654. +        if (haveMisc())
  655. +            applyImprovements(player);
  656. +    }
  657. +}
  658. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java
  659. IDEA additional info:
  660. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  661. <+>UTF-8
  662. ===================================================================
  663. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java (revision 0cee4de6d3bf3c03152b92998337cece1191fad3)
  664. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java (date 1532877470943)
  665. @@ -5,6 +5,7 @@
  666.  import net.sf.l2j.commons.lang.StringUtil;
  667.  
  668.  import net.sf.l2j.Config;
  669. +import net.sf.l2j.donation.DonationStats;
  670.  import net.sf.l2j.gameserver.cache.CrestCache;
  671.  import net.sf.l2j.gameserver.cache.HtmCache;
  672.  import net.sf.l2j.gameserver.data.ItemTable;
  673. @@ -232,6 +233,11 @@
  674.                         ZoneManager.getInstance().reload();
  675.                         activeChar.sendMessage("Zones have been reloaded.");
  676.                     }
  677. +                    else if (type.startsWith("donations"))
  678. +                    {
  679. +                        DonationStats.getInstance().reload();
  680. +                        activeChar.sendMessage("Donations have been reloaded.");
  681. +                    }
  682.                     else
  683.                     {
  684.                         activeChar.sendMessage("Usage : //reload <acar|announcement|config|crest|door>");
  685. Index: java/net/sf/l2j/gameserver/model/actor/instance/DonationManager.java
  686. IDEA additional info:
  687. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  688. <+>UTF-8
  689. ===================================================================
  690. --- java/net/sf/l2j/gameserver/model/actor/instance/DonationManager.java    (date 1532879375552)
  691. +++ java/net/sf/l2j/gameserver/model/actor/instance/DonationManager.java    (date 1532879375552)
  692. @@ -0,0 +1,165 @@
  693. +package net.sf.l2j.gameserver.model.actor.instance;
  694. +
  695. +import net.sf.l2j.commons.lang.StringUtil;
  696. +import net.sf.l2j.donation.DonationHolder;
  697. +import net.sf.l2j.donation.DonationItem;
  698. +import net.sf.l2j.donation.DonationMisc;
  699. +import net.sf.l2j.donation.DonationPackage;
  700. +import net.sf.l2j.gameserver.data.ItemTable;
  701. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  702. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  703. +
  704. +import java.util.Collection;
  705. +import java.util.StringTokenizer;
  706. +
  707. +public class DonationManager extends Folk
  708. +{
  709. +    private static final int donateItemId = 57;
  710. +
  711. +    public DonationManager(int objectId, NpcTemplate template)
  712. +    {
  713. +        super(objectId, template);
  714. +    }
  715. +
  716. +    @Override
  717. +    public void onBypassFeedback(Player player, String command)
  718. +    {
  719. +        StringTokenizer st = new StringTokenizer(command, " ");
  720. +        String currentCommand = st.nextToken();
  721. +
  722. +        if (currentCommand.startsWith("showPackages"))
  723. +        {
  724. +            showPackages(player);
  725. +        }
  726. +        else if (currentCommand.startsWith("explore"))
  727. +        {
  728. +            if (!st.hasMoreTokens())
  729. +                return;
  730. +
  731. +            final int val = tryParseInt(st.nextToken());
  732. +
  733. +            if (val < 0)
  734. +                return;
  735. +
  736. +            explorePackage(player, val);
  737. +        }
  738. +        else if (currentCommand.startsWith("buy"))
  739. +        {
  740. +            final int val = tryParseInt(st.nextToken());
  741. +
  742. +            if (val <= 0)
  743. +                return;
  744. +
  745. +            final DonationPackage packet = DonationHolder.INSTANCE.get(val);
  746. +
  747. +            if (packet == null)
  748. +                return;
  749. +
  750. +            if (player.destroyItemByItemId("donation", donateItemId, packet.getCost(), null, true))
  751. +                packet.reward(player);
  752. +        }
  753. +    }
  754. +
  755. +    private void explorePackage(Player player, int val)
  756. +    {
  757. +        DonationPackage currPackage = DonationHolder.INSTANCE.get(val);
  758. +
  759. +        if (currPackage == null)
  760. +            return;
  761. +
  762. +        final NpcHtmlMessage html = new NpcHtmlMessage(0);
  763. +        html.setFile("data/html/mods/donate/list.htm");
  764. +
  765. +        final StringBuilder sb = new StringBuilder();
  766. +        generateHtmlForPackageItems(currPackage, sb);
  767. +        generateHtmlForMiscs(currPackage, sb);
  768. +        replacePackageHtmlPlaceholders(val, currPackage, html, sb);
  769. +        player.sendPacket(html);
  770. +    }
  771. +
  772. +    private void replacePackageHtmlPlaceholders(int val, DonationPackage currPackage, NpcHtmlMessage html, StringBuilder sb) {
  773. +        html.replace("%package%", "<font color=\"LEVEL\">" + currPackage.getPackage() + " Package</font>");
  774. +        html.replace("%objectId%", getObjectId());
  775. +        html.replace("%items%", sb.toString());
  776. +        html.replace("%packetVal%", val);
  777. +    }
  778. +
  779. +    private void generateHtmlForMiscs(DonationPackage currPackage, StringBuilder sb) {
  780. +        if (!currPackage.haveMisc())
  781. +            return;
  782. +
  783. +        final DonationMisc misc = currPackage.getMisc();
  784. +
  785. +        if (misc.haveNoblesse())
  786. +            StringUtil.append(sb, "<tr><td align=\"center\">", "<font color=\"LEVEL\">Noblesse Status</font></td></tr>");
  787. +
  788. +        if (misc.haveRec())
  789. +            StringUtil.append(sb, "<tr><td align=\"center\"><font color=\"LEVEL\">Recommends</font> (", misc.getRecs(), ")</font></td></tr>");
  790. +
  791. +        if (misc.haveDyes())
  792. +            StringUtil.append(sb, "<tr><td align=\"center\"><font color=\"LEVEL\">Auto Dyes Picker</font></td></tr>");
  793. +    }
  794. +
  795. +    private void generateHtmlForPackageItems(DonationPackage currPackage, StringBuilder sb) {
  796. +        for (DonationItem donateItem : currPackage.getItems())
  797. +        {
  798. +            final String name = ItemTable.getInstance().getTemplate(donateItem.getId()).getName();
  799. +            final int count = donateItem.getCount();
  800. +            final int enchant = donateItem.getEnchant();
  801. +            StringUtil.append(sb, "<tr><td align=\"center\">", name, " (x", count, ")"+(enchant > 0 ? " <font color=\"LEVEL\">+" + enchant + "</font>" : "" )+"</td></tr>");
  802. +        }
  803. +    }
  804. +
  805. +    private void showPackages(Player player)
  806. +    {
  807. +        final Collection<DonationPackage> packages = DonationHolder.INSTANCE.getPackages();
  808. +        if (packages.isEmpty())
  809. +            return;
  810. +
  811. +        final NpcHtmlMessage html = new NpcHtmlMessage(0);
  812. +        html.setFile(getHtmlPath(getNpcId(), 1));
  813. +
  814. +        final StringBuilder sb = new StringBuilder(2000);
  815. +
  816. +        generateDonationPackageHtml(packages, sb);
  817. +
  818. +        replaceHtmlPlaceholders(html, sb);
  819. +        player.sendPacket(html);
  820. +    }
  821. +
  822. +    private void replaceHtmlPlaceholders(NpcHtmlMessage html, StringBuilder sb) {
  823. +        html.replace("%packages%", sb.toString());
  824. +        html.replace("%objectId%", getObjectId());
  825. +    }
  826. +
  827. +    private void generateDonationPackageHtml(Collection<DonationPackage> packages, StringBuilder sb) {
  828. +        int pos = 1;
  829. +        for (final DonationPackage dp : packages)
  830. +        {
  831. +            final String name = dp.getPackage();
  832. +            final int cost = dp.getCost();
  833. +            StringUtil.append(sb, "<tr><td align=\"center\"><a action=\"bypass -h npc_%objectId%_explore ", pos++, "\">", name, "</a></td><td>", "<font color=\"3399CC\">", cost, " ", ItemTable.getInstance().getTemplate(donateItemId).getName(), "</font></td></tr>");
  834. +        }
  835. +    }
  836. +
  837. +    private int tryParseInt(String val) {
  838. +        try {
  839. +            return Integer.parseInt(val);
  840. +        }
  841. +        catch (NumberFormatException e) {
  842. +            return 0;
  843. +        }
  844. +    }
  845. +
  846. +    @Override
  847. +    public String getHtmlPath(int npcId, int val)
  848. +    {
  849. +        String filename
  850. +        if (val == 0)
  851. +            filename = "" + npcId;
  852. +        else
  853. +            filename = npcId + "-" + val;
  854. +
  855. +        return "data/html/mods/donate/" + filename + ".htm";
  856. +    }
  857. +}
  858. \ No newline at end of file
  859. Index: java/net/sf/l2j/donation/packages/PlatinumPackage.java
  860. IDEA additional info:
  861. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  862. <+>UTF-8
  863. ===================================================================
  864. --- java/net/sf/l2j/donation/packages/PlatinumPackage.java  (date 1532877955135)
  865. +++ java/net/sf/l2j/donation/packages/PlatinumPackage.java  (date 1532877955135)
  866. @@ -0,0 +1,15 @@
  867. +package net.sf.l2j.donation.packages;
  868. +
  869. +import net.sf.l2j.donation.DonationItem;
  870. +import net.sf.l2j.donation.DonationMisc;
  871. +import net.sf.l2j.donation.DonationPackage;
  872. +
  873. +import java.util.List;
  874. +
  875. +public class PlatinumPackage extends DonationPackage
  876. +{
  877. +    public PlatinumPackage(int cost, List<DonationItem> items, DonationMisc misc)
  878. +    {
  879. +        super(cost, items, misc);
  880. +    }
  881. +}
  882. \ No newline at end of file
RAW Paste Data