Advertisement
Fabbian

vip

Apr 22nd, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.96 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2JDream
  3. Index: Dream_GameServer/src/com/dream/game/handler/voiced/VipComand.java
  4. ===================================================================
  5. --- Dream_GameServer/src/com/dream/game/handler/voiced/VipComand.java (revision 0)
  6. +++ Dream_GameServer/src/com/dream/game/handler/voiced/VipComand.java (working copy)
  7. @@ -0,0 +1,62 @@
  8. +/*
  9. + * This program is free software: you can redistribute it and/or modify it under
  10. + * the terms of the GNU General Public License as published by the Free Software
  11. + * Foundation, either version 3 of the License, or (at your option) any later
  12. + * version.
  13. + *
  14. + * This program is distributed in the hope that it will be useful, but WITHOUT
  15. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17. + * details.
  18. + *
  19. + * You should have received a copy of the GNU General Public License along with
  20. + * this program. If not, see <http://www.gnu.org/licenses/>.
  21. + */
  22. +package com.dream.game.handler.voiced;
  23. +
  24. +import com.dream.Config;
  25. +import com.dream.game.handler.IVoicedCommandHandler;
  26. +import com.dream.game.model.actor.instance.L2PcInstance;
  27. +
  28. +public class VipComand implements IVoicedCommandHandler
  29. +{
  30. + private static final String[] VOICED_COMMANDS =
  31. + {
  32. + "viptele",
  33. + };
  34. +
  35. + @Override
  36. + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  37. + {
  38. + if (command.equals("viptele"))
  39. + {
  40. + if (checkConditions(activeChar))
  41. + {
  42. + activeChar.teleToLocation(Config.VIP_TELE_X, Config.VIP_TELE_Y, Config.VIP_TELE_Z);
  43. + }
  44. + }
  45. +
  46. + return true;
  47. + }
  48. +
  49. + private static boolean checkConditions(L2PcInstance p)
  50. + {
  51. + if (!p.isVip() && Config.ALLOW_VIP_TELE)
  52. + {
  53. + return false;
  54. + }
  55. + return true;
  56. + }
  57. +
  58. + @Override
  59. + public String[] getVoicedCommandList()
  60. + {
  61. + return VOICED_COMMANDS;
  62. + }
  63. +
  64. + @Override
  65. + public String getDescription(String command)
  66. + {
  67. + return "Teleport you to an Vip area.";
  68. + }
  69. +}
  70. \ No newline at end of file
  71. Index: Dream_GameServer/src/com/dream/game/handler/item/VipItem.java
  72. ===================================================================
  73. --- Dream_GameServer/src/com/dream/game/handler/item/VipItem.java (revision 0)
  74. +++ Dream_GameServer/src/com/dream/game/handler/item/VipItem.java (working copy)
  75. @@ -0,0 +1,109 @@
  76. +package com.dream.game.handler.item;
  77. +
  78. +import java.sql.Connection;
  79. +import java.sql.PreparedStatement;
  80. +
  81. +import com.dream.Config;
  82. +import com.dream.L2DatabaseFactory;
  83. +import com.dream.game.handler.IItemHandler;
  84. +import com.dream.game.model.actor.L2Playable;
  85. +import com.dream.game.model.actor.instance.L2ItemInstance;
  86. +import com.dream.game.model.actor.instance.L2PcInstance;
  87. +import com.dream.game.network.SystemChatChannelId;
  88. +import com.dream.game.network.serverpackets.CreatureSay;
  89. +
  90. +public class VipItem implements IItemHandler
  91. +{
  92. + private static final int[] ITEM_IDS =
  93. + {
  94. + Config.VIP_ITEM1,
  95. + Config.VIP_ITEM2,
  96. + Config.VIP_ITEM3
  97. + };
  98. +
  99. + @Override
  100. + public void useItem(L2Playable playable, L2ItemInstance item, boolean par)
  101. + {
  102. +
  103. + }
  104. +
  105. + @Override
  106. + public void useItem(L2Playable playable, L2ItemInstance item)
  107. + {
  108. + if (!(playable instanceof L2PcInstance))
  109. + {
  110. + return;
  111. + }
  112. +
  113. + L2PcInstance activeChar = (L2PcInstance) playable;
  114. +
  115. + if (item.getItemId() == Config.VIP_ITEM1)
  116. + {
  117. + activeChar.setVip(true);
  118. + activeChar.setEndTime("vip", Config.VIP_ITEM_DAY1);
  119. + activeChar.doVIP(activeChar);
  120. + activeChar.sendPacket(new CreatureSay(0, SystemChatChannelId.Chat_None, "System", "Dear player, you are now an VIP, congratulations."));
  121. +
  122. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  123. + {
  124. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET vip = 1, vip_end = ? WHERE charId=?");
  125. + statement.setLong(1, activeChar.getVipEndTime());
  126. + statement.setInt(2, activeChar.getObjectId());
  127. + statement.execute();
  128. + statement.close();
  129. + }
  130. + catch (Exception e)
  131. + {
  132. + _log.warn("Something went wrong, check log folder for details", e);
  133. + }
  134. + }
  135. +
  136. + if (item.getItemId() == Config.VIP_ITEM2)
  137. + {
  138. + activeChar.setVip(true);
  139. + activeChar.setEndTime("vip", Config.VIP_ITEM_DAY2);
  140. + activeChar.doVIP(activeChar);
  141. + activeChar.sendPacket(new CreatureSay(0, SystemChatChannelId.Chat_None, "System", "Dear player, you are now an VIP, congratulations."));
  142. +
  143. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  144. + {
  145. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET vip = 1, vip_end = ? WHERE charId=?");
  146. + statement.setLong(1, activeChar.getVipEndTime());
  147. + statement.setInt(2, activeChar.getObjectId());
  148. + statement.execute();
  149. + statement.close();
  150. + }
  151. + catch (Exception e)
  152. + {
  153. + _log.warn("Something went wrong, check log folder for details", e);
  154. + }
  155. + }
  156. +
  157. + if (item.getItemId() == Config.VIP_ITEM3)
  158. + {
  159. + activeChar.setVip(true);
  160. + activeChar.setEndTime("vip", Config.VIP_ITEM_DAY3);
  161. + activeChar.doVIP(activeChar);
  162. + activeChar.sendPacket(new CreatureSay(0, SystemChatChannelId.Chat_None, "System", "Dear player, you are now an VIP, congratulations."));
  163. +
  164. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  165. + {
  166. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET vip = 1, vip_end = ? WHERE charId=?");
  167. + statement.setLong(1, activeChar.getVipEndTime());
  168. + statement.setInt(2, activeChar.getObjectId());
  169. + statement.execute();
  170. + statement.close();
  171. + }
  172. + catch (Exception e)
  173. + {
  174. + _log.warn("Something went wrong, check log folder for details", e);
  175. + }
  176. + }
  177. + }
  178. +
  179. + @Override
  180. + public int[] getItemIds()
  181. + {
  182. + return ITEM_IDS;
  183. + }
  184. +}
  185. \ No newline at end of file
  186. Index: Dream_GameServer/src/com/dream/Config.java
  187. ===================================================================
  188. --- Dream_GameServer/src/com/dream/Config.java (revision 2099)
  189. +++ Dream_GameServer/src/com/dream/Config.java (working copy)
  190. @@ -11,6 +11,7 @@
  191. import java.io.OutputStream;
  192. import java.math.BigInteger;
  193. import java.util.ArrayList;
  194. +import java.util.HashMap;
  195. import java.util.List;
  196. import java.util.Map;
  197. import java.util.Properties;
  198. @@ -35,6 +36,105 @@
  199. {
  200. protected static Logger _log = Logger.getLogger(Config.class.getName());
  201.  
  202. + // Vip Properties
  203. + public static boolean ENABLE_VIP_SYSTEM;
  204. + public static Map<Integer, Integer> VIP_SKILLS;
  205. + public static boolean ALLOW_VIP_NCOLOR;
  206. + public static int VIP_NCOLOR;
  207. + public static boolean ALLOW_VIP_TCOLOR;
  208. + public static int VIP_TCOLOR;
  209. + public static float VIP_XP_SP_RATE;
  210. + public static float VIP_ADENA_RATE;
  211. + public static float VIP_DROP_RATE;
  212. + public static float VIP_SPOIL_RATE;
  213. + public static boolean ALLOW_VIP_ITEM;
  214. + public static int VIP_ITEMID;
  215. + public static boolean ALLOW_CUSTOM_CHAR_VIP;
  216. + public static int CUSTOM_DAY_VIP;
  217. + public static boolean ALLOW_VIP_LEVEL;
  218. + public static int VIP_DAY_LEVEL;
  219. + public static int VIP_LEVEL_GIVE;
  220. + public static int VIP_ITEM1;
  221. + public static int VIP_ITEM_DAY1;
  222. + public static int VIP_ITEM2;
  223. + public static int VIP_ITEM_DAY2;
  224. + public static int VIP_ITEM3;
  225. + public static int VIP_ITEM_DAY3;
  226. + public static boolean ALLOW_VIP_TELE;
  227. + public static int VIP_TELE_X;
  228. + public static int VIP_TELE_Y;
  229. + public static int VIP_TELE_Z;
  230. +
  231. + public static void loadVipConfig()
  232. + {
  233. + try
  234. + {
  235. + Properties p = new L2Properties(ConfigFiles.VIP_FILE);
  236. +
  237. + /** VIP System */
  238. + ENABLE_VIP_SYSTEM = Boolean.parseBoolean(p.getProperty("EnableVipSystem", "True"));
  239. + ALLOW_VIP_NCOLOR = Boolean.parseBoolean(p.getProperty("AllowVipNameColor", "True"));
  240. + VIP_NCOLOR = Integer.decode("0x" + p.getProperty("VipNameColor", "88AA88"));
  241. + ALLOW_VIP_TCOLOR = Boolean.parseBoolean(p.getProperty("AllowVipTitleColor", "True"));
  242. + VIP_TCOLOR = Integer.decode("0x" + p.getProperty("VipTitleColor", "88AA88"));
  243. + VIP_XP_SP_RATE = Float.parseFloat(p.getProperty("VIPXpSpRate", "1.5"));
  244. + VIP_ADENA_RATE = Float.parseFloat(p.getProperty("VIPAdenaRate", "1.5"));
  245. + VIP_DROP_RATE = Float.parseFloat(p.getProperty("VIPDropRate", "1.5"));
  246. + VIP_SPOIL_RATE = Float.parseFloat(p.getProperty("VIPSpoilRate", "1.5"));
  247. + VIP_ITEMID = Integer.parseInt(p.getProperty("ItemIdVip", "9945"));
  248. + ALLOW_VIP_ITEM = Boolean.parseBoolean(p.getProperty("AllowVIPItem", "False"));
  249. + ALLOW_CUSTOM_CHAR_VIP = Boolean.parseBoolean(p.getProperty("AllowCustomStartVip", "false"));
  250. + CUSTOM_DAY_VIP = Integer.parseInt(p.getProperty("CustomStartDays", "1"));
  251. + ALLOW_VIP_LEVEL = Boolean.parseBoolean(p.getProperty("AllowVipLevel", "false"));
  252. + VIP_DAY_LEVEL = Integer.parseInt(p.getProperty("VipDayLevel", "10"));
  253. + VIP_LEVEL_GIVE = Integer.parseInt(p.getProperty("VipLevelGive", "15"));
  254. + VIP_ITEM1 = Integer.parseInt(p.getProperty("VipItem1", "5567"));
  255. + VIP_ITEM_DAY1 = Integer.parseInt(p.getProperty("VipItemDay1", "7"));
  256. + VIP_ITEM2 = Integer.parseInt(p.getProperty("VipItem2", "5568"));
  257. + VIP_ITEM_DAY2 = Integer.parseInt(p.getProperty("VipItemDay2", "15"));
  258. + VIP_ITEM3 = Integer.parseInt(p.getProperty("VipItem3", "5569"));
  259. + VIP_ITEM_DAY3 = Integer.parseInt(p.getProperty("VipItemDay3", "30"));
  260. + ALLOW_VIP_TELE = Boolean.parseBoolean(p.getProperty("AllowVipTele", "True"));
  261. + VIP_TELE_X = Integer.parseInt(p.getProperty("VipTeleX", "36554"));
  262. + VIP_TELE_Y = Integer.parseInt(p.getProperty("VipTeley", "-6654"));
  263. + VIP_TELE_Z = Integer.parseInt(p.getProperty("VipTelez", "1644"));
  264. +
  265. + if (ENABLE_VIP_SYSTEM)
  266. + {
  267. + String[] VipSkillsSplit = p.getProperty("VipSkills", "").split(";");
  268. + VIP_SKILLS = new HashMap<>(VipSkillsSplit.length);
  269. + for (String skill : VipSkillsSplit)
  270. + {
  271. + String[] skillSplit = skill.split(",");
  272. + if (skillSplit.length != 2)
  273. + {
  274. + _log.info("[VIP System]: invalid config property in vip.properties -> VipSkills \"" + skill + "\"");
  275. + }
  276. + else
  277. + {
  278. + try
  279. + {
  280. + VIP_SKILLS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  281. + }
  282. + catch (NumberFormatException nfe)
  283. + {
  284. + if (!skill.equals(""))
  285. + {
  286. + _log.info("[VIP System]: invalid config property in vip.properties -> VipSkills \"" + skillSplit[0] + "\"" + skillSplit[1]);
  287. + }
  288. + }
  289. + }
  290. + }
  291. + }
  292. +
  293. + }
  294. + catch (Exception e)
  295. + {
  296. + _log.error(e.getMessage(), e);
  297. + throw new Error("Failed to Load " + ConfigFiles.VIP_FILE + " File.");
  298. + }
  299. + }
  300. +
  301. // Npc Properties
  302. public static boolean SHOW_NPC_LVL;
  303. public static int MAX_DRIFT_RANGE;
  304. @@ -2554,6 +2654,7 @@
  305. loadCustomConfig();
  306. loadOptionsConfig();
  307. loadRatesConfig();
  308. + loadVipConfig();
  309. if (!ReloadHandler.getInstance().isRegistred("config"))
  310. {
  311. ReloadHandler.getInstance().registerHandler("config", _reloadAll);
  312. Index: Dream_GameServer/src/com/dream/game/model/actor/stat/PcStat.java
  313. ===================================================================
  314. --- Dream_GameServer/src/com/dream/game/model/actor/stat/PcStat.java (revision 2099)
  315. +++ Dream_GameServer/src/com/dream/game/model/actor/stat/PcStat.java (working copy)
  316. @@ -129,6 +129,13 @@
  317.  
  318. L2PcInstance activeChar = getActiveChar();
  319.  
  320. + if (Config.ALLOW_VIP_LEVEL && (getLevel() == Config.VIP_DAY_LEVEL))
  321. + {
  322. + activeChar.setVip(true);
  323. + activeChar.setVipEndTime(Config.VIP_LEVEL_GIVE);
  324. + activeChar.doVIP(activeChar);
  325. + }
  326. +
  327. if (levelIncreased)
  328. {
  329. QuestState qs = activeChar.getQuestState("255_Tutorial");
  330. Index: Dream_Commons/src/main/java/com/dream/ConfigFiles.java
  331. ===================================================================
  332. --- Dream_Commons/src/main/java/com/dream/ConfigFiles.java (revision 2099)
  333. +++ Dream_Commons/src/main/java/com/dream/ConfigFiles.java (working copy)
  334. @@ -34,4 +34,5 @@
  335.  
  336. public static final String SAY_FILTER = "./config/admin/sayfilter.txt";
  337.  
  338. + public static final String VIP_FILE = "./config/main/vip.properties";
  339. }
  340. Index: Dream_GameServer/src/com/dream/game/model/actor/L2Attackable.java
  341. ===================================================================
  342. --- Dream_GameServer/src/com/dream/game/model/actor/L2Attackable.java (revision 2099)
  343. +++ Dream_GameServer/src/com/dream/game/model/actor/L2Attackable.java (working copy)
  344. @@ -657,6 +657,17 @@
  345. }
  346. }
  347.  
  348. + if (attacker instanceof L2PcInstance)
  349. + {
  350. + L2PcInstance a = (L2PcInstance) attacker;
  351. +
  352. + if (a.isVip())
  353. + {
  354. + exp *= Config.VIP_XP_SP_RATE;
  355. + sp *= Config.VIP_XP_SP_RATE;
  356. + }
  357. + }
  358. +
  359. // Distribute the Exp and SP between the
  360. // L2PcInstance and its L2Summon
  361. if (isChampion())
  362. @@ -829,6 +840,17 @@
  363. }
  364. }
  365.  
  366. + if (attacker instanceof L2PcInstance)
  367. + {
  368. + L2PcInstance a = (L2PcInstance) attacker;
  369. +
  370. + if (a.isVip())
  371. + {
  372. + exp *= Config.VIP_XP_SP_RATE;
  373. + sp *= Config.VIP_XP_SP_RATE;
  374. + }
  375. + }
  376. +
  377. // champion xp/sp :)
  378. if (isChampion())
  379. {
  380. @@ -1227,14 +1249,26 @@
  381. if (drop.getItemId() == 57)
  382. {
  383. dropChance *= Config.RATE_DROP_ADENA;
  384. + if (lastAttacker.isVip())
  385. + {
  386. + dropChance *= Config.VIP_ADENA_RATE;
  387. + }
  388. }
  389. else if (isSweep)
  390. {
  391. dropChance *= Config.RATE_DROP_SPOIL;
  392. + if (lastAttacker.isVip())
  393. + {
  394. + dropChance *= Config.VIP_SPOIL_RATE;
  395. + }
  396. }
  397. else
  398. {
  399. dropChance *= isRaid() && !isRaidMinion() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
  400. + if (lastAttacker.isVip())
  401. + {
  402. + dropChance *= Config.VIP_DROP_RATE;
  403. + }
  404. }
  405.  
  406. dropChance = Math.round(dropChance) * champRate;
  407. @@ -1364,14 +1398,21 @@
  408. }
  409.  
  410. int dropChance = drop.getChance();
  411. -
  412. if (drop.getItemId() == 57)
  413. {
  414. dropChance *= Config.RATE_DROP_ADENA;
  415. + if (lastAttacker.isVip())
  416. + {
  417. + dropChance *= Config.VIP_ADENA_RATE;
  418. + }
  419. }
  420. else
  421. {
  422. dropChance *= isRaid() && !isRaidMinion() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
  423. + if (lastAttacker.isVip())
  424. + {
  425. + dropChance *= Config.VIP_DROP_RATE;
  426. + }
  427. }
  428.  
  429. dropChance = Math.round(dropChance) * champRate;
  430. Index: Dream_GameServer/src/com/dream/game/network/clientpackets/EnterWorld.java
  431. ===================================================================
  432. --- Dream_GameServer/src/com/dream/game/network/clientpackets/EnterWorld.java (revision 2099)
  433. +++ Dream_GameServer/src/com/dream/game/network/clientpackets/EnterWorld.java (working copy)
  434. @@ -1,5 +1,8 @@
  435. package com.dream.game.network.clientpackets;
  436.  
  437. +import java.util.Calendar;
  438. +import java.util.Date;
  439. +
  440. import org.apache.log4j.Logger;
  441.  
  442. import com.dream.Config;
  443. @@ -46,7 +49,9 @@
  444. import com.dream.game.model.restriction.ObjectRestrictions;
  445. import com.dream.game.model.world.L2World;
  446. import com.dream.game.model.zone.L2Zone;
  447. +import com.dream.game.network.SystemChatChannelId;
  448. import com.dream.game.network.SystemMessageId;
  449. +import com.dream.game.network.serverpackets.CreatureSay;
  450. import com.dream.game.network.serverpackets.Die;
  451. import com.dream.game.network.serverpackets.EtcStatusUpdate;
  452. import com.dream.game.network.serverpackets.ExStorageMaxCount;
  453. @@ -335,6 +340,21 @@
  454.  
  455. ObjectRestrictions.getInstance().resumeTasks(activeChar.getObjectId());
  456.  
  457. + if (activeChar.isVip())
  458. + {
  459. + onEnterVip(activeChar);
  460. + }
  461. +
  462. + if (Config.ALLOW_VIP_NCOLOR && activeChar.isVip())
  463. + {
  464. + activeChar.getAppearance().setNameColor(Config.VIP_NCOLOR);
  465. + }
  466. +
  467. + if (Config.ALLOW_VIP_TCOLOR && activeChar.isVip())
  468. + {
  469. + activeChar.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  470. + }
  471. +
  472. if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
  473. {
  474. activeChar.checkAllowedSkills();
  475. @@ -564,4 +584,30 @@
  476. }
  477. }
  478.  
  479. + private static void onEnterVip(L2PcInstance activeChar)
  480. + {
  481. + long now = Calendar.getInstance().getTimeInMillis();
  482. + long endDay = activeChar.getVipEndTime();
  483. + if (now > endDay)
  484. + {
  485. + activeChar.setVip(false);
  486. + activeChar.setVipEndTime(0);
  487. + activeChar.lostVipSkills();
  488. + if (Config.ALLOW_VIP_ITEM)
  489. + {
  490. + activeChar.getInventory().destroyItemByItemId("", Config.VIP_ITEMID, 1, activeChar, null);
  491. + activeChar.getWarehouse().destroyItemByItemId("", Config.VIP_ITEMID, 1, activeChar, null);
  492. + activeChar.sendPacket(new ItemList(activeChar.getInventory().getItems(), true));
  493. + }
  494. + activeChar.sendPacket(new CreatureSay(0, SystemChatChannelId.Chat_None, "System", "Your VIP period ends."));
  495. + }
  496. + else
  497. + {
  498. + Date dt = new Date(endDay);
  499. + if (activeChar.isVip())
  500. + {
  501. + activeChar.sendMessage("Your VIP period ends at: " + dt);
  502. + }
  503. + }
  504. + }
  505. }
  506. \ No newline at end of file
  507. Index: Dream_GameServer/src/com/dream/game/handler/admin/AdminVip.java
  508. ===================================================================
  509. --- Dream_GameServer/src/com/dream/game/handler/admin/AdminVip.java (revision 0)
  510. +++ Dream_GameServer/src/com/dream/game/handler/admin/AdminVip.java (working copy)
  511. @@ -0,0 +1,114 @@
  512. +/*
  513. + * This program is free software; you can redistribute it and/or modify
  514. + * it under the terms of the GNU General Public License as published by
  515. + * the Free Software Foundation; either version 2, or (at your option)
  516. + * any later version.
  517. + *
  518. + * This program is distributed in the hope that it will be useful,
  519. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  520. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  521. + * GNU General Public License for more details.
  522. + *
  523. + * You should have received a copy of the GNU General Public License
  524. + * along with this program; if not, write to the Free Software
  525. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  526. + * 02111-1307, USA.
  527. + *
  528. + * http://www.gnu.org/copyleft/gpl.html
  529. + */
  530. +package com.dream.game.handler.admin;
  531. +
  532. +import org.apache.log4j.Logger;
  533. +
  534. +import com.dream.Config;
  535. +import com.dream.game.access.gmHandler;
  536. +import com.dream.game.model.L2Object;
  537. +import com.dream.game.model.actor.instance.L2PcInstance;
  538. +import com.dream.game.model.world.L2World;
  539. +
  540. +public class AdminVip extends gmHandler
  541. +{
  542. + private static String[] _adminCommands =
  543. + {
  544. + "setvip",
  545. + "removevip"
  546. + };
  547. +
  548. + protected static Logger _log = Logger.getLogger(Config.class.getName());
  549. +
  550. + @Override
  551. + public void runCommand(L2PcInstance admin, String... params)
  552. + {
  553. + final String command = params[0];
  554. +
  555. + if (command.startsWith("setvip"))
  556. + {
  557. + L2Object target = admin.getTarget();
  558. + L2PcInstance player = L2World.getInstance().getPlayer(params[1]);
  559. +
  560. + if ((target != null) && (target instanceof L2PcInstance))
  561. + {
  562. + player = (L2PcInstance) target;
  563. + }
  564. + else
  565. + {
  566. + player = admin;
  567. + }
  568. +
  569. + try
  570. + {
  571. + String playername = player.getName();
  572. + admin.doVip(player, playername, params[2]);
  573. + }
  574. + catch (Exception e)
  575. + {
  576. + admin.sendMessage("Usage: //setvip <name> [time](in days)");
  577. + }
  578. +
  579. + player.broadcastUserInfo();
  580. +
  581. + if (player.isVip())
  582. + {
  583. + return;
  584. + }
  585. + }
  586. + else if (command.startsWith("removevip"))
  587. + {
  588. + L2Object target = admin.getTarget();
  589. + L2PcInstance player = null;
  590. +
  591. + if (target instanceof L2PcInstance)
  592. + {
  593. + player = (L2PcInstance) target;
  594. + }
  595. + else
  596. + {
  597. + player = admin;
  598. + }
  599. +
  600. + try
  601. + {
  602. + String playername = player.getName();
  603. + admin.removeVip(player, playername);
  604. + }
  605. + catch (Exception e)
  606. + {
  607. + admin.sendMessage("Usage: //removevip <char_name>");
  608. + }
  609. +
  610. + player.broadcastUserInfo();
  611. +
  612. + if (!player.isVip())
  613. + {
  614. + return;
  615. + }
  616. + }
  617. + return;
  618. + }
  619. +
  620. + @Override
  621. + public String[] getCommandList()
  622. + {
  623. + return _adminCommands;
  624. + }
  625. +}
  626. \ No newline at end of file
  627. Index: Dream_GameServer/src/com/dream/game/network/clientpackets/CharacterCreate.java
  628. ===================================================================
  629. --- Dream_GameServer/src/com/dream/game/network/clientpackets/CharacterCreate.java (revision 2099)
  630. +++ Dream_GameServer/src/com/dream/game/network/clientpackets/CharacterCreate.java (working copy)
  631. @@ -191,6 +191,13 @@
  632. }
  633. }
  634.  
  635. + if (Config.ALLOW_CUSTOM_CHAR_VIP)
  636. + {
  637. + newChar.setVip(true);
  638. + newChar.setVipEndTime(Config.CUSTOM_DAY_VIP);
  639. + newChar.doVIP(newChar);
  640. + }
  641. +
  642. startTutorialQuest(newChar);
  643. newChar.store();
  644. newChar.deleteMe();
  645. Index: Dream_GameServer/dist/config/main/vip.properties
  646. ===================================================================
  647. --- Dream_GameServer/dist/config/main/vip.properties (revision 0)
  648. +++ Dream_GameServer/dist/config/main/vip.properties (working copy)
  649. @@ -0,0 +1,84 @@
  650. +#=============================================================
  651. +# VIP System
  652. +#=============================================================
  653. +EnableVipSystem = True
  654. +
  655. +# Enable / Disable Name Color
  656. +AllowVipNameColor = True
  657. +VipNameColor = 88AA88
  658. +
  659. +# Enable / Disable Title Color
  660. +AllowVipTitleColor = True
  661. +VipTitleColor = 88AA88
  662. +
  663. +# VIP Xp/Sp Rate
  664. +VIPXpSpRate = 1.5
  665. +# VIP Adena rate
  666. +VIPAdenaRate = 1.5
  667. +# VIP drop rate
  668. +VIPDropRate = 1.5
  669. +# VIP spoil rate
  670. +VIPSpoilRate = 1.5
  671. +
  672. +# List of Vip Skills
  673. +# Format : skillid,skilllvl;skillid2,skilllvl2;
  674. +VipSkills = 1085,3;1304,3;1087,3;1354,1;1062,2;1243,6;1045,6;1048,6;1429,1;163,1;\
  675. +1311,6;213,8;1007,3;1309,3;1552,3;1006,3;1308,3;1253,3;1284,3;1392,3;1393,3;214,1;\
  676. +1009,3;1310,4;1363,1;1362,1;1397,3;1292,6;1078,6;307,1;276,1;309,1;274,1;275,1;164,3;\
  677. +272,1;277,1;273,1;311,1;366,1;365,1;310,1;271,1;1242,3;1391,3;1002,3;7029,1;\
  678. +1352,1;229,7;228,3;1077,3;1218,33;1059,3;1219,33;1388,3;1389,3;1240,3;1413,1;\
  679. +1086,2;1036,2;1035,4;1068,3;1356,1;1355,1;1357,1;1307,3;1410,1;1409,1;1353,1;\
  680. +1044,3;1182,3;1191,3;1189,3;1259,4;1306,6;234,23;1040,3;364,1;264,1;306,1;\
  681. +269,1;270,1;265,1;363,1;349,1;308,1;305,1;304,1;267,1;266,1;268,1;1390,3;1303,2;\
  682. +1204,2;1268,4
  683. +
  684. +# Custom item for VIP
  685. +AllowVIPItem = True
  686. +
  687. +# ID of the item that will be given to VIP
  688. +# Default: Keshanberk*Keshanberk
  689. +ItemIdVip = 5233
  690. +
  691. +# Allow custom Day's Vip on CharacterCreate
  692. +# Default: False
  693. +AllowCustomStartVip = False
  694. +# Custom Start Days for Vip
  695. +# Default: 1
  696. +CustomStartDays = 1
  697. +
  698. +# Allow VipLevel when Char reach LEVEL
  699. +# Default: False
  700. +AllowVipLevel = False
  701. +
  702. +# Level need to rech to doVIP
  703. +VipDayLevel = 10
  704. +
  705. +# Time in Day's GIVE reach LEVEL
  706. +VipLevelGive = 15
  707. +
  708. +# Vip Item Use's
  709. +# ID of the item that you will put the player to become VIP!
  710. +VipItem1 = 5567
  711. +
  712. +# Number of days that the player get VIP!
  713. +VipItemDay1 = 7
  714. +
  715. +# ID of the item that you will put the player to become VIP!
  716. +VipItem2 = 5568
  717. +
  718. +# Number of days that the player get VIP!
  719. +VipItemDay2 = 15
  720. +
  721. +# ID of the item that you will put the player to become VIP!
  722. +VipItem3 = 5569
  723. +
  724. +# Number of days that the player get VIP!
  725. +VipItemDay3 = 30
  726. +
  727. +# System Vip Teleport Command
  728. +# Arena Teleport
  729. +# Vip Teleport Command .viptele
  730. +AllowVipTele = True
  731. +VipTeleX = 36554
  732. +VipTeley = -6654
  733. +VipTelez = 1644
  734. \ No newline at end of file
  735. Index: Dream_GameServer/src/com/dream/game/model/actor/instance/L2PcInstance.java
  736. ===================================================================
  737. --- Dream_GameServer/src/com/dream/game/model/actor/instance/L2PcInstance.java (revision 2099)
  738. +++ Dream_GameServer/src/com/dream/game/model/actor/instance/L2PcInstance.java (working copy)
  739. @@ -245,6 +245,10 @@
  740. private boolean _showTraders = true;
  741. private boolean _showBuffAnimation = true;
  742.  
  743. + /** VIP System */
  744. + private boolean _isVip = false;
  745. + private long _vip_endTime = 0;
  746. +
  747. private boolean _GmStatus = false;
  748. private boolean _AllowFixRes = false;
  749. private boolean _AllowAltG = false;
  750. @@ -270,9 +274,9 @@
  751.  
  752. private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE charId = ? AND class_index = ?";
  753.  
  754. - private static final String UPDATE_CHARACTER = "UPDATE characters SET level = ?, maxHp = ?, curHp = ?, maxCp = ?, curCp = ?, maxMp = ?, curMp = ?, face = ?, hairStyle = ?, hairColor = ?, heading = ?, x = ?, y = ?, z = ?, exp = ?, expBeforeDeath = ?, sp = ?, karma = ?, pvpkills = ?, pkkills = ?, rec_have = ?, rec_left = ?, clanid = ?, race = ?, classid = ?, deletetime = ?, title = ?, online = ?, isin7sdungeon = ?, clan_privs = ?, wantspeace = ?, base_class = ?, onlinetime = ?, in_jail = ?, jail_timer = ?, newbie = ?, nobless = ?, pledge_rank = ?, subpledge = ?, last_recom_date = ?, lvl_joined_academy = ?, apprentice = ?, sponsor = ?, varka_ketra_ally = ?, clan_join_expiry_time = ?, clan_create_expiry_time = ?, char_name = ?, death_penalty_level = ?, pccaffe_points = ?, isBanned = ?, hwid = ? WHERE charId = ?";
  755. + private static final String UPDATE_CHARACTER = "UPDATE characters SET level = ?, maxHp = ?, curHp = ?, maxCp = ?, curCp = ?, maxMp = ?, curMp = ?, face = ?, hairStyle = ?, hairColor = ?, heading = ?, x = ?, y = ?, z = ?, exp = ?, expBeforeDeath = ?, sp = ?, karma = ?, pvpkills = ?, pkkills = ?, rec_have = ?, rec_left = ?, clanid = ?, race = ?, classid = ?, deletetime = ?, title = ?, online = ?, isin7sdungeon = ?, clan_privs = ?, wantspeace = ?, base_class = ?, onlinetime = ?, in_jail = ?, jail_timer = ?, newbie = ?, nobless = ?, pledge_rank = ?, subpledge = ?, last_recom_date = ?, lvl_joined_academy = ?, apprentice = ?, sponsor = ?, varka_ketra_ally = ?, clan_join_expiry_time = ?, clan_create_expiry_time = ?, char_name = ?, death_penalty_level = ?, pccaffe_points = ?, isBanned = ?, hwid = ?, vip = ?, vip_end = ? WHERE charId = ?";
  756.  
  757. - private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, pledge_rank, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally, clan_join_expiry_time, clan_create_expiry_time, death_penalty_level, pccaffe_points, isBanned, hwid FROM characters WHERE charId = ?";
  758. + private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, pledge_rank, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally, clan_join_expiry_time, clan_create_expiry_time, death_penalty_level, pccaffe_points, isBanned, hwid, vip, vip_end FROM characters WHERE charId = ?";
  759.  
  760. private static final String CREATE_CHARACTER = "INSERT INTO characters (account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, exp, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, online, isin7sdungeon, clan_privs, wantspeace, base_class, newbie, nobless, pledge_rank, last_recom_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  761.  
  762. @@ -5891,6 +5895,10 @@
  763. player.setLvlJoinedAcademy(rset.getInt("lvl_joined_academy"));
  764. player.setAllianceWithVarkaKetra(rset.getInt("varka_ketra_ally"));
  765. player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
  766. +
  767. + player.setVip(rset.getInt("vip") == 1 ? true : false);
  768. + player.setVipEndTime(rset.getLong("vip_end"));
  769. +
  770. player.getPosition().setXYZInvisible(rset.getInt("x"), rset.getInt("y"), rset.getInt("z"));
  771.  
  772. PreparedStatement stmt = con.prepareStatement("SELECT charId, char_name FROM characters WHERE account_name=? AND charId<>?");
  773. @@ -6441,7 +6449,9 @@
  774. statement.setLong(49, _pccaffe);
  775. statement.setInt(50, isBanned() ? 1 : 0);
  776. statement.setString(51, getHWid());
  777. - statement.setInt(52, getObjectId());
  778. + statement.setInt(52, isVip() ? 1 : 0);
  779. + statement.setLong(53, getVipEndTime());
  780. + statement.setInt(54, getObjectId());
  781. statement.execute();
  782. statement.close();
  783. }
  784. @@ -13378,4 +13388,172 @@
  785. {
  786. sendPacket(new CreatureSay(objectId, SystemChatChannelId.Chat_None, charName, text));
  787. }
  788. +
  789. + public boolean isVip()
  790. + {
  791. + return _isVip;
  792. + }
  793. +
  794. + public void setVip(boolean val)
  795. + {
  796. + _isVip = val;
  797. + }
  798. +
  799. + public long getVipEndTime()
  800. + {
  801. + return _vip_endTime;
  802. + }
  803. +
  804. + public void setVipEndTime(long val)
  805. + {
  806. + _vip_endTime = val;
  807. + }
  808. +
  809. + public void rewardVipSkills()
  810. + {
  811. + L2Skill skill;
  812. + for (Integer skillid : Config.VIP_SKILLS.keySet())
  813. + {
  814. + int skilllvl = Config.VIP_SKILLS.get(skillid);
  815. + skill = SkillTable.getInstance().getInfo(skillid, skilllvl);
  816. + if (skill != null)
  817. + {
  818. + addSkill(skill, true);
  819. + }
  820. + }
  821. + }
  822. +
  823. + public void lostVipSkills()
  824. + {
  825. + for (L2Skill skill : this.getAllSkills())
  826. + {
  827. + this.removeSkill(skill);
  828. + }
  829. + }
  830. +
  831. + public void setEndTime(String process, int val)
  832. + {
  833. + Calendar calendar = Calendar.getInstance();
  834. + calendar.add(Calendar.DAY_OF_MONTH, val);
  835. + long end_day = calendar.getTimeInMillis();
  836. +
  837. + if (process.equals("vip"))
  838. + {
  839. + _vip_endTime = end_day;
  840. + }
  841. + }
  842. +
  843. + public void doVip(L2PcInstance _player, String _playername, String _time)
  844. + {
  845. + int days = Integer.parseInt(_time);
  846. +
  847. + if ((_player == null) || _player.isVip())
  848. + {
  849. + return;
  850. + }
  851. +
  852. + if (days > 0)
  853. + {
  854. + _player.lostVipSkills();
  855. + _player.setVip(true);
  856. + _player.setEndTime("vip", days);
  857. + _player.sendPacket(new CreatureSay(0, SystemChatChannelId.Chat_None, "System", "Dear player, you are now an VIP, congratulations."));
  858. +
  859. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  860. + {
  861. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET vip = 1, vip_end = ? WHERE charId=?");
  862. + statement.setLong(1, _player.getVipEndTime());
  863. + statement.setInt(2, _player.getObjectId());
  864. + statement.execute();
  865. + statement.close();
  866. +
  867. + if (Config.ALLOW_VIP_NCOLOR)
  868. + {
  869. + _player.getAppearance().setNameColor(Config.VIP_NCOLOR);
  870. + }
  871. +
  872. + if (Config.ALLOW_VIP_TCOLOR)
  873. + {
  874. + _player.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  875. + }
  876. +
  877. + _player.rewardVipSkills();
  878. +
  879. + if (Config.ALLOW_VIP_ITEM)
  880. + {
  881. + _player.getInventory().addItem("", Config.VIP_ITEMID, 1, _player, null);
  882. + _player.getInventory().equipItem(_player.getInventory().getItemByItemId(Config.VIP_ITEMID));
  883. + _player.sendPacket(new ItemList(_player.getInventory().getItems(), true));
  884. +
  885. + }
  886. + _player.broadcastUserInfo();
  887. + _player.sendSkillList();
  888. + }
  889. + catch (Exception e)
  890. + {
  891. + _log.warn("Something went wrong, check log folder for details", e);
  892. + }
  893. + }
  894. + }
  895. +
  896. + public void removeVip(L2PcInstance _player, String _playername)
  897. + {
  898. + if (!_player.isVip())
  899. + {
  900. + return;
  901. + }
  902. +
  903. + _player.setVip(false);
  904. + _player.setVipEndTime(0);
  905. +
  906. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  907. + {
  908. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET vip = 0, vip_end = 0 WHERE charId = ?");
  909. + statement.setInt(1, _player.getObjectId());
  910. + statement.execute();
  911. + statement.close();
  912. +
  913. + _player.lostVipSkills();
  914. +
  915. + if (Config.ALLOW_VIP_ITEM)
  916. + {
  917. + _player.getInventory().destroyItemByItemId("", Config.VIP_ITEMID, 1, _player, null);
  918. + _player.getWarehouse().destroyItemByItemId("", Config.VIP_ITEMID, 1, _player, null);
  919. + _player.sendPacket(new ItemList(_player.getInventory().getItems(), true));
  920. + }
  921. + _player.getAppearance().setNameColor(0xFFFFFF);
  922. + _player.getAppearance().setTitleColor(0xFFFF77);
  923. + _player.broadcastUserInfo();
  924. + _player.sendSkillList();
  925. + }
  926. + catch (Exception e)
  927. + {
  928. + _log.warn("Something went wrong, check log folder for details", e);
  929. + }
  930. + }
  931. +
  932. + public void doVIP(L2PcInstance _player)
  933. + {
  934. + if (Config.ALLOW_VIP_NCOLOR)
  935. + {
  936. + _player.getAppearance().setNameColor(Config.VIP_NCOLOR);
  937. + }
  938. +
  939. + if (Config.ALLOW_VIP_TCOLOR)
  940. + {
  941. + _player.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  942. + }
  943. +
  944. + _player.rewardVipSkills();
  945. +
  946. + if (Config.ALLOW_VIP_ITEM)
  947. + {
  948. + _player.getInventory().addItem("", Config.VIP_ITEMID, 1, _player, null);
  949. + _player.getInventory().equipItem(_player.getInventory().getItemByItemId(Config.VIP_ITEMID));
  950. + _player.sendPacket(new ItemList(_player.getInventory().getItems(), true));
  951. +
  952. + }
  953. + _player.broadcastUserInfo();
  954. + _player.sendSkillList();
  955. + }
  956. }
  957. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement