diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..9af15f51c5 --- /dev/null +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,125 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java index 05d7db375a..55e5e148e8 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -133,6 +133,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -895,6 +896,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 31323134aa..07d277ca7d 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -106,6 +106,7 @@ import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidBo import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidServerInfo; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -460,7 +461,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15D, null, ConnectionState.IN_GAME), // 152 REQUEST_BLOCK_LIST_FOR_AD(0x15E, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15F, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x160, null, ConnectionState.IN_GAME), // 152 + EX_INTERACT_MODIFY(0x160, ExInteractModify::new, ConnectionState.IN_GAME), // 152 EX_TRY_ENCHANT_ARTIFACT(0x161, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME), // 152 EX_XIGN_CODE(0x162, null, ConnectionState.IN_GAME); // 152 diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 476907b225..6342b1d523 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -633,6 +633,9 @@ public class EnterWorld implements IClientIncomingPacket player.sendPacket(new ExAutoSoulShot(0, true, 2)); player.sendPacket(new ExAutoSoulShot(0, true, 3)); + // Client settings restore. + player.getClientSettings(); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 110621d575..cd069dee56 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..9af15f51c5 --- /dev/null +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,125 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java index e1eb9e5c0e..e986f6fef1 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -133,6 +133,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -895,6 +896,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index c473646315..76328c9ff6 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -107,6 +107,7 @@ import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidBo import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidServerInfo; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -461,7 +462,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15D, null, ConnectionState.IN_GAME), // 152 REQUEST_BLOCK_LIST_FOR_AD(0x15E, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15F, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x160, null, ConnectionState.IN_GAME), // 152 + EX_INTERACT_MODIFY(0x160, ExInteractModify::new, ConnectionState.IN_GAME), // 152 EX_TRY_ENCHANT_ARTIFACT(0x161, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME), // 152 EX_XIGN_CODE(0x162, null, ConnectionState.IN_GAME); // 152 diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 476907b225..6342b1d523 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -633,6 +633,9 @@ public class EnterWorld implements IClientIncomingPacket player.sendPacket(new ExAutoSoulShot(0, true, 2)); player.sendPacket(new ExAutoSoulShot(0, true, 3)); + // Client settings restore. + player.getClientSettings(); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java index 95b03f4b3b..6e5e23fcd0 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java @@ -227,7 +227,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 110621d575..cd069dee56 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..b2f7eac3e4 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,43 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + _announceName = player.getName(); } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java index 3525816d88..1bdc661cb7 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -137,6 +137,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -913,6 +914,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 13e2b14743..6b8bfc4e72 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -118,6 +118,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -480,7 +482,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, null, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, null, ConnectionState.IN_GAME), @@ -543,7 +545,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19A, null, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19B, null, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19C, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19D, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19D, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_ANTIBOT(0x19E, null, ConnectionState.IN_GAME), EX_DPSVR(0x19F, null, ConnectionState.IN_GAME), EX_TENPROTECT_DECRYPT_ERROR(0x1A0, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index f6b018bc89..3a63d43682 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -112,6 +112,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillList; import org.l2jmobius.gameserver.network.serverpackets.attendance.ExVipAttendanceItemList; import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.util.BuilderUtil; /** @@ -643,6 +644,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java index 8e362ca27a..52e402ebca 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java @@ -227,7 +227,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 0c7d604620..29cb5986f5 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..44a5e8d6a5 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,62 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java index cf7901831a..bd77655add 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -136,6 +136,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -916,6 +917,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 2881b6b8a2..e180adfecc 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -131,6 +131,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -497,7 +499,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, null, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, null, ConnectionState.IN_GAME), @@ -562,7 +564,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, null, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, null, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 028d07e57d..ffc355d1bf 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -118,6 +118,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusReady; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.util.BuilderUtil; /** @@ -659,6 +660,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java index 44a25407fe..c66b217ece 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java @@ -227,7 +227,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 0c7d604620..29cb5986f5 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..44a5e8d6a5 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,62 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java index 1ec7a06952..4907b6ad02 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -138,6 +138,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -932,6 +933,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 3c8f43814a..983792745e 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -141,6 +141,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -507,7 +509,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, null, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, null, ConnectionState.IN_GAME), @@ -572,7 +574,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, null, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, null, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 6086ed9c53..74fa3b7cb4 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusReady; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.util.BuilderUtil; /** @@ -664,6 +665,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java index 44a25407fe..c66b217ece 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java @@ -227,7 +227,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 0c7d604620..29cb5986f5 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..44a5e8d6a5 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,62 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java index e6fc06a4e9..e5ff148683 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -138,6 +138,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -934,6 +935,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 1a7c9c2e43..b0721035ab 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -143,6 +143,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -509,7 +511,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, null, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME), @@ -574,7 +576,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, null, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, null, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index ff9e7449b7..cc4deb7c90 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -121,6 +121,7 @@ import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPoi import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusReady; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.util.BuilderUtil; /** @@ -668,6 +669,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java index 271d9b2688..7113677c9a 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java @@ -227,7 +227,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 05f0ada364..cbc944f3a6 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.THE_TARGET_CANNOT_BE_INVITED); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..44a5e8d6a5 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,62 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java index 02f5fd131e..df4cb72f1b 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -138,6 +138,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -934,6 +935,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 682088613c..eb058aae54 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -155,6 +155,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -527,7 +529,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, null, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME), @@ -592,7 +594,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, null, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, null, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index ff9e7449b7..cc4deb7c90 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -121,6 +121,7 @@ import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPoi import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusReady; import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.util.BuilderUtil; /** @@ -668,6 +669,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 05f0ada364..cbc944f3a6 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.THE_TARGET_CANNOT_BE_INVITED); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/enchant/RequestEnchantItem.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/enchant/RequestEnchantItem.java index a84a591cea..1d8d2c622d 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/enchant/RequestEnchantItem.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/enchant/RequestEnchantItem.java @@ -230,7 +230,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..44a5e8d6a5 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,62 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..9af15f51c5 --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,125 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java index 9da74fd599..6b6b514d60 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -135,6 +135,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -884,6 +885,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index deffc11dca..a7809a6904 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -90,6 +90,7 @@ import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidBo import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidServerInfo; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -447,7 +448,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15D, ExElementalSpiritChangeType::new, ConnectionState.IN_GAME), // 152 REQUEST_BLOCK_LIST_FOR_AD(0x15E, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15F, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x160, null, ConnectionState.IN_GAME), // 152 + EX_INTERACT_MODIFY(0x160, ExInteractModify::new, ConnectionState.IN_GAME), // 152 EX_TRY_ENCHANT_ARTIFACT(0x161, null, ConnectionState.IN_GAME), // 152 EX_XIGN_CODE(0x162, null, ConnectionState.IN_GAME); // 152 diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index e23924126e..80ce08825b 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -616,6 +616,9 @@ public class EnterWorld implements IClientIncomingPacket player.sendPacket(new ExAutoSoulShot(0, true, 2)); player.sendPacket(new ExAutoSoulShot(0, true, 3)); + // Client settings restore. + player.getClientSettings(); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 110621d575..cd069dee56 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..9af15f51c5 --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,125 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java index 1def4201f6..e130b4826f 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -135,6 +135,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -884,6 +885,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 02232ed0cb..caba3c9067 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -91,6 +91,7 @@ import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidBo import org.l2jmobius.gameserver.network.clientpackets.raidbossinfo.RequestRaidServerInfo; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -448,7 +449,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15D, ExElementalSpiritChangeType::new, ConnectionState.IN_GAME), // 152 REQUEST_BLOCK_LIST_FOR_AD(0x15E, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15F, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x160, null, ConnectionState.IN_GAME), // 152 + EX_INTERACT_MODIFY(0x160, ExInteractModify::new, ConnectionState.IN_GAME), // 152 EX_TRY_ENCHANT_ARTIFACT(0x161, null, ConnectionState.IN_GAME), // 152 EX_XIGN_CODE(0x162, null, ConnectionState.IN_GAME); // 152 diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index e23924126e..80ce08825b 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -616,6 +616,9 @@ public class EnterWorld implements IClientIncomingPacket player.sendPacket(new ExAutoSoulShot(0, true, 2)); player.sendPacket(new ExAutoSoulShot(0, true, 3)); + // Client settings restore. + player.getClientSettings(); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java index 088a14969d..189197b44f 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java @@ -228,7 +228,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 110621d575..cd069dee56 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..b2f7eac3e4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,43 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + _announceName = player.getName(); } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java index b9789fe3e8..3060251b1e 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -139,6 +139,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -904,6 +905,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 4484b135ed..7c32ce906b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -102,6 +102,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -467,7 +469,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, ExElementalSpiritChangeType::new, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, null, ConnectionState.IN_GAME), @@ -530,7 +532,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19A, null, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19B, null, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19C, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19D, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19D, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_ANTIBOT(0x19E, null, ConnectionState.IN_GAME), EX_DPSVR(0x19F, null, ConnectionState.IN_GAME), EX_TENPROTECT_DECRYPT_ERROR(0x1A0, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 075bc837b9..02de25ae4c 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -112,6 +112,7 @@ import org.l2jmobius.gameserver.network.serverpackets.attendance.ExVipAttendance import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExConnectedTimeAndGettableReward; import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList; import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.util.BuilderUtil; /** @@ -624,6 +625,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java index 088a14969d..189197b44f 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java @@ -228,7 +228,7 @@ public class RequestEnchantItem implements IClientIncomingPacket sm.addInt(item.getEnchantLevel()); sm.addItemName(item); player.broadcastPacket(sm); - Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player)); + Broadcast.toAllOnlinePlayers(new ExItemAnnounce(player, item, ExItemAnnounce.ENCHANT)); final Skill skill = CommonSkill.FIREWORK.getSkill(); if (skill != null) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 110621d575..cd069dee56 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 4eea62de37..44a5e8d6a5 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -22,28 +22,62 @@ import org.l2jmobius.gameserver.model.item.instance.Item; import org.l2jmobius.gameserver.network.OutgoingPackets; /** - * @author NviX + * @author NviX, Mobius */ public class ExItemAnnounce implements IClientOutgoingPacket { - private final Item _item; - private final Player _player; + public static final int ENCHANT = 0; + public static final int RANDOM_CRAFT = 2; - public ExItemAnnounce(Item item, Player player) + private final Item _item; + private final int _type; + private final String _announceName; + + public ExItemAnnounce(Player player, Item item, int type) { _item = item; - _player = player; + _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); - packet.writeC(0); // item icon - packet.writeString(_player.getName()); // name of player + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. + packet.writeC(_type); // announce type + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java index 6c2ae2d705..3bbaf39dd7 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -141,6 +141,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -937,6 +938,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index f388dc3341..cc9ea6ca54 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -126,6 +126,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -500,7 +502,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, ExElementalSpiritChangeType::new, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME), @@ -565,7 +567,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, ExRequestRandomCraftRefresh::new, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, ExRequestRandomCraftMake::new, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, ExRequestSharingLocationUi::new, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index a56652f041..68f3edeaaa 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -118,6 +118,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI; import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.util.BuilderUtil; /** @@ -631,6 +632,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 0999ee7ad2..165d9a5916 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.THE_TARGET_CANNOT_BE_INVITED); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 132003d4d8..44a5e8d6a5 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -30,25 +30,54 @@ public class ExItemAnnounce implements IClientOutgoingPacket public static final int RANDOM_CRAFT = 2; private final Item _item; - private final Player _player; private final int _type; + private final String _announceName; public ExItemAnnounce(Player player, Item item, int type) { - _player = player; _item = item; _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. packet.writeC(_type); // announce type - packet.writeString(_player.getName()); // name of player + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java index 8af2f22629..b3533b87aa 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -143,6 +143,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -969,6 +970,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index c6bf1ad710..39b08ad5b3 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -140,6 +140,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -518,7 +520,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, ExElementalSpiritChangeType::new, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME), @@ -583,7 +585,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, ExRequestRandomCraftRefresh::new, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, ExRequestRandomCraftMake::new, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, ExRequestSharingLocationUi::new, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index fdb3636eb7..bd2d53c282 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -121,6 +121,7 @@ import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCoun import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI; import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeContributionList; import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar; import org.l2jmobius.gameserver.util.BuilderUtil; @@ -638,6 +639,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 0999ee7ad2..165d9a5916 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.THE_TARGET_CANNOT_BE_INVITED); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 132003d4d8..44a5e8d6a5 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -30,25 +30,54 @@ public class ExItemAnnounce implements IClientOutgoingPacket public static final int RANDOM_CRAFT = 2; private final Item _item; - private final Player _player; private final int _type; + private final String _announceName; public ExItemAnnounce(Player player, Item item, int type) { - _player = player; _item = item; _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. packet.writeC(_type); // announce type - packet.writeString(_player.getName()); // name of player + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java index 09d1e13d01..d6530af7ca 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -144,6 +144,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -977,6 +978,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index c12961eb42..09c1f802f7 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -152,6 +152,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -530,7 +532,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, ExElementalSpiritChangeType::new, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME), @@ -595,7 +597,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, ExRequestRandomCraftRefresh::new, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, ExRequestRandomCraftMake::new, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, ExRequestSharingLocationUi::new, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 9fd31bb0b5..e73614aa59 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -122,6 +122,7 @@ import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCoun import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI; import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeContributionList; import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar; import org.l2jmobius.gameserver.util.BuilderUtil; @@ -639,6 +640,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 05f0ada364..cbc944f3a6 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.THE_TARGET_CANNOT_BE_INVITED); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 132003d4d8..44a5e8d6a5 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -30,25 +30,54 @@ public class ExItemAnnounce implements IClientOutgoingPacket public static final int RANDOM_CRAFT = 2; private final Item _item; - private final Player _player; private final int _type; + private final String _announceName; public ExItemAnnounce(Player player, Item item, int type) { - _player = player; _item = item; _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. packet.writeC(_type); // announce type - packet.writeString(_player.getName()); // name of player + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/ClientSettings.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/ClientSettings.java new file mode 100644 index 0000000000..a781b3c2d2 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/ClientSettings.java @@ -0,0 +1,139 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.model; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author Index + */ +public class ClientSettings +{ + private static final String VARIABLE = "CLIENT_SETTINGS"; + + private final Player _player; + private boolean _announceEnabled; + private boolean _partyRequestRestrictedFromOthers; + private boolean _partyRequestRestrictedFromClan; + private boolean _partyRequestRestrictedFromFriends; + private boolean _friendRequestRestrictedFromOthers; + private boolean _friendRequestRestrictedFromClan; + private int _partyContributionType; + + public ClientSettings(Player player) + { + _player = player; + + final String variable = _player.getVariables().getString(VARIABLE, ""); + final StatSet settings = variable.isEmpty() ? new StatSet() : new StatSet(Arrays.stream(variable.split(",")).map(entry -> entry.split("=")).collect(Collectors.toMap(entry -> entry[0].replace("{", "").replace(" ", ""), entry -> entry[1].replace("}", "").replace(" ", "")))); + _announceEnabled = settings.getBoolean("ANNOUNCE_ENABLED", true); + _partyRequestRestrictedFromOthers = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", false); + _partyRequestRestrictedFromClan = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyRequestRestrictedFromFriends = settings.getBoolean("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", false); + _friendRequestRestrictedFromOthers = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", false); + _friendRequestRestrictedFromClan = settings.getBoolean("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", false); + _partyContributionType = settings.getInt("PARTY_CONTRIBUTION_TYPE", 0); + } + + public void storeSettings() + { + final StatSet settings = new StatSet(); + settings.set("ANNOUNCE_ENABLED", _announceEnabled); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_OTHERS", _partyRequestRestrictedFromOthers); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_CLAN", _partyRequestRestrictedFromClan); + settings.set("PARTY_REQUEST_RESTRICTED_FROM_FRIENDS", _partyRequestRestrictedFromFriends); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_OTHERS", _friendRequestRestrictedFromOthers); + settings.set("FRIENDS_REQUEST_RESTRICTED_FROM_CLAN", _friendRequestRestrictedFromClan); + settings.set("PARTY_CONTRIBUTION_TYPE", _partyContributionType); + _player.getVariables().set(VARIABLE, settings.getSet()); + } + + public boolean isAnnounceEnabled() + { + return _announceEnabled; + } + + public void setAnnounceEnabled(boolean enabled) + { + _announceEnabled = enabled; + storeSettings(); + } + + public boolean isPartyRequestRestrictedFromOthers() + { + return _partyRequestRestrictedFromOthers; + } + + public void setPartyRequestRestrictedFromOthers(boolean partyRequestRestrictedFromOthers) + { + _partyRequestRestrictedFromOthers = partyRequestRestrictedFromOthers; + } + + public boolean isPartyRequestRestrictedFromClan() + { + return _partyRequestRestrictedFromClan; + } + + public void setPartyRequestRestrictedFromClan(boolean partyRequestRestrictedFromClan) + { + _partyRequestRestrictedFromClan = partyRequestRestrictedFromClan; + } + + public boolean isPartyRequestRestrictedFromFriends() + { + return _partyRequestRestrictedFromFriends; + } + + public void setPartyRequestRestrictedFromFriends(boolean partyRequestRestrictedFromFriends) + { + _partyRequestRestrictedFromFriends = partyRequestRestrictedFromFriends; + } + + public boolean isFriendRequestRestrictedFromOthers() + { + return _friendRequestRestrictedFromOthers; + } + + public void setFriendRequestRestrictedFromOthers(boolean friendRequestRestrictedFromOthers) + { + _friendRequestRestrictedFromOthers = friendRequestRestrictedFromOthers; + } + + public boolean isFriendRequestRestrictedFromClan() + { + return _friendRequestRestrictedFromClan; + } + + public void setFriendRequestRestrictionFromClan(boolean friendRequestRestrictedFromClan) + { + _friendRequestRestrictedFromClan = friendRequestRestrictedFromClan; + } + + public int getPartyContributionType() + { + return _partyContributionType; + } + + public void setPartyContributionType(int partyContributionType) + { + _partyContributionType = partyContributionType; + storeSettings(); + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java index 5762a6d3dc..ba03833c6e 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -144,6 +144,7 @@ import org.l2jmobius.gameserver.instancemanager.ZoneManager; import org.l2jmobius.gameserver.model.AccessLevel; import org.l2jmobius.gameserver.model.ArenaParticipantsHolder; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; @@ -982,6 +983,18 @@ public class Player extends Playable return _sellingBuffs; } + // Player client settings + private ClientSettings _clientSettings; + + public ClientSettings getClientSettings() + { + if (_clientSettings == null) + { + _clientSettings = new ClientSettings(this); + } + return _clientSettings; + } + /** * Create a new Player and add it in the characters table of the database.
*
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 16c9e16857..77bbc1266d 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -163,6 +163,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove; import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExInteractModify; +import org.l2jmobius.gameserver.network.clientpackets.settings.ExSaveItemAnnounceSetting; import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle; import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff; @@ -547,7 +549,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ELEMENTAL_SPIRIT_CHANGE_TYPE(0x15C, ExElementalSpiritChangeType::new, ConnectionState.IN_GAME), REQUEST_BLOCK_LIST_FOR_AD(0x15D, null, ConnectionState.IN_GAME), REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME), - EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME), + EX_INTERACT_MODIFY(0x15F, ExInteractModify::new, ConnectionState.IN_GAME), EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME), EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME), EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME), @@ -612,7 +614,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_CRAFT_RANDOM_REFRESH(0x19C, ExRequestRandomCraftRefresh::new, ConnectionState.IN_GAME), EX_CRAFT_RANDOM_MAKE(0x19D, ExRequestRandomCraftMake::new, ConnectionState.IN_GAME), EX_MULTI_SELL_LIST(0x19E, null, ConnectionState.IN_GAME), - EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, null, ConnectionState.IN_GAME), + EX_SAVE_ITEM_ANNOUNCE_SETTING(0x19F, ExSaveItemAnnounceSetting::new, ConnectionState.IN_GAME), EX_OLYMPIAD_UI(0x1A0, null, ConnectionState.IN_GAME), // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, ExRequestSharingLocationUi::new, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 2f4328c9d6..d058b68ae0 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -122,6 +122,7 @@ import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCoun import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI; import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeContributionList; import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar; import org.l2jmobius.gameserver.util.BuilderUtil; @@ -639,6 +640,10 @@ public class EnterWorld implements IClientIncomingPacket player.restoreAutoShortcuts(); player.restoreAutoSettings(); + // Client settings restore. + player.getClientSettings(); + player.sendPacket(new ExItemAnnounceSetting(player.getClientSettings().isAnnounceEnabled())); + // Fix for equipped item skills if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty()) { diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java index 74eb9e6a35..074b35b319 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestAnswerJoinParty.java @@ -68,7 +68,7 @@ public class RequestAnswerJoinParty implements IClientIncomingPacket return; } - requestor.sendPacket(new JoinParty(_response)); + requestor.sendPacket(new JoinParty(_response, requestor)); if (_response == 1) { if (party.getMemberCount() >= Config.ALT_PARTY_MAX_MEMBERS) diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java index 05f0ada364..cbc944f3a6 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java @@ -22,6 +22,7 @@ import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; @@ -74,6 +75,12 @@ public class RequestJoinParty implements IClientIncomingPacket return; } + final ClientSettings clientSettings = requestor.getClientSettings(); + if (clientSettings.getPartyContributionType() != _partyDistributionTypeId) + { + requestor.getClientSettings().setPartyContributionType(_partyDistributionTypeId); + } + if (FakePlayerData.getInstance().isTalkable(_name)) { final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_INVITED_TO_THE_PARTY); @@ -147,7 +154,12 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.THE_TARGET_CANNOT_BE_INVITED); return; } - + if (checkInviteByIgnoredSettings(target, requestor)) + { + requestor.sendPacket(new SystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST).addPcName(target)); + target.sendPacket(new SystemMessage(SystemMessageId.PARTY_INVITATION_IS_SET_UP_TO_BE_REJECTED_AT_PREFERENCES_THE_PARTY_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(requestor)); + return; + } if (target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped()) { requestor.sendPacket(SystemMessageId.INVALID_TARGET); @@ -245,4 +257,16 @@ public class RequestJoinParty implements IClientIncomingPacket requestor.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY); } } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + ClientSettings targetClientSettings = target.getClientSettings(); + boolean condition = targetClientSettings.isPartyRequestRestrictedFromOthers(); + boolean clanCheck = (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan()); + if (condition && ((!targetClientSettings.isPartyRequestRestrictedFromFriends() && target.getFriendList().contains(requestor.getObjectId())) || (!targetClientSettings.isPartyRequestRestrictedFromClan() && clanCheck))) + { + condition = false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java index 505094d3b3..1aff55d509 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/friend/RequestFriendInvite.java @@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.gameserver.data.xml.FakePlayerData; import org.l2jmobius.gameserver.model.BlockList; +import org.l2jmobius.gameserver.model.ClientSettings; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; @@ -134,6 +135,12 @@ public class RequestFriendInvite implements IClientIncomingPacket player.sendPacket(sm); return; } + // Check, if tatget blocked sends requests in game. + if (checkInviteByIgnoredSettings(friend, player)) + { + player.sendPacket(new SystemMessage(SystemMessageId.PREFERENCES_IS_CONFIGURED_TO_REFUSE_FRIEND_REQUESTS_AND_THE_FRIEND_INVITATION_OF_C1_IS_AUTOMATICALLY_REJECTED).addPcName(friend)); + return; + } // Friend request sent. player.onTransactionRequest(friend); friend.sendPacket(new FriendAddRequest(player.getName())); @@ -141,4 +148,15 @@ public class RequestFriendInvite implements IClientIncomingPacket sm.addString(_name); player.sendPacket(sm); } + + private boolean checkInviteByIgnoredSettings(Player target, Player requestor) + { + final ClientSettings targetClientSettings = target.getClientSettings(); + final boolean condition = targetClientSettings.isFriendRequestRestrictedFromOthers(); + if (condition && !targetClientSettings.isFriendRequestRestrictedFromClan() && (target.getClan() != null) && (requestor.getClan() != null) && (target.getClan() == requestor.getClan())) + { + return false; + } + return condition; + } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java new file mode 100644 index 0000000000..220e8ccc3e --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExInteractModify.java @@ -0,0 +1,70 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.ClientSettings; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author Index + */ +public class ExInteractModify implements IClientIncomingPacket +{ + private int _type; + private int _settings; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _type = packet.readC(); + _settings = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final ClientSettings clientSettings = player.getClientSettings(); + switch (_type) + { + case 0: + { + clientSettings.setPartyRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setPartyRequestRestrictedFromClan((_settings & 2) == 2); + clientSettings.setPartyRequestRestrictedFromFriends((_settings & 4) == 4); + clientSettings.storeSettings(); + break; + } + case 1: + { + clientSettings.setFriendRequestRestrictedFromOthers((_settings & 1) == 1); + clientSettings.setFriendRequestRestrictionFromClan((_settings & 2) == 2); + clientSettings.storeSettings(); + break; + } + } + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java new file mode 100644 index 0000000000..b9fcb5bd20 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/settings/ExSaveItemAnnounceSetting.java @@ -0,0 +1,51 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.clientpackets.settings; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting; + +/** + * @author Index + */ +public class ExSaveItemAnnounceSetting implements IClientIncomingPacket +{ + private boolean _announceType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _announceType = packet.readC() == 1; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.getClientSettings().setAnnounceEnabled(_announceType); + player.sendPacket(new ExItemAnnounceSetting(_announceType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java index 132003d4d8..44a5e8d6a5 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExItemAnnounce.java @@ -30,25 +30,54 @@ public class ExItemAnnounce implements IClientOutgoingPacket public static final int RANDOM_CRAFT = 2; private final Item _item; - private final Player _player; private final int _type; + private final String _announceName; public ExItemAnnounce(Player player, Item item, int type) { - _player = player; _item = item; _type = type; + if (player.getClientSettings().isAnnounceEnabled()) + { + _announceName = player.getName(); + } + else + { + switch (player.getLang()) + { + case "ru": + { + _announceName = "Некто"; + break; + } + default: + { + _announceName = "Someone"; + break; + } + } + } } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_ITEM_ANNOUNCE.writeId(packet); + // _type + // 0 - enchant + // 1 - item get from container + // 2 - item get from random creation + // 3 - item get from special creation + // 4 - item get from workbench? + // 5 - item get from festival + // 6 - item get from "limited random creation" + // 7 - fire and item get from container + // 8 and others - null item name by item_id and icon from chest. packet.writeC(_type); // announce type - packet.writeString(_player.getName()); // name of player + packet.writeString(_announceName); // name of player packet.writeD(_item.getId()); // item id - packet.writeD(_item.getEnchantLevel()); // enchant level - packet.writeC(0); // name of item + packet.writeC(_item.getEnchantLevel()); // enchant level + packet.writeD(0); // chest item id return true; } } \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java index c3b9918230..ad16842291 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/JoinParty.java @@ -17,15 +17,18 @@ package org.l2jmobius.gameserver.network.serverpackets; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.OutgoingPackets; public class JoinParty implements IClientOutgoingPacket { private final int _response; + private final int _type; - public JoinParty(int response) + public JoinParty(int response, Player requestor) { _response = response; + _type = requestor.getClientSettings().getPartyContributionType(); } @Override @@ -33,7 +36,12 @@ public class JoinParty implements IClientOutgoingPacket { OutgoingPackets.JOIN_PARTY.writeId(packet); packet.writeD(_response); - packet.writeD(0); // TODO: Find me! + packet.writeD(_type); + if (_type != 0) + { + packet.writeD(0); // TODO: Find me! + packet.writeD(0); // TODO: Find me! + } return true; } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java new file mode 100644 index 0000000000..e68766fcdd --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/settings/ExItemAnnounceSetting.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets.settings; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Index + */ +public class ExItemAnnounceSetting implements IClientOutgoingPacket +{ + private final boolean _announceEnabled; + + public ExItemAnnounceSetting(boolean announceEnabled) + { + _announceEnabled = announceEnabled; + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_ITEM_ANNOUNCE_SETTING.writeId(packet); + packet.writeC(_announceEnabled ? 1 : 0); + return true; + } +}