Advertisement
LIONN

Admin Olympiad Points

May 6th, 2012
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 10.07 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jFrozen_DataPack
  3. Index: sql/admin_command_access_rights.sql
  4. ===================================================================
  5. --- sql/admin_command_access_rights.sql (revision 986)
  6. +++ sql/admin_command_access_rights.sql (working copy)
  7. @@ -29,6 +29,12 @@
  8.  ('admin_saveolymp','2'),
  9.  ('admin_manualhero','2'),
  10.  
  11. +-- Olympiad Points
  12. +('admin_addolypoints', '2'),
  13. +('admin_removeolypoints', '2'),
  14. +('admin_setolypoints', '2'),
  15. +('admin_getolypoints', '2'),
  16. +
  17.  -- Section: Announcements
  18.  ('admin_list_announcements','3'),
  19.  ('admin_reload_announcements','3'),
  20. #P L2jFrozen_GameServer
  21. Index: head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminOlympiad.java
  22. ===================================================================
  23. --- head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminOlympiad.java   (revision 0)
  24. +++ head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminOlympiad.java   (working copy)
  25. @@ -0,0 +1,210 @@
  26. +/*
  27. + * This program is free software: you can redistribute it and/or modify it under
  28. + * the terms of the GNU General Public License as published by the Free Software
  29. + * Foundation, either version 3 of the License, or (at your option) any later
  30. + * version.
  31. + *
  32. + * This program is distributed in the hope that it will be useful, but WITHOUT
  33. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  34. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  35. + * details.
  36. + *
  37. + * You should have received a copy of the GNU General Public License along with
  38. + * this program. If not, see <http://www.gnu.org/licenses/>.
  39. + */
  40. +package com.l2jfrozen.gameserver.handler.admincommandhandlers;
  41. +
  42. +import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
  43. +import com.l2jfrozen.gameserver.model.L2Object;
  44. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  45. +import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  46. +import com.l2jfrozen.gameserver.templates.StatsSet;
  47. +
  48. +public class AdminOlympiad implements IAdminCommandHandler
  49. +{
  50. +   private static final String[] ADMIN_COMMANDS =
  51. +   {
  52. +       "admin_addolypoints",
  53. +       "admin_removeolypoints",
  54. +       "admin_setolypoints",
  55. +       "admin_getolypoints"
  56. +   };
  57. +  
  58. +   @Override
  59. +   public boolean useAdminCommand(String command, L2PcInstance activeChar)
  60. +   {
  61. +       if (command.startsWith("admin_addolypoints"))
  62. +       {
  63. +           try
  64. +           {
  65. +               String val = command.substring(19);
  66. +               L2Object target = activeChar.getTarget();
  67. +               L2PcInstance player = null;
  68. +               if (target instanceof L2PcInstance)
  69. +               {
  70. +                   player = (L2PcInstance) target;
  71. +                   if (player.isNoble())
  72. +                   {
  73. +                       StatsSet playerStat = Olympiad.getNobleStats(player.getObjectId());
  74. +                       if (playerStat == null)
  75. +                       {
  76. +                           activeChar.sendMessage("Oops! This player hasn't played on Olympiad yet!");
  77. +                           return false;
  78. +                       }
  79. +                       int oldpoints = Olympiad.getInstance().getNoblePoints(player.getObjectId());
  80. +                       int points = oldpoints + Integer.parseInt(val);
  81. +                       if (points > 100)
  82. +                       {
  83. +                           activeChar.sendMessage("You can't set more than 100 or less than 0 Olympiad points!");
  84. +                           return false;
  85. +                       }
  86. +                       playerStat.set("olympiad_points", points);
  87. +                      
  88. +                       activeChar.sendMessage("Player " + player.getName() + " now has " + points + " Olympiad points.");
  89. +                   }
  90. +                   else
  91. +                   {
  92. +                       activeChar.sendMessage("Oops! This player is not noblesse!");
  93. +                       return false;
  94. +                   }
  95. +               }
  96. +               else
  97. +               {
  98. +                   activeChar.sendMessage("Usage: target a player and write the amount of points you would like to add.");
  99. +                   activeChar.sendMessage("Example: //addolypoints 10");
  100. +                   activeChar.sendMessage("However, keep in mind that you can't have less than 0 or more than 100 points.");
  101. +               }
  102. +           }
  103. +           catch (StringIndexOutOfBoundsException e)
  104. +           {
  105. +               activeChar.sendMessage("Usage: //addolypoints <points>");
  106. +           }
  107. +       }
  108. +       else if (command.startsWith("admin_removeolypoints"))
  109. +       {
  110. +           try
  111. +           {
  112. +               String val = command.substring(22);
  113. +               L2Object target = activeChar.getTarget();
  114. +               L2PcInstance player = null;
  115. +               if (target instanceof L2PcInstance)
  116. +               {
  117. +                   player = (L2PcInstance) target;
  118. +                   if (player.isNoble())
  119. +                   {
  120. +                       StatsSet playerStat = Olympiad.getNobleStats(player.getObjectId());
  121. +                       if (playerStat == null)
  122. +                       {
  123. +                           activeChar.sendMessage("Oops! This player hasn't played on Olympiad yet!");
  124. +                           return false;
  125. +                       }
  126. +                       int oldpoints = Olympiad.getInstance().getNoblePoints(player.getObjectId());
  127. +                       int points = oldpoints - Integer.parseInt(val);
  128. +                       if (points < 0)
  129. +                           points = 0;
  130. +                       playerStat.set("olympiad_points", points);
  131. +                       activeChar.sendMessage("Player " + player.getName() + " now has " + points + " Olympiad points.");
  132. +                   }
  133. +                   else
  134. +                   {
  135. +                       activeChar.sendMessage("Oops! This player is not noblesse!");
  136. +                       return false;
  137. +                   }
  138. +               }
  139. +               else
  140. +               {
  141. +                   activeChar.sendMessage("Usage: target a player and write the amount of points you would like to remove.");
  142. +                   activeChar.sendMessage("Example: //removeolypoints 10");
  143. +                   activeChar.sendMessage("However, keep in mind that you can't have less than 0 or more than 100 points.");
  144. +               }
  145. +           }
  146. +           catch (StringIndexOutOfBoundsException e)
  147. +           {
  148. +               activeChar.sendMessage("Usage: //removeolypoints points");
  149. +           }
  150. +       }
  151. +       else if (command.startsWith("admin_setolypoints"))
  152. +       {
  153. +           try
  154. +           {
  155. +               String val = command.substring(19);
  156. +               L2Object target = activeChar.getTarget();
  157. +               L2PcInstance player = null;
  158. +               if (target instanceof L2PcInstance)
  159. +               {
  160. +                   player = (L2PcInstance) target;
  161. +                   if (player.isNoble())
  162. +                   {
  163. +                       StatsSet playerStat = Olympiad.getNobleStats(player.getObjectId());
  164. +                       if (playerStat == null)
  165. +                       {
  166. +                           activeChar.sendMessage("Oops! This player hasn't played on Olympiad yet!");
  167. +                           return false;
  168. +                       }
  169. +                       if (Integer.parseInt(val) < 1 && Integer.parseInt(val) > 100)
  170. +                       {
  171. +                           activeChar.sendMessage("You can't set more than 100 or less than 0 Olympiad points! or lower then 0");
  172. +                           return false;
  173. +                       }
  174. +                       playerStat.set("olympiad_points", Integer.parseInt(val));
  175. +                       activeChar.sendMessage("Player " + player.getName() + " now has " + Integer.parseInt(val) + " Olympiad points.");
  176. +                   }
  177. +                   else
  178. +                   {
  179. +                       activeChar.sendMessage("Oops! This player is not noblesse!");
  180. +                       return false;
  181. +                   }
  182. +               }
  183. +               else
  184. +               {
  185. +                   activeChar.sendMessage("Usage: target a player and write the amount of points you would like to set.");
  186. +                   activeChar.sendMessage("Example: //setolypoints 10");
  187. +                   activeChar.sendMessage("However, keep in mind that you can't have less than 0 or more than 100 points.");
  188. +               }
  189. +           }
  190. +           catch (StringIndexOutOfBoundsException e)
  191. +           {
  192. +               activeChar.sendMessage("Usage: //setolypoints <points>");
  193. +           }
  194. +       }
  195. +       else if (command.startsWith("admin_getolypoints"))
  196. +       {
  197. +           try
  198. +           {
  199. +               L2Object target = activeChar.getTarget();
  200. +               L2PcInstance player = null;
  201. +               if (target instanceof L2PcInstance)
  202. +               {
  203. +                   player = (L2PcInstance) target;
  204. +                   if (player.isNoble())
  205. +                   {
  206. +                       activeChar.sendMessage(">=========>>" + player.getName() + "<<=========");
  207. +                       activeChar.sendMessage("   Match(s):" + Olympiad.getInstance().getCompetitionDone(player.getObjectId()));
  208. +                       activeChar.sendMessage("   Win(s):" + Olympiad.getInstance().getCompetitionWon(activeChar.getObjectId()));
  209. +                       activeChar.sendMessage("   Defeat(s):" + Olympiad.getInstance().getCompetitionLost(activeChar.getObjectId()));
  210. +                       activeChar.sendMessage("   Point(s) " + Olympiad.getInstance().getNoblePoints(player.getObjectId()));
  211. +                       activeChar.sendMessage(">=========>>" + player.getName() + "<<=========");
  212. +                   }
  213. +                   else
  214. +                   {
  215. +                       activeChar.sendMessage("Oops! This player is not noblesse!");
  216. +                       return false;
  217. +                   }
  218. +               }
  219. +               else
  220. +                   activeChar.sendMessage("You must target a player to use the command.");
  221. +           }
  222. +           catch (StringIndexOutOfBoundsException e)
  223. +           {
  224. +               activeChar.sendMessage("Usage: //getolypoints");
  225. +           }
  226. +       }
  227. +       return true;
  228. +   }
  229. +  
  230. +   @Override
  231. +   public String[] getAdminCommandList()
  232. +   {
  233. +       return ADMIN_COMMANDS;
  234. +   }
  235. +}
  236. \ No newline at end of file
  237. Index: head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java
  238. ===================================================================
  239. --- head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java  (revision 986)
  240. +++ head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java  (working copy)
  241. @@ -69,6 +69,7 @@
  242.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminMobGroup;
  243.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminMonsterRace;
  244.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminNoble;
  245. +import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminOlympiad;
  246.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminPForge;
  247.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminPetition;
  248.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminPledge;
  249. @@ -186,6 +187,7 @@
  250.         registerAdminCommandHandler(new AdminAio());
  251.         registerAdminCommandHandler(new AdminCharSupervision());
  252.         registerAdminCommandHandler(new AdminWho()); // L2OFF command
  253. +       registerAdminCommandHandler(new AdminOlympiad());
  254.         // ATTENTION: adding new command handlers, you have to change the
  255.         // sql file containing the access levels rights
  256.        
  257. Index: head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java
  258. ===================================================================
  259. --- head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java   (revision 986)
  260. +++ head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java   (working copy)
  261. @@ -558,7 +558,7 @@
  262.         return _nobles.size();
  263.     }
  264.    
  265. -   protected static StatsSet getNobleStats(int playerId)
  266. +   public static StatsSet getNobleStats(int playerId)
  267.     {
  268.         return _nobles.get(playerId);
  269.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement