Guest User

MiniRewarder for L2j-Planet.net

a guest
Feb 7th, 2013
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.92 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/GameServer.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 95)
  6. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  7. @@ -99,6 +99,7 @@
  8.  import net.sf.l2j.gameserver.model.entity.custom.HzVoteReward;
  9.  import net.sf.l2j.gameserver.model.entity.custom.LMS;
  10.  import net.sf.l2j.gameserver.model.entity.custom.LuckyChests;
  11. +import net.sf.l2j.gameserver.model.entity.custom.MiniReward;
  12.  import net.sf.l2j.gameserver.model.entity.custom.PvPMaster;
  13.  import net.sf.l2j.gameserver.model.entity.custom.QuizEvent;
  14.  import net.sf.l2j.gameserver.model.entity.custom.SoloEvent;
  15. @@ -286,6 +287,9 @@
  16.         Util.printSection("Custom");
  17.         AchievementsManager.getInstance();
  18.         L2BufferInstance.makeBufferBuffsList();
  19. +       if (Config.ALLOW_MINI_REWARD_SYSTEM){
  20. +           MiniReward.getInstance();
  21. +       }
  22.        
  23.         // -------------------------------------------- //
  24.        
  25. Index: java/net/sf/l2j/gameserver/model/entity/custom/MiniReward.java
  26. ===================================================================
  27. --- java/net/sf/l2j/gameserver/model/entity/custom/MiniReward.java  (revision 0)
  28. +++ java/net/sf/l2j/gameserver/model/entity/custom/MiniReward.java  (working copy)
  29. @@ -0,0 +1,83 @@
  30. +/*
  31. + * This program is free software: you can redistribute it and/or modify it under
  32. + * the terms of the GNU General Public License as published by the Free Software
  33. + * Foundation, either version 3 of the License, or (at your option) any later
  34. + * version.
  35. + *
  36. + * This program is distributed in the hope that it will be useful, but WITHOUT
  37. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  38. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  39. + * details.
  40. + *
  41. + * You should have received a copy of the GNU General Public License along with
  42. + * this program. If not, see <http://www.gnu.org/licenses/>.
  43. + */
  44. +package net.sf.l2j.gameserver.model.entity.custom;
  45. +
  46. +import java.util.Collection;
  47. +import java.util.HashMap;
  48. +
  49. +import net.sf.l2j.Config;
  50. +import net.sf.l2j.gameserver.ThreadPoolManager;
  51. +import net.sf.l2j.gameserver.model.L2World;
  52. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  53. +
  54. +/**
  55. + * @author Debian
  56. + *
  57. + */
  58. +public class MiniReward
  59. +{
  60. +   @SuppressWarnings("unused")
  61. +   static HashMap<String, Integer> playerIps = new HashMap<String, Integer>();
  62. +  
  63. +    public static void getInstance()
  64. +    {
  65. +        ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  66. +        {
  67. +           @Override
  68. +            public void run()
  69. +            {
  70. +                MiniReward();
  71. +            }
  72. +
  73. +           private void MiniReward()
  74. +           {              
  75. +               Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();             
  76. +               for (L2PcInstance p : pls)
  77. +               {
  78. +                   boolean canReward = false;
  79. +                   String pIp = p.getClient().getConnection().getInetAddress().getHostAddress();
  80. +                   if (playerIps.containsKey(pIp))
  81. +                   {
  82. +                       int count = playerIps.get(pIp);
  83. +                       if (count < Config.DUALBOXES_ALLOWED)
  84. +                       {
  85. +                              playerIps.remove(pIp);
  86. +                              playerIps.put(pIp, count+1);
  87. +                              canReward = true;
  88. +                       }
  89. +                       else
  90. +                       {
  91. +                           canReward = true;
  92. +                           playerIps.put(pIp, 1);
  93. +                       }
  94. +                   }
  95. +                  
  96. +                   if (canReward)
  97. +                   {
  98. +                       for (int i : Config.MINI_REWARD.keySet())
  99. +                       {
  100. +                           p.addItem("Mini Reward.", i, Config.MINI_REWARD.get(i), p, true);
  101. +                       }
  102. +                   }
  103. +                   else
  104. +                    {
  105. +                            p.sendMessage("Already "+Config.DUALBOXES_ALLOWED+" character(s) of your ip have been rewarded, so this character won't be rewarded.");
  106. +                    }
  107. +                    playerIps.clear();
  108. +               }              
  109. +           }
  110. +        }, 0, 86400 * 1000);
  111. +    }
  112. +}
  113. \ No newline at end of file
  114. Index: config/aCis.properties
  115. ===================================================================
  116. --- config/aCis.properties  (revision 95)
  117. +++ config/aCis.properties  (working copy)
  118. @@ -257,6 +257,18 @@
  119.  # Seconds to give back buffs after cancel.
  120.  CustomCancelSeconds = 7
  121.  
  122. +# Allow mini reward system.
  123. +AllowMiniRewardSystem = True
  124. +# Mini rewards (id,count;id,count;).
  125. +MiniReward = 3481,10;
  126. +# Dualboxes allowed.
  127. +DualboxesAllowed = 1
  128. +
  129.  # Restrictions so that some classes can't wear a kind of weapon.
  130. # If they do, they get penalty.
  131. BowRestrictedClasses =
  132. Index: java/net/sf/l2j/Config.java
  133. ===================================================================
  134. --- java/net/sf/l2j/Config.java (revision 95)
  135. +++ java/net/sf/l2j/Config.java (working copy)
  136. @@ -264,6 +264,13 @@
  137.    
  138.     public static Vector<int[]> PVP_ZONE_RESPAWN_POINTS = new Vector<>();
  139.    
  140. +   public static boolean ALLOW_MINI_REWARD_SYSTEM;
  141. +   public static Map<Integer, Integer> MINI_REWARD = new HashMap<Integer, Integer>();
  142. +   public static int DUALBOXES_ALLOWED;
  143. +  
  144.     // --------------------------------------------------
  145.     // Clans settings
  146.     // --------------------------------------------------
  147. @@ -1231,6 +1238,26 @@
  148.                         PVP_ZONE_RESPAWN_POINTS.add(val);
  149.                     }
  150.                 }
  151. +                
  152. +                ALLOW_MINI_REWARD_SYSTEM = Boolean.parseBoolean(aCis.getProperty("AllowMiniRewardSystem", "True"));
  153. +                String MINI_REWARD_VALUE = aCis.getProperty("MiniReward", "57,10000;");
  154. +                String[] mini_reward_value_splitted_1 = MINI_REWARD_VALUE.split(";");
  155. +                for (String i : mini_reward_value_splitted_1)
  156. +                {
  157. +                   String[] mini_reward_value_splitted_2 = i.split(",");
  158. +                   MINI_REWARD.put(Integer.parseInt(mini_reward_value_splitted_2[0]), Integer.parseInt(mini_reward_value_splitted_2[1]));
  159. +                }
  160. +                DUALBOXES_ALLOWED = Integer.parseInt(aCis.getProperty("DualboxesAllowed", "1"));
  161.             }
  162.             catch (Exception e)
  163.             {
Advertisement
Add Comment
Please, Sign In to add comment