Advertisement
Guest User

Namer system.

a guest
Jun 10th, 2011
911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.54 KB | None | 0 0
  1. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  2. ===================================================================
  3. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 114)
  4. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  5. @@ -26,6 +26,7 @@
  6. import java.util.Collection;
  7. import java.util.List;
  8. import java.util.Map;
  9. +import java.util.Set;
  10. import java.util.concurrent.Future;
  11. import java.util.concurrent.ScheduledFuture;
  12. import java.util.concurrent.TimeUnit;
  13. @@ -223,6 +224,9 @@
  14. */
  15. public final class L2PcInstance extends L2Playable
  16. {
  17. + // Namers.
  18. + private boolean isNamer = false;
  19. +
  20. // Character Skill SQL String Definitions:
  21. private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
  22. private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
  23. @@ -4771,6 +4775,29 @@
  24. {
  25. // Add karma to attacker and increase its PK counter
  26. setPvpKills(getPvpKills() + 1);
  27. +
  28. + if (isNamer())
  29. + {
  30. + if (Config.NAMERS_NAME_COLOR)
  31. + {
  32. + if (!Config.NAMES_NAME_COLOR_STATIC)
  33. + {
  34. + if (Config.COLOR_NAME_DEPENDS.equals("PVP"))
  35. + {
  36. + Set<Integer> pvps = Config.NAMERS_NAME_COLORS.keySet();
  37. +
  38. + for (int i : pvps)
  39. + {
  40. + if (getPvpKills() >= i)
  41. + {
  42. + getAppearance().setNameColor(Config.NAMERS_NAME_COLORS.get(i));
  43. + broadcastUserInfo();
  44. + }
  45. + }
  46. + }
  47. + }
  48. + }
  49. + }
  50.  
  51. // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  52. sendPacket(new UserInfo(this));
  53. @@ -4829,6 +4856,29 @@
  54. // Add karma to attacker and increase its PK counter
  55. setPkKills(getPkKills() + 1);
  56. setKarma(getKarma() + newKarma);
  57. +
  58. + if (isNamer())
  59. + {
  60. + if (Config.NAMERS_TITLE_COLOR)
  61. + {
  62. + if (!Config.NAMES_TITLE_COLOR_STATIC)
  63. + {
  64. + if (Config.COLOR_TITLE_DEPENDS.equals("PK"))
  65. + {
  66. + Set<Integer> pks = Config.NAMERS_TITLE_COLORS.keySet();
  67. +
  68. + for (int i : pks)
  69. + {
  70. + if (getPkKills() >= i)
  71. + {
  72. + getAppearance().setTitleColor(Config.NAMERS_TITLE_COLORS.get(i));
  73. + broadcastUserInfo();
  74. + }
  75. + }
  76. + }
  77. + }
  78. + }
  79. + }
  80.  
  81. // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  82. sendPacket(new UserInfo(this));
  83. @@ -11355,4 +11405,139 @@
  84. }
  85. }
  86. }
  87. +
  88. + public void setNamer(boolean val)
  89. + {
  90. + if (!val)
  91. + {
  92. + for (int i : Config.NAMERS_CUSTOM_SKILLS.keySet())
  93. + {
  94. + L2Skill s = SkillTable.getInstance().getInfo(i, Config.NAMERS_CUSTOM_SKILLS.get(i));
  95. + removeSkill(s);
  96. + }
  97. +
  98. + setName(getName().substring(Config.NAMERS_NAME_PREFIX.length()));
  99. + getAppearance().setNameColor(0xFFFFFF);
  100. + broadcastUserInfo();
  101. + }
  102. + else
  103. + {
  104. + if (Config.ALLOW_NAMERS_CUSTOM_SKILLS)
  105. + {
  106. + for (int i : Config.NAMERS_CUSTOM_SKILLS.keySet())
  107. + {
  108. + L2Skill s = SkillTable.getInstance().getInfo(i, Config.NAMERS_CUSTOM_SKILLS.get(i));
  109. + addSkill(s);
  110. + }
  111. + }
  112. +
  113. + if (Config.NAMERS_HAVE_NAME_PREFIX)
  114. + {
  115. + setName(Config.NAMERS_NAME_PREFIX+getName());
  116. + }
  117. +
  118. + if (Config.NAMERS_NAME_COLOR)
  119. + {
  120. + if (Config.NAMES_NAME_COLOR_STATIC)
  121. + {
  122. + getAppearance().setNameColor(Config.NAMES_NAME_STATIC_COLOR);
  123. + broadcastUserInfo();
  124. + }
  125. + else
  126. + {
  127. + if (Config.COLOR_NAME_DEPENDS.equals("PVP"))
  128. + {
  129. + Set<Integer> pvps = Config.NAMERS_NAME_COLORS.keySet();
  130. +
  131. + for (int i : pvps)
  132. + {
  133. + if (getPvpKills() == i)
  134. + {
  135. + getAppearance().setNameColor(Config.NAMERS_NAME_COLORS.get(i));
  136. + }
  137. + }
  138. + }
  139. + if (Config.COLOR_NAME_DEPENDS.equals("PK"))
  140. + {
  141. + Set<Integer> pks = Config.NAMERS_NAME_COLORS.keySet();
  142. +
  143. + for (int i : pks)
  144. + {
  145. + if (getPkKills() == i)
  146. + {
  147. + getAppearance().setNameColor(Config.NAMERS_NAME_COLORS.get(i));
  148. + }
  149. + }
  150. + }
  151. + if (Config.COLOR_NAME_DEPENDS.equals("LEVEL"))
  152. + {
  153. + Set<Integer> levels = Config.NAMERS_NAME_COLORS.keySet();
  154. +
  155. + for (int i : levels)
  156. + {
  157. + if (getLevel() == i)
  158. + {
  159. + getAppearance().setNameColor(Config.NAMERS_NAME_COLORS.get(i));
  160. + }
  161. + }
  162. + }
  163. + }
  164. + }
  165. +
  166. + if (Config.NAMERS_TITLE_COLOR)
  167. + {
  168. + if (Config.NAMES_TITLE_COLOR_STATIC)
  169. + {
  170. + getAppearance().setTitleColor(Config.NAMES_TITLE_STATIC_COLOR);
  171. + broadcastUserInfo();
  172. + }
  173. + else
  174. + {
  175. + if (Config.COLOR_TITLE_DEPENDS.equals("PVP"))
  176. + {
  177. + Set<Integer> pvps = Config.NAMERS_TITLE_COLORS.keySet();
  178. +
  179. + for (int i : pvps)
  180. + {
  181. + if (getPvpKills() >= i)
  182. + {
  183. + getAppearance().setTitleColor(Config.NAMERS_TITLE_COLORS.get(i));
  184. + }
  185. + }
  186. + }
  187. + if (Config.COLOR_TITLE_DEPENDS.equals("PK"))
  188. + {
  189. + Set<Integer> pks = Config.NAMERS_TITLE_COLORS.keySet();
  190. +
  191. + for (int i : pks)
  192. + {
  193. + if (getPkKills() >= i)
  194. + {
  195. + getAppearance().setTitleColor(Config.NAMERS_TITLE_COLORS.get(i));
  196. + }
  197. + }
  198. + }
  199. + if (Config.COLOR_TITLE_DEPENDS.equals("LEVEL"))
  200. + {
  201. + Set<Integer> levels = Config.NAMERS_TITLE_COLORS.keySet();
  202. +
  203. + for (int i : levels)
  204. + {
  205. + if (getLevel() >= i)
  206. + {
  207. + getAppearance().setTitleColor(Config.NAMERS_TITLE_COLORS.get(i));
  208. + }
  209. + }
  210. + }
  211. + }
  212. + }
  213. + }
  214. +
  215. + isNamer = val;
  216. + }
  217. +
  218. + public boolean isNamer()
  219. + {
  220. + return isNamer;
  221. + }
  222. }
  223. \ No newline at end of file
  224. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
  225. ===================================================================
  226. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 114)
  227. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
  228. @@ -15,9 +15,13 @@
  229. package net.sf.l2j.gameserver.handler.chathandlers;
  230.  
  231. import java.util.Collection;
  232. +import java.util.Vector;
  233.  
  234. +import net.sf.l2j.Config;
  235. import net.sf.l2j.gameserver.handler.IChatHandler;
  236. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminNameSystem;
  237. import net.sf.l2j.gameserver.model.BlockList;
  238. +import net.sf.l2j.gameserver.model.L2World;
  239. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  240. import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  241.  
  242. @@ -38,14 +42,47 @@
  243. {
  244. CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  245. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  246. -
  247. - for (L2PcInstance player : plrs)
  248. +
  249. + boolean saidToNamers = false;
  250. + if (activeChar.isNamer())
  251. {
  252. - if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
  253. - player.sendPacket(cs);
  254. + if (Config.NAMERS_CUSTOM_CHAT)
  255. + {
  256. + if (text.startsWith(Config.NAMERS_CUSTOM_CHAT_PREFIX))
  257. + {
  258. + String txt = text.substring(1);
  259. + CreatureSay csN = new CreatureSay(activeChar.getObjectId(), 15, activeChar.getName(), txt);
  260. + Vector<L2PcInstance> namers = new Vector<L2PcInstance>();
  261. +
  262. + for (String s : AdminNameSystem.getAllNamers())
  263. + {
  264. + L2PcInstance p = L2World.getInstance().getPlayer(s);
  265. + if (p != null)
  266. + {
  267. + namers.add(p);
  268. + }
  269. + }
  270. +
  271. + for (L2PcInstance p : namers)
  272. + {
  273. + p.sendPacket(csN);
  274. + }
  275. +
  276. + saidToNamers = true;
  277. + }
  278. + }
  279. }
  280. +
  281. + if (!saidToNamers)
  282. + {
  283. + for (L2PcInstance player : plrs)
  284. + {
  285. + if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
  286. + player.sendPacket(cs);
  287. + }
  288.  
  289. - activeChar.sendPacket(cs);
  290. + activeChar.sendPacket(cs);
  291. + }
  292. }
  293.  
  294. /**
  295. Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  296. ===================================================================
  297. --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 114)
  298. +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
  299. @@ -49,6 +49,14 @@
  300.  
  301. if (player == null)
  302. return;
  303. +
  304. + if (player.isNamer())
  305. + {
  306. + String i = Config.NAMERS_NAME_PREFIX;
  307. + String ii = player.getName();
  308. + String iii = player.getName().substring(i.length());
  309. + player.setName(iii);
  310. + }
  311.  
  312. player.getInventory().updateDatabase();
  313.  
  314. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  315. ===================================================================
  316. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 114)
  317. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
  318. @@ -31,6 +31,7 @@
  319. import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
  320. import net.sf.l2j.gameserver.datatables.MapRegionTable;
  321. import net.sf.l2j.gameserver.datatables.SkillTable;
  322. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminNameSystem;
  323. import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
  324. import net.sf.l2j.gameserver.instancemanager.CoupleManager;
  325. import net.sf.l2j.gameserver.instancemanager.DimensionalRiftManager;
  326. @@ -87,6 +88,20 @@
  327. getClient().closeNow();
  328. return;
  329. }
  330. +
  331. + if (AdminNameSystem.getAllNamers().contains(activeChar.getName()))
  332. + {
  333. + activeChar.setNamer(true);
  334. + activeChar.broadcastUserInfo();
  335. + }
  336. +
  337. + if (activeChar.isNamer())
  338. + {
  339. + if (Config.NAMERS_ANNOUNCE_ON_LOGIN)
  340. + {
  341. + Announcements.getInstance().announceToAll(activeChar.getName()+", a server's "+Config.NAME_SYSTEM_NAME+", has logged in.");
  342. + }
  343. + }
  344.  
  345. // Register in flood protector
  346. FloodProtector.getInstance().registerNewPlayer(activeChar.getObjectId());
  347. Index: java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
  348. ===================================================================
  349. --- java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java (revision 114)
  350. +++ java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java (working copy)
  351. @@ -294,7 +294,7 @@
  352.  
  353. writeD(_activeChar.getClanCrestLargeId());
  354. writeC(_activeChar.isNoble() ? 1 : 0); //0x01: symbol on char menu ctrl+I
  355. - writeC((_activeChar.isHero() || (_activeChar.isGM() && Config.GM_HERO_AURA)) ? 1 : 0); //0x01: Hero Aura
  356. + writeC((_activeChar.isHero() || (_activeChar.isGM() && Config.GM_HERO_AURA) || (_activeChar.isNamer() && Config.NAMERS_HERO_AURA)) ? 1 : 0); //0x01: Hero Aura
  357.  
  358. writeC(_activeChar.isFishing() ? 1 : 0); //Fishing Mode
  359. writeD(_activeChar.getFishx()); //fishing x
  360. Index: config/namesystem.info
  361. ===================================================================
  362. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  363. ===================================================================
  364. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 114)
  365. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
  366. @@ -51,6 +51,14 @@
  367.  
  368. if (player == null)
  369. return;
  370. +
  371. + if (player.isNamer())
  372. + {
  373. + String i = Config.NAMERS_NAME_PREFIX;
  374. + String ii = player.getName();
  375. + String iii = player.getName().substring(i.length());
  376. + player.setName(iii);
  377. + }
  378.  
  379. if(player.getActiveEnchantItem() != null)
  380. {
  381. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  382. ===================================================================
  383. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 114)
  384. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  385. @@ -50,6 +50,7 @@
  386. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminManor;
  387. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminMenu;
  388. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminMonsterRace;
  389. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminNameSystem;
  390. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminPForge;
  391. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminPathNode;
  392. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminPetition;
  393. @@ -129,6 +130,10 @@
  394. registerAdminCommandHandler(new AdminTeleport());
  395. registerAdminCommandHandler(new AdminUnblockIp());
  396. registerAdminCommandHandler(new AdminZone());
  397. + if (Config.ALLOW_NAME_ADMIN_COMMAND)
  398. + {
  399. + registerAdminCommandHandler(new AdminNameSystem());
  400. + }
  401. }
  402.  
  403. public void registerAdminCommandHandler(IAdminCommandHandler handler)
  404. Index: java/net/sf/l2j/Config.java
  405. ===================================================================
  406. --- java/net/sf/l2j/Config.java (revision 114)
  407. +++ java/net/sf/l2j/Config.java (working copy)
  408. @@ -29,11 +29,13 @@
  409. import java.math.BigInteger;
  410. import java.util.Arrays;
  411. import java.util.List;
  412. +import java.util.Map;
  413. import java.util.Properties;
  414. import java.util.StringTokenizer;
  415. import java.util.logging.Logger;
  416.  
  417. import javolution.util.FastList;
  418. +import javolution.util.FastMap;
  419. import net.sf.l2j.util.StringUtil;
  420.  
  421. /**
  422. @@ -418,6 +420,29 @@
  423. /** Buffs */
  424. public static boolean STORE_SKILL_COOLTIME;
  425. public static byte BUFFS_MAX_AMOUNT;
  426. +
  427. + /** Namers */
  428. + public static String NAME_SYSTEM_NAME;
  429. + public static boolean ALLOW_NAME_ADMIN_COMMAND;
  430. + public static boolean NAMERS_NAME_COLOR;
  431. + public static boolean NAMES_NAME_COLOR_STATIC;
  432. + public static int NAMES_NAME_STATIC_COLOR;
  433. + public static String COLOR_NAME_DEPENDS;
  434. + public static Map<Integer, Integer> NAMERS_NAME_COLORS = new FastMap<Integer, Integer>();
  435. + public static boolean NAMERS_TITLE_COLOR;
  436. + public static boolean NAMES_TITLE_COLOR_STATIC;
  437. + public static int NAMES_TITLE_STATIC_COLOR;
  438. + public static String COLOR_TITLE_DEPENDS;
  439. + public static Map<Integer, Integer> NAMERS_TITLE_COLORS = new FastMap<Integer, Integer>();
  440. + public static boolean ALLOW_NAMERS_CUSTOM_SKILLS;
  441. + public static Map<Integer, Integer> NAMERS_CUSTOM_SKILLS = new FastMap<Integer, Integer>();
  442. + public static boolean NAMERS_HERO_AURA;
  443. + public static boolean NAMERS_ANNOUNCE_ON_BECOME;
  444. + public static boolean NAMERS_ANNOUNCE_ON_LOGIN;
  445. + public static boolean NAMERS_CUSTOM_CHAT;
  446. + public static String NAMERS_CUSTOM_CHAT_PREFIX;
  447. + public static boolean NAMERS_HAVE_NAME_PREFIX;
  448. + public static String NAMERS_NAME_PREFIX;
  449.  
  450. //--------------------------------------------------
  451. // Server
  452. @@ -1022,6 +1047,46 @@
  453.  
  454. BUFFS_MAX_AMOUNT = Byte.parseByte(players.getProperty("MaxBuffsAmount","20"));
  455. STORE_SKILL_COOLTIME = Boolean.parseBoolean(players.getProperty("StoreSkillCooltime", "true"));
  456. +
  457. + NAME_SYSTEM_NAME = players.getProperty("NameSystemName", "Donator");
  458. + ALLOW_NAME_ADMIN_COMMAND = Boolean.parseBoolean(players.getProperty("AllowNameAdminCommand", "true"));
  459. + NAMERS_NAME_COLOR = Boolean.parseBoolean(players.getProperty("NamersNameColor", "false"));
  460. + NAMES_NAME_COLOR_STATIC = Boolean.parseBoolean(players.getProperty("NamesNameColorStatic", "true"));
  461. + NAMES_NAME_STATIC_COLOR = Integer.decode("0x" + players.getProperty("NamesNameStaticColor", "0000FF"));
  462. + COLOR_NAME_DEPENDS = players.getProperty("ColorNameDepends", "PVP");
  463. + String NAMERS_NAME_COLOR_C = players.getProperty("NamersNameColorC", "100,00FF00;200,FF0000;300,0000FF;");
  464. + String[] namers_name_color_c_splitted = NAMERS_NAME_COLOR_C.split(";");
  465. + for (String s : namers_name_color_c_splitted)
  466. + {
  467. + String[] i = s.split(",");
  468. + NAMERS_NAME_COLORS.put(Integer.parseInt(i[0]), Integer.decode("0x"+i[1]));
  469. + }
  470. + NAMERS_TITLE_COLOR = Boolean.parseBoolean(players.getProperty("NamersTitleColor", "false"));
  471. + NAMES_TITLE_COLOR_STATIC = Boolean.parseBoolean(players.getProperty("NamesTitleColorStatic", "true"));
  472. + NAMES_TITLE_STATIC_COLOR = Integer.decode("0x" + players.getProperty("NamesTitleStaticColor", "FF0000"));
  473. + COLOR_TITLE_DEPENDS = players.getProperty("ColorTitleDepends", "PK");
  474. + String NAMERS_TITLE_COLOR_C = players.getProperty("NamersTitleColorC", "100,00FF00;200,FF0000;300,0000FF;");
  475. + String[] namers_title_color_c_splitted = NAMERS_TITLE_COLOR_C.split(";");
  476. + for (String s : namers_title_color_c_splitted)
  477. + {
  478. + String[] i = s.split(",");
  479. + NAMERS_TITLE_COLORS.put(Integer.parseInt(i[0]), Integer.decode("0x"+i[1]));
  480. + }
  481. + ALLOW_NAMERS_CUSTOM_SKILLS = Boolean.parseBoolean(players.getProperty("AllowNamersCustomSkills", "false"));
  482. + String namers_custom_skills = players.getProperty("NamersCustomSkills", "1,1;2,2;");
  483. + String[] namers_custom_skills_splitted = namers_custom_skills.split(";");
  484. + for (String s : namers_custom_skills_splitted)
  485. + {
  486. + String[] i = s.split(",");
  487. + NAMERS_CUSTOM_SKILLS.put(Integer.parseInt(i[0]), Integer.parseInt(i[1]));
  488. + }
  489. + NAMERS_HERO_AURA = Boolean.parseBoolean(players.getProperty("NamersHeroAura", "false"));
  490. + NAMERS_ANNOUNCE_ON_BECOME = Boolean.parseBoolean(players.getProperty("NamersAnnounceOnBecome", "false"));
  491. + NAMERS_ANNOUNCE_ON_LOGIN = Boolean.parseBoolean(players.getProperty("NamersAnnounceOnLogin", "false"));
  492. + NAMERS_CUSTOM_CHAT = Boolean.parseBoolean(players.getProperty("NamersCustomChat", "false"));
  493. + NAMERS_CUSTOM_CHAT_PREFIX = players.getProperty("NamersCustomChatPrefix", "~");
  494. + NAMERS_HAVE_NAME_PREFIX = Boolean.parseBoolean(players.getProperty("NamersHaveNamePrefix", "false"));
  495. + NAMERS_NAME_PREFIX = players.getProperty("NamersNamePrefix", "[DON]");
  496. }
  497. catch (Exception e)
  498. {
  499. Index: config/players.properties
  500. ===================================================================
  501. --- config/players.properties (revision 114)
  502. +++ config/players.properties (working copy)
  503. @@ -310,4 +310,51 @@
  504. MaxBuffsAmount = 20
  505.  
  506. # Store buffs/debuffs on user logout?
  507. -StoreSkillCooltime = True
  508. \ No newline at end of file
  509. +StoreSkillCooltime = True
  510. +
  511. +# NAME system settings.
  512. +# NAME system name that will be used, for admin commands and other stuff like announcements.
  513. +NameSystemName = Donator
  514. +# Allow admin command to become name(//set_name(this name will be replaced by the name you put in the previous config, but all leters in lower case. Eg. you put DONATOR, admin command will be //set_donator).
  515. +AllowNameAdminCommand = True
  516. +# Will these 'name' players have name color.
  517. +NamersNameColor = False
  518. +# Color name will be static?
  519. +# If false, then ignore the next config and go to to the config under it(it's auto enabled if this is false).
  520. +NamesNameColorStatic = True
  521. +NamesNameStaticColor = 0000FF
  522. +# Color will depend on?
  523. +# Options: PVP, PK.
  524. +ColorNameDepends = PVP
  525. +# Which color and the level(works like eg. lvl,color;lvl,color; or eg. pvps,color;pvps,color;).
  526. +NamersNameColorC = 100,00FF00;200,FF0000;300,0000FF;
  527. +# Will these 'name' players have title color.
  528. +NamersTitleColor = False
  529. +# Color title will be static?
  530. +# If false, then the next config is enabled by default.
  531. +NamesTitleColorStatic = True
  532. +NamesTitleStaticColor = FF0000
  533. +# Color will depend on?
  534. +# Options: PVP, PK.
  535. +ColorTitleDepends = PK
  536. +# Which color and the level(works like eg. lvl,color;lvl,color; or eg. pvps,color;pvps,color;).
  537. +NamersTitleColorC = 100,00FF00;200,FF0000;300,0000FF;
  538. +# Will name players get custom skills.
  539. +AllowNamersCustomSkills = False
  540. +# If true, what skills will they take(works like skillid,skilllvl;skillid,skilllvl;).
  541. +NamersCustomSkills = 1,1;2,2;
  542. +# Will name players get hero aura.
  543. +NamersHeroAura = False
  544. +# Will it be announced when they become name players(like Playername has become a server's NameSystemName(eg. Anarchy has become a server's Donator.)).
  545. +NamersAnnounceOnBecome = False
  546. +# Will it be announced when they login(like Playername, a server's NameSystemName, has logged in.(eg. Anarchy, a server's Donator, has logged in.)).
  547. +NamersAnnounceOnLogin = False
  548. +# Will namers have custom chat.
  549. +NamersCustomChat = False
  550. +# What prefix will it have(eg party(#), clan(@)).
  551. +# NOTE: Do not use existing one.
  552. +NamersCustomChatPrefix = ~
  553. +# Will namers have custom prefix on their name? (eg. [DON]Anarchy or [VIP]Anarchy)
  554. +NamersHaveNamePrefix = False
  555. +# If true what prefix.
  556. +NamersNamePrefix = [DON]
  557. \ No newline at end of file
  558. Index: java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
  559. ===================================================================
  560. --- java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java (revision 114)
  561. +++ java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java (working copy)
  562. @@ -335,7 +335,7 @@
  563.  
  564. writeD(_activeChar.getClanCrestLargeId());
  565. writeC(_activeChar.isNoble() ? 1 : 0); // Symbol on char menu ctrl+I
  566. - writeC((_activeChar.isHero() || (_activeChar.isGM() && Config.GM_HERO_AURA)) ? 1 : 0); // Hero Aura
  567. + writeC((_activeChar.isHero() || (_activeChar.isGM() && Config.GM_HERO_AURA) || (_activeChar.isNamer() && Config.NAMERS_HERO_AURA)) ? 1 : 0); // Hero Aura
  568.  
  569. writeC(_activeChar.isFishing() ? 1 : 0); //0x01: Fishing Mode (Cant be undone by setting back to 0)
  570. writeD(_activeChar.getFishx());
  571. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminNameSystem.java
  572. ===================================================================
  573. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminNameSystem.java (revision 0)
  574. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminNameSystem.java (revision 0)
  575. @@ -0,0 +1,216 @@
  576. +/* This program is free software; you can redistribute it and/or modify
  577. + * it under the terms of the GNU General Public License as published by
  578. + * the Free Software Foundation; either version 2, or (at your option)
  579. + * any later version.
  580. + *
  581. + * This program is distributed in the hope that it will be useful,
  582. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  583. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  584. + * GNU General Public License for more details.
  585. + *
  586. + * You should have received a copy of the GNU General Public License
  587. + * along with this program; if not, write to the Free Software
  588. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  589. + * 02111-1307, USA.
  590. + *
  591. + * http://www.gnu.org/copyleft/gpl.html
  592. + */
  593. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  594. +
  595. +import java.io.BufferedReader;
  596. +import java.io.BufferedWriter;
  597. +import java.io.File;
  598. +import java.io.FileReader;
  599. +import java.io.FileWriter;
  600. +import java.io.IOException;
  601. +import java.util.Collection;
  602. +
  603. +import javolution.util.FastList;
  604. +import net.sf.l2j.Config;
  605. +import net.sf.l2j.gameserver.Announcements;
  606. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  607. +import net.sf.l2j.gameserver.model.L2Object;
  608. +import net.sf.l2j.gameserver.model.L2World;
  609. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  610. +/**
  611. + *
  612. + * @author Anarchy
  613. + */
  614. +public class AdminNameSystem implements IAdminCommandHandler
  615. +{
  616. + private static final String[] ADMIN_COMMANDS = { "admin_set_"+Config.NAME_SYSTEM_NAME.toLowerCase() };
  617. +
  618. + public boolean useAdminCommand(String command, L2PcInstance activeChar)
  619. + {
  620. + if (command.equals("admin_set_"+Config.NAME_SYSTEM_NAME.toLowerCase()))
  621. + {
  622. + L2Object targetObject = activeChar.getTarget();
  623. +
  624. + if (!(targetObject instanceof L2PcInstance))
  625. + {
  626. + activeChar.sendMessage("Wrong target.");
  627. + return false;
  628. + }
  629. +
  630. + L2PcInstance target = (L2PcInstance)targetObject;
  631. +
  632. + if (getAllNamers().contains(target.getName()))
  633. + {
  634. + target.setNamer(false);
  635. + boolean removed = removeNamer(target.getName());
  636. +
  637. + if (!removed)
  638. + {
  639. + for (L2PcInstance gm : L2World.getInstance().getAllGMs())
  640. + {
  641. + gm.sendMessage("Error on removing namer from namesystem.info file. Player: "+target.getName()+".");
  642. + }
  643. + }
  644. + }
  645. + else
  646. + {
  647. + boolean added = addNamer(target.getName());
  648. + target.setNamer(true);
  649. + target.broadcastUserInfo();
  650. +
  651. + if (!added)
  652. + {
  653. + for (L2PcInstance gm : L2World.getInstance().getAllGMs())
  654. + {
  655. + gm.sendMessage("Error on adding namer on namesystem.info file. Player: "+target.getName()+".");
  656. + }
  657. + }
  658. + else
  659. + {
  660. + if (Config.NAMERS_ANNOUNCE_ON_BECOME)
  661. + {
  662. + Announcements.getInstance().announceToAll(target.getName()+" is now a "+Config.NAME_SYSTEM_NAME+"!");
  663. + }
  664. + }
  665. + }
  666. +
  667. + return true;
  668. + }
  669. +
  670. + return true;
  671. + }
  672. +
  673. + public static boolean addNamer(String name)
  674. + {
  675. + if (name == null)
  676. + {
  677. + return false;
  678. + }
  679. +
  680. + if (getAllNamers().contains(name))
  681. + {
  682. + return false;
  683. + }
  684. +
  685. + File f = new File("./config/", "namesystem.info");
  686. + try
  687. + {
  688. + FileWriter fw = new FileWriter(f, true);
  689. + BufferedWriter w = new BufferedWriter(fw);
  690. +
  691. + w.write(name);
  692. + w.newLine();
  693. + if (Config.NAMERS_HAVE_NAME_PREFIX)
  694. + {
  695. + w.write(Config.NAMERS_NAME_PREFIX+name);
  696. + w.newLine();
  697. + }
  698. +
  699. + w.close();
  700. + }
  701. + catch (IOException ioe)
  702. + { }
  703. +
  704. + return true;
  705. + }
  706. +
  707. + public static boolean removeNamer(String name)
  708. + {
  709. + if (name == null)
  710. + {
  711. + return false;
  712. + }
  713. +
  714. + if (!getAllNamers().contains(name))
  715. + {
  716. + return false;
  717. + }
  718. +
  719. + File f = new File("./config/", "namesystem.info");
  720. + try
  721. + {
  722. + FileWriter fw = new FileWriter(f);
  723. + BufferedWriter w = new BufferedWriter(fw);
  724. +
  725. + for (String s : getAllNamers())
  726. + {
  727. + if (!s.equals(name) && !s.equals(Config.NAMERS_NAME_PREFIX+name))
  728. + {
  729. + w.write(s);
  730. + w.newLine();
  731. + if (Config.NAMERS_HAVE_NAME_PREFIX)
  732. + {
  733. + w.write(Config.NAMERS_NAME_PREFIX+s);
  734. + w.newLine();
  735. + }
  736. + }
  737. + }
  738. +
  739. + w.close();
  740. + }
  741. + catch (IOException ioe)
  742. + { }
  743. +
  744. + return true;
  745. + }
  746. +
  747. + public static FastList<String> getAllNamers()
  748. + {
  749. + FastList<String> namers = new FastList<String>();
  750. + File f = new File("./config/", "namesystem.info");
  751. + if (!f.exists())
  752. + {
  753. + Collection<L2PcInstance> gms = L2World.getInstance().getAllGMs();
  754. + for (L2PcInstance gm : gms)
  755. + {
  756. + gm.sendMessage("Error on getting namers: namesystem.info does not exist.");
  757. + return null;
  758. + }
  759. + }
  760. + try
  761. + {
  762. + FileReader fr = new FileReader(f);
  763. + BufferedReader r = new BufferedReader(fr);
  764. + boolean eof = false;
  765. + do
  766. + {
  767. + String s = r.readLine();
  768. + if (s == null)
  769. + {
  770. + eof = true;
  771. + }
  772. + else
  773. + {
  774. + namers.add(s);
  775. + }
  776. + }
  777. + while (!eof);
  778. +
  779. + r.close();
  780. + }
  781. + catch (IOException ioe)
  782. + { }
  783. +
  784. + return namers;
  785. + }
  786. +
  787. + public String[] getAdminCommandList()
  788. + {
  789. + return ADMIN_COMMANDS;
  790. + }
  791. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement