Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/config/CustomMods/ProtectionMods.ini b/config/CustomMods/ProtectionMods.ini
- index 24f5fbd..a429379 100644
- --- a/config/CustomMods/ProtectionMods.ini
- +++ b/config/CustomMods/ProtectionMods.ini
- @@ -116,3 +116,12 @@
- AltDisableBow = False
- DisableBowForClasses = 89
- +#=============================================================
- +# Dual Box
- +#=============================================================
- +# Allow players to run multiple windows with a single IP address.
- +# In the game you can use the command // find_dualbox
- +AllowDualBox = True
- +AllowedBoxes = 99
- +AllowDualBoxInOly = False
- +
- diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
- index a47fa13..7b84437 100644
- --- a/java/net/sf/l2j/Config.java
- +++ b/java/net/sf/l2j/Config.java
- @@ -82,6 +82,9 @@
- public static int MANOR_SAVE_PERIOD_RATE;
- public static boolean ANNOUNCE_PK_KILL;
- public static boolean ANNOUNCE_PVP_KILL;
- + public static boolean ALLOW_DUALBOX;
- + public static int ALLOWED_BOXES;
- + public static boolean ALLOW_DUALBOX_OLY;
- /** Clan Hall function */
- public static boolean PVP_SAME_IP;
- public static boolean PVP_SUMON;
- @@ -1146,6 +1149,9 @@
- if(!class_id.equals(""))
- DISABLE_BOW_CLASSES.add(Integer.parseInt(class_id));
- }
- + ALLOW_DUALBOX_OLY = Boolean.parseBoolean(Protection.getProperty("AllowDualBoxInOly", "True"));
- + ALLOWED_BOXES = Integer.parseInt(Protection.getProperty("AllowedBoxes", "99"));
- + ALLOW_DUALBOX = Boolean.parseBoolean(Protection.getProperty("AllowDualBox", "True"));
- }
- private static final void loadOff()
- diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver/model/actor/Player.java
- index 2b2e9e2..de2c3e1 100644
- --- a/java/net/sf/l2j/gameserver/model/actor/Player.java
- +++ b/java/net/sf/l2j/gameserver/model/actor/Player.java
- @@ -7527,5 +7527,128 @@
- {
- _gainXpSpEnable = value;
- }
- + /** The _active_boxes. */
- + public int _active_boxes = -1;
- + /** The active_boxes_characters. */
- + public List<String> active_boxes_characters = new ArrayList<>();
- + /**
- + * check if local player can make multibox and also refresh local boxes instances number.
- + * @return true, if successful
- + */
- + public boolean checkMultiBox()
- + {
- +
- + boolean output = true;
- +
- + int boxes_number = 0; // this one
- + final List<String> active_boxes = new ArrayList<>();
- +
- + if (getClient() != null && getClient().getConnection() != null && !getClient().getConnection().isClosed() && getClient().getConnection().getInetAddress() != null)
- + {
- +
- + final String thisip = getClient().getConnection().getInetAddress().getHostAddress();
- + final Collection<Player> allPlayers = World.getInstance().getPlayers();
- + for (final Player player : allPlayers)
- + {
- + if (player != null)
- + {
- + if (player.isOnline() && player.getClient() != null && player.getClient().getConnection() != null && !player.getClient().getConnection().isClosed() && player.getClient().getConnection().getInetAddress() != null && !player.getName().equals(this.getName()))
- + {
- +
- + final String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
- + if (thisip.equals(ip) && this != player)
- + {
- + if (!Config.ALLOW_DUALBOX)
- + {
- +
- + output = false;
- + break;
- +
- + }
- +
- + if (boxes_number + 1 > Config.ALLOWED_BOXES)
- + { // actual count+actual player one
- + output = false;
- + break;
- + }
- + boxes_number++;
- + active_boxes.add(player.getName());
- + }
- + }
- + }
- + }
- + }
- +
- + if (output)
- + {
- + _active_boxes = boxes_number + 1; // current number of boxes+this one
- + if (!active_boxes.contains(this.getName()))
- + {
- + active_boxes.add(this.getName());
- +
- + this.active_boxes_characters = active_boxes;
- + }
- + refreshOtherBoxes();
- + }
- + /*
- + * LOGGER.info("Player "+getName()+" has this boxes"); for(String name:active_boxes_characters){ LOGGER.info("*** "+name+" ***"); }
- + */
- + return output;
- + }
- + /**
- + * descrease active boxes number for local player and other boxer for same ip.
- + */
- + public void decreaseBoxes()
- + {
- +
- + _active_boxes = _active_boxes - 1;
- + active_boxes_characters.remove(this.getName());
- +
- + refreshOtherBoxes();
- + /*
- + * if(getClient()!=null && !getClient().getConnection().isClosed()){ String thisip = getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress(); Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers(); L2PcInstance[] players =
- + * allPlayers.toArray(new L2PcInstance[allPlayers.size()]); for(L2PcInstance player : players) { if(player != null) { if(player.getClient()!=null && !player.getClient().getConnection().isClosed()){ String ip =
- + * 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;
- + * LOGGER.info("Player "+player.getName()+" has this boxes"); for(String name:player.active_boxes_characters){ LOGGER.info("*** "+name+" ***"); } } } } } }
- + */
- + /*
- + * LOGGER.info("Player "+getName()+" has this boxes"); for(String name:active_boxes_characters){ LOGGER.info("*** "+name+" ***"); }
- + */
- + }
- + /**
- + * increase active boxes number for local player and other boxer for same ip.
- + */
- + public void refreshOtherBoxes()
- + {
- +
- + if (getClient() != null && getClient().getConnection() != null && !getClient().getConnection().isClosed() && getClient().getConnection().getInetAddress() != null)
- + {
- +
- + final String thisip = getClient().getConnection().getInetAddress().getHostAddress();
- + final Collection<Player> allPlayers = World.getInstance().getPlayers();
- + final Player[] players = allPlayers.toArray(new Player[allPlayers.size()]);
- +
- + for (final Player player : players)
- + {
- + if (player != null && player.isOnline())
- + {
- + if (player.getClient() != null && player.getClient().getConnection() != null && !player.getClient().getConnection().isClosed() && !player.getName().equals(this.getName()))
- + {
- +
- + final String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
- + if (thisip.equals(ip) && this != player)
- + {
- + player._active_boxes = _active_boxes;
- + player.active_boxes_characters = active_boxes_characters;
- + /*
- + * LOGGER.info("Player "+player.getName()+" has this boxes"); for(String name:player.active_boxes_characters){ LOGGER.info("*** "+name+" ***"); }
- + */
- + }
- + }
- + }
- + }
- + }
- +
- + }
- }
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- index 1b329db..1c35a8b 100644
- --- a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- +++ b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- @@ -10,6 +10,7 @@
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.enums.OlympiadType;
- +import net.sf.l2j.gameserver.model.World;
- import net.sf.l2j.gameserver.model.actor.Npc;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- @@ -126,6 +127,22 @@
- return false;
- }
- + // Olympiad dualbox protection
- + if (player._active_boxes > 1 && !Config.ALLOW_DUALBOX_OLY)
- + {
- + final List<String> players_in_boxes = player.active_boxes_characters;
- +
- + if (players_in_boxes != null && players_in_boxes.size() > 1)
- + for (final String character_name : players_in_boxes)
- + {
- + final Player activeChar = World.getInstance().getPlayer(character_name);
- + if (activeChar != null && (activeChar.getOlympiadGameId() > 0 || activeChar.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(activeChar)))
- + {
- + activeChar.sendMessage("You are already participating in Olympiad with another char!");
- + return false;
- + }
- + }
- + }
- if (Olympiad.getInstance().getMillisToCompEnd() < 600000)
- {
- player.sendPacket(SystemMessageId.GAME_REQUEST_CANNOT_BE_MADE);
- diff --git a/java/net/sf/l2j/gameserver/network/GameClient.java b/java/net/sf/l2j/gameserver/network/GameClient.java
- index 860138d..c2c200e 100644
- --- a/java/net/sf/l2j/gameserver/network/GameClient.java
- +++ b/java/net/sf/l2j/gameserver/network/GameClient.java
- @@ -112,6 +112,8 @@
- if (getPlayer().getSummon() != null)
- getPlayer().getSummon().store();
- + if (_player._active_boxes != -1)
- + _player.decreaseBoxes();
- }
- }, 300000L, 900000L);
- }
- @@ -212,6 +214,9 @@
- if (getPlayer() != null && !isDetached())
- {
- setDetached(true);
- + // Decrease boxes number
- + if (_player._active_boxes != -1)
- + _player.decreaseBoxes();
- if (offlineMode(getPlayer()))
- {
- if (getPlayer().getParty() != null)
- diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- index e0aaa70..b41537e 100644
- --- a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- +++ b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- @@ -226,7 +226,12 @@
- {
- Olympiad.olympiadEnd(player);
- }
- -
- + // Means that it's not ok multiBox situation, so logout
- + if (!player.checkMultiBox())
- + {
- + player.sendPacket(new ExShowScreenMessage("I'm sorry, but multibox is not allowed here, Disconnect 5 Segunds", 5000));
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + player.logout(true);
- + }
- + }, 5000);
- +
- + }
- // If the Player is a Dark Elf, check for Shadow Sense at night.
- if (player.getRace() == ClassRace.DARK_ELF && player.hasSkill(L2Skill.SKILL_SHADOW_SENSE))
- player.sendPacket(SystemMessage.getSystemMessage((GameTimeTaskManager.getInstance().isNight()) ? SystemMessageId.NIGHT_S1_EFFECT_APPLIES : SystemMessageId.DAY_S1_EFFECT_DISAPPEARS).addSkillName(L2Skill.SKILL_SHADOW_SENSE));
- diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- index 3520e73..0a071c9 100644
- --- a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- +++ b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- @@ -43,7 +43,11 @@
- sendPacket(RestartResponse.valueOf(false));
- return;
- }
- -
- + // delete box from the world
- + if (player._active_boxes != -1)
- + {
- + player.decreaseBoxes();
- + }
- if (player.isFestivalParticipant() && FestivalOfDarknessManager.getInstance().isFestivalInitialized())
- {
- player.sendPacket(SystemMessageId.NO_RESTART_HERE);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement