Advertisement
Sarada-L2

DualBox+DualBox Olympiadas Acis 394+

Feb 28th, 2021 (edited)
957
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.89 KB | None | 0 0
  1. diff --git a/config/CustomMods/ProtectionMods.ini b/config/CustomMods/ProtectionMods.ini
  2. index 24f5fbd..a429379 100644
  3. --- a/config/CustomMods/ProtectionMods.ini
  4. +++ b/config/CustomMods/ProtectionMods.ini
  5. @@ -116,3 +116,12 @@
  6. AltDisableBow = False
  7. DisableBowForClasses = 89
  8.  
  9. +#=============================================================
  10. +# Dual Box
  11. +#=============================================================
  12. +# Allow players to run multiple windows with a single IP address.
  13. +# In the game you can use the command // find_dualbox
  14. +AllowDualBox = True
  15. +AllowedBoxes = 99
  16. +AllowDualBoxInOly = False
  17. +
  18. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  19. index a47fa13..7b84437 100644
  20. --- a/java/net/sf/l2j/Config.java
  21. +++ b/java/net/sf/l2j/Config.java
  22. @@ -82,6 +82,9 @@
  23. public static int MANOR_SAVE_PERIOD_RATE;
  24. public static boolean ANNOUNCE_PK_KILL;
  25. public static boolean ANNOUNCE_PVP_KILL;
  26. + public static boolean ALLOW_DUALBOX;
  27. + public static int ALLOWED_BOXES;
  28. + public static boolean ALLOW_DUALBOX_OLY;
  29. /** Clan Hall function */
  30. public static boolean PVP_SAME_IP;
  31. public static boolean PVP_SUMON;
  32. @@ -1146,6 +1149,9 @@
  33. if(!class_id.equals(""))
  34. DISABLE_BOW_CLASSES.add(Integer.parseInt(class_id));
  35. }
  36. + ALLOW_DUALBOX_OLY = Boolean.parseBoolean(Protection.getProperty("AllowDualBoxInOly", "True"));
  37. + ALLOWED_BOXES = Integer.parseInt(Protection.getProperty("AllowedBoxes", "99"));
  38. + ALLOW_DUALBOX = Boolean.parseBoolean(Protection.getProperty("AllowDualBox", "True"));
  39. }
  40.  
  41. private static final void loadOff()
  42. diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver/model/actor/Player.java
  43. index 2b2e9e2..de2c3e1 100644
  44. --- a/java/net/sf/l2j/gameserver/model/actor/Player.java
  45. +++ b/java/net/sf/l2j/gameserver/model/actor/Player.java
  46. @@ -7527,5 +7527,128 @@
  47. {
  48. _gainXpSpEnable = value;
  49. }
  50. + /** The _active_boxes. */
  51. + public int _active_boxes = -1;
  52.  
  53. + /** The active_boxes_characters. */
  54. + public List<String> active_boxes_characters = new ArrayList<>();
  55. + /**
  56. + * check if local player can make multibox and also refresh local boxes instances number.
  57. + * @return true, if successful
  58. + */
  59. + public boolean checkMultiBox()
  60. + {
  61. +
  62. + boolean output = true;
  63. +
  64. + int boxes_number = 0; // this one
  65. + final List<String> active_boxes = new ArrayList<>();
  66. +
  67. + if (getClient() != null && getClient().getConnection() != null && !getClient().getConnection().isClosed() && getClient().getConnection().getInetAddress() != null)
  68. + {
  69. +
  70. + final String thisip = getClient().getConnection().getInetAddress().getHostAddress();
  71. + final Collection<Player> allPlayers = World.getInstance().getPlayers();
  72. + for (final Player player : allPlayers)
  73. + {
  74. + if (player != null)
  75. + {
  76. + if (player.isOnline() && player.getClient() != null && player.getClient().getConnection() != null && !player.getClient().getConnection().isClosed() && player.getClient().getConnection().getInetAddress() != null && !player.getName().equals(this.getName()))
  77. + {
  78. +
  79. + final String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
  80. + if (thisip.equals(ip) && this != player)
  81. + {
  82. + if (!Config.ALLOW_DUALBOX)
  83. + {
  84. +
  85. + output = false;
  86. + break;
  87. +
  88. + }
  89. +
  90. + if (boxes_number + 1 > Config.ALLOWED_BOXES)
  91. + { // actual count+actual player one
  92. + output = false;
  93. + break;
  94. + }
  95. + boxes_number++;
  96. + active_boxes.add(player.getName());
  97. + }
  98. + }
  99. + }
  100. + }
  101. + }
  102. +
  103. + if (output)
  104. + {
  105. + _active_boxes = boxes_number + 1; // current number of boxes+this one
  106. + if (!active_boxes.contains(this.getName()))
  107. + {
  108. + active_boxes.add(this.getName());
  109. +
  110. + this.active_boxes_characters = active_boxes;
  111. + }
  112. + refreshOtherBoxes();
  113. + }
  114. + /*
  115. + * LOGGER.info("Player "+getName()+" has this boxes"); for(String name:active_boxes_characters){ LOGGER.info("*** "+name+" ***"); }
  116. + */
  117. + return output;
  118. + }
  119. + /**
  120. + * descrease active boxes number for local player and other boxer for same ip.
  121. + */
  122. + public void decreaseBoxes()
  123. + {
  124. +
  125. + _active_boxes = _active_boxes - 1;
  126. + active_boxes_characters.remove(this.getName());
  127. +
  128. + refreshOtherBoxes();
  129. + /*
  130. + * if(getClient()!=null && !getClient().getConnection().isClosed()){ String thisip = getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress(); Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers(); L2PcInstance[] players =
  131. + * allPlayers.toArray(new L2PcInstance[allPlayers.size()]); for(L2PcInstance player : players) { if(player != null) { if(player.getClient()!=null && !player.getClient().getConnection().isClosed()){ String ip =
  132. + * player.getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress(); if(thisip.equals(ip) && this != player && player != null) { player._active_boxes = _active_boxes; player.active_boxes_characters = active_boxes_characters;
  133. + * LOGGER.info("Player "+player.getName()+" has this boxes"); for(String name:player.active_boxes_characters){ LOGGER.info("*** "+name+" ***"); } } } } } }
  134. + */
  135. + /*
  136. + * LOGGER.info("Player "+getName()+" has this boxes"); for(String name:active_boxes_characters){ LOGGER.info("*** "+name+" ***"); }
  137. + */
  138. + }
  139. + /**
  140. + * increase active boxes number for local player and other boxer for same ip.
  141. + */
  142. + public void refreshOtherBoxes()
  143. + {
  144. +
  145. + if (getClient() != null && getClient().getConnection() != null && !getClient().getConnection().isClosed() && getClient().getConnection().getInetAddress() != null)
  146. + {
  147. +
  148. + final String thisip = getClient().getConnection().getInetAddress().getHostAddress();
  149. + final Collection<Player> allPlayers = World.getInstance().getPlayers();
  150. + final Player[] players = allPlayers.toArray(new Player[allPlayers.size()]);
  151. +
  152. + for (final Player player : players)
  153. + {
  154. + if (player != null && player.isOnline())
  155. + {
  156. + if (player.getClient() != null && player.getClient().getConnection() != null && !player.getClient().getConnection().isClosed() && !player.getName().equals(this.getName()))
  157. + {
  158. +
  159. + final String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
  160. + if (thisip.equals(ip) && this != player)
  161. + {
  162. + player._active_boxes = _active_boxes;
  163. + player.active_boxes_characters = active_boxes_characters;
  164. + /*
  165. + * LOGGER.info("Player "+player.getName()+" has this boxes"); for(String name:player.active_boxes_characters){ LOGGER.info("*** "+name+" ***"); }
  166. + */
  167. + }
  168. + }
  169. + }
  170. + }
  171. + }
  172. +
  173. + }
  174. }
  175. \ No newline at end of file
  176. diff --git a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  177. index 1b329db..1c35a8b 100644
  178. --- a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  179. +++ b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  180. @@ -10,6 +10,7 @@
  181.  
  182. import net.sf.l2j.Config;
  183. import net.sf.l2j.gameserver.enums.OlympiadType;
  184. +import net.sf.l2j.gameserver.model.World;
  185. import net.sf.l2j.gameserver.model.actor.Npc;
  186. import net.sf.l2j.gameserver.model.actor.Player;
  187. import net.sf.l2j.gameserver.network.SystemMessageId;
  188. @@ -126,6 +127,22 @@
  189. return false;
  190. }
  191.  
  192. + // Olympiad dualbox protection
  193. + if (player._active_boxes > 1 && !Config.ALLOW_DUALBOX_OLY)
  194. + {
  195. + final List<String> players_in_boxes = player.active_boxes_characters;
  196. +
  197. + if (players_in_boxes != null && players_in_boxes.size() > 1)
  198. + for (final String character_name : players_in_boxes)
  199. + {
  200. + final Player activeChar = World.getInstance().getPlayer(character_name);
  201. + if (activeChar != null && (activeChar.getOlympiadGameId() > 0 || activeChar.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(activeChar)))
  202. + {
  203. + activeChar.sendMessage("You are already participating in Olympiad with another char!");
  204. + return false;
  205. + }
  206. + }
  207. + }
  208. if (Olympiad.getInstance().getMillisToCompEnd() < 600000)
  209. {
  210. player.sendPacket(SystemMessageId.GAME_REQUEST_CANNOT_BE_MADE);
  211. diff --git a/java/net/sf/l2j/gameserver/network/GameClient.java b/java/net/sf/l2j/gameserver/network/GameClient.java
  212. index 860138d..c2c200e 100644
  213. --- a/java/net/sf/l2j/gameserver/network/GameClient.java
  214. +++ b/java/net/sf/l2j/gameserver/network/GameClient.java
  215. @@ -112,6 +112,8 @@
  216.  
  217. if (getPlayer().getSummon() != null)
  218. getPlayer().getSummon().store();
  219. + if (_player._active_boxes != -1)
  220. + _player.decreaseBoxes();
  221. }
  222. }, 300000L, 900000L);
  223. }
  224. @@ -212,6 +214,9 @@
  225. if (getPlayer() != null && !isDetached())
  226. {
  227. setDetached(true);
  228. + // Decrease boxes number
  229. + if (_player._active_boxes != -1)
  230. + _player.decreaseBoxes();
  231. if (offlineMode(getPlayer()))
  232. {
  233. if (getPlayer().getParty() != null)
  234. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  235. index e0aaa70..b41537e 100644
  236. --- a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  237. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  238. @@ -226,7 +226,12 @@
  239. {
  240. Olympiad.olympiadEnd(player);
  241. }
  242. -
  243. + // Means that it's not ok multiBox situation, so logout
  244. + if (!player.checkMultiBox())
  245. + {
  246. + player.sendPacket(new ExShowScreenMessage("I'm sorry, but multibox is not allowed here, Disconnect 5 Segunds", 5000));
  247. + ThreadPool.schedule(new Runnable()
  248. + {
  249. + @Override
  250. + public void run()
  251. + {
  252. + player.logout(true);
  253. + }
  254. + }, 5000);
  255. +
  256. + }
  257. // If the Player is a Dark Elf, check for Shadow Sense at night.
  258. if (player.getRace() == ClassRace.DARK_ELF && player.hasSkill(L2Skill.SKILL_SHADOW_SENSE))
  259. player.sendPacket(SystemMessage.getSystemMessage((GameTimeTaskManager.getInstance().isNight()) ? SystemMessageId.NIGHT_S1_EFFECT_APPLIES : SystemMessageId.DAY_S1_EFFECT_DISAPPEARS).addSkillName(L2Skill.SKILL_SHADOW_SENSE));
  260. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  261. index 3520e73..0a071c9 100644
  262. --- a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  263. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  264. @@ -43,7 +43,11 @@
  265. sendPacket(RestartResponse.valueOf(false));
  266. return;
  267. }
  268. -
  269. + // delete box from the world
  270. + if (player._active_boxes != -1)
  271. + {
  272. + player.decreaseBoxes();
  273. + }
  274. if (player.isFestivalParticipant() && FestivalOfDarknessManager.getInstance().isFestivalInitialized())
  275. {
  276. player.sendPacket(SystemMessageId.NO_RESTART_HERE);
  277.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement