Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/model/L2Clan.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/model/L2Clan.java (revision 1)
  6. +++ java/net/sf/l2j/gameserver/model/L2Clan.java (working copy)
  7. @@ -22,6 +22,7 @@
  8. import java.util.HashMap;
  9. import java.util.List;
  10. import java.util.Map;
  11. +import java.util.concurrent.CopyOnWriteArrayList;
  12. import java.util.logging.Level;
  13. import java.util.logging.Logger;
  14.  
  15. @@ -64,6 +65,7 @@
  16. private int _clanId;
  17. private L2ClanMember _leader;
  18. private final Map<Integer, L2ClanMember> _members = new HashMap<>();
  19. + private final List<L2PcInstance> _watchers = new CopyOnWriteArrayList<>();
  20.  
  21. private String _allyName;
  22. private int _allyId;
  23. @@ -203,6 +205,21 @@
  24. _members.put(leader.getObjectId(), leader);
  25. }
  26.  
  27. + public List<L2PcInstance> getWatchers()
  28. + {
  29. + return _watchers;
  30. + }
  31. +
  32. + public void addWatcher(L2PcInstance player)
  33. + {
  34. + _watchers.add(player);
  35. + }
  36. +
  37. + public void removeWatcher(L2PcInstance player)
  38. + {
  39. + _watchers.remove(player);
  40. + }
  41. +
  42. public void setNewLeader(L2ClanMember member)
  43. {
  44. if (!_leader.isOnline())
  45. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatClan.java
  46. ===================================================================
  47. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatClan.java (revision 1)
  48. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatClan.java (working copy)
  49. @@ -38,8 +38,15 @@
  50. {
  51. if (activeChar.getClan() != null)
  52. {
  53. - CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  54. + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  55. activeChar.getClan().broadcastToOnlineMembers(cs);
  56. +
  57. + if(!activeChar.getClan().getWatchers().isEmpty())
  58. + {
  59. + cs = new CreatureSay(activeChar.getObjectId(), type, "[Clan:"+activeChar.getClan().getName()+"]"+activeChar.getName(), text);
  60. + for(L2PcInstance watcher : activeChar.getClan().getWatchers())
  61. + watcher.sendPacket(cs);
  62. + }
  63. }
  64. }
  65.  
  66. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  67. ===================================================================
  68. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 1)
  69. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  70. @@ -66,6 +66,7 @@
  71. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTarget;
  72. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTeleport;
  73. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminUnblockIp;
  74. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminWatchClan;
  75. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
  76.  
  77. public class AdminCommandHandler
  78. @@ -98,6 +99,7 @@
  79. registerAdminCommandHandler(new AdminEffects());
  80. registerAdminCommandHandler(new AdminEnchant());
  81. registerAdminCommandHandler(new AdminExpSp());
  82. + registerAdminCommandHandler(new AdminWatchClan());
  83. registerAdminCommandHandler(new AdminGeodata());
  84. registerAdminCommandHandler(new AdminGm());
  85. registerAdminCommandHandler(new AdminGmChat());
  86. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminWatchClan.java
  87. ===================================================================
  88. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminWatchClan.java (revision 0)
  89. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminWatchClan.java (revision 0)
  90. @@ -0,0 +1,86 @@
  91. +/*
  92. + * This program is free software: you can redistribute it and/or modify it under
  93. + * the terms of the GNU General Public License as published by the Free Software
  94. + * Foundation, either version 3 of the License, or (at your option) any later
  95. + * version.
  96. + *
  97. + * This program is distributed in the hope that it will be useful, but WITHOUT
  98. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  99. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  100. + * details.
  101. + *
  102. + * You should have received a copy of the GNU General Public License along with
  103. + * this program. If not, see <http://www.gnu.org/licenses/>.
  104. + */
  105. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  106. +
  107. +import net.sf.l2j.gameserver.datatables.ClanTable;
  108. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  109. +import net.sf.l2j.gameserver.model.L2Clan;
  110. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  111. +
  112. +/**
  113. + * @author Lioy
  114. + *
  115. + */
  116. +public class AdminWatchClan implements IAdminCommandHandler
  117. +{
  118. + private static final String[] ADMIN_COMMANDS =
  119. + {
  120. + "admin_watchclan",
  121. + "admin_stopwatch",
  122. + };
  123. +
  124. + @Override
  125. + public boolean useAdminCommand(String command, L2PcInstance activeChar)
  126. + {
  127. + if(command.startsWith(ADMIN_COMMANDS[0]) || command.startsWith(ADMIN_COMMANDS[1]))
  128. + {
  129. + L2Clan clan;
  130. + String clanName;
  131. + try
  132. + {
  133. + clanName = command.substring(16);
  134. + clan = ClanTable.getInstance().getClanByName(clanName);
  135. + }
  136. + catch(Exception e)
  137. + {
  138. + activeChar.sendMessage("Incorrect clan name. Usage: //watchclan <clanname>");
  139. + return false;
  140. + }
  141. +
  142. + if(command.startsWith(ADMIN_COMMANDS[0]))
  143. + {
  144. +
  145. + if(clan.getWatchers().contains(activeChar))
  146. + {
  147. + activeChar.sendMessage("You already watch "+clanName +" clan.");
  148. + return false;
  149. + }
  150. +
  151. + clan.addWatcher(activeChar);
  152. + activeChar.sendMessage("You are now a watcher in "+clanName +" clan.");
  153. + }
  154. +
  155. + else if(command.startsWith(ADMIN_COMMANDS[1]))
  156. + {
  157. + if(!clan.getWatchers().contains(activeChar))
  158. + {
  159. + activeChar.sendMessage("You don't watch even "+clanName +" clan.");
  160. + return false;
  161. + }
  162. +
  163. + clan.removeWatcher(activeChar);
  164. + activeChar.sendMessage("You are not a watcher anymore in "+clanName +" clan.");
  165. + }
  166. + }
  167. + return true;
  168. + }
  169. +
  170. + @Override
  171. + public String[] getAdminCommandList()
  172. + {
  173. + return ADMIN_COMMANDS;
  174. + }
  175. +
  176. +}
  177. Index: data/xml/admin_commands_rights.xml
  178. ===================================================================
  179. --- data/xml/admin_commands_rights.xml (revision 1)
  180. +++ data/xml/admin_commands_rights.xml (working copy)
  181. @@ -14,6 +14,9 @@
  182. <aCar name="admin_tradeoff" accessLevel="1" />
  183. <aCar name="admin_reload" accessLevel="1" />
  184. <aCar name="admin_script_load" accessLevel="1" />
  185. +
  186. + <aCar name="admin_watchclan" accessLevel="1" />
  187. + <aCar name="admin_stopwatch" accessLevel="1" />
  188.  
  189. <!-- ANNOUNCEMENTS -->
  190. <aCar name="admin_list_announcements" accessLevel="1" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement