diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini index dd3690d035..5eabb61469 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini @@ -677,7 +677,7 @@ ResumeAutoPlay = False Share loction L-Coin cost. # Default: 50 -ShareLocationLcoinCost = 1000 +ShareLocationLcoinCost = 50 # Teleport share location L-Coin cost. # Default: 400 diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java index 5c1023ee81..e984d4e7ba 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -35,7 +37,7 @@ public class ChatAlliance implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if ((activeChar.getClan() == null) || ((activeChar.getClan() != null) && (activeChar.getClan().getAllyId() == 0))) { @@ -53,7 +55,25 @@ public class ChatAlliance implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar, type, activeChar.getName(), text)); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation)); } @Override diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatClan.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatClan.java index e3941e445f..66a4396aa3 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatClan.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatClan.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -36,7 +38,7 @@ public class ChatClan implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.getClan() == null) { @@ -54,7 +56,25 @@ public class ChatClan implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } @Override diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java index a255c85826..8d130ba9f7 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java @@ -27,6 +27,8 @@ import org.l2jmobius.gameserver.handler.VoicedCommandHandler; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -43,7 +45,7 @@ public class ChatGeneral implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String paramsValue, String text) + public void handleChat(ChatType type, Player activeChar, String paramsValue, String text, boolean shareLocation) { boolean vcdUsed = false; if (text.startsWith(".")) @@ -87,8 +89,26 @@ public class ChatGeneral implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), text); - final CreatureSay csRandom = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text)); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), text, shareLocation); + final CreatureSay csRandom = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text), shareLocation); + World.getInstance().forEachVisibleObjectInRange(activeChar, Player.class, 1250, player -> { if ((player != null) && !BlockList.isBlocked(player, activeChar)) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java index 3f5dd28c9e..2c7e0fa640 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java @@ -38,7 +38,7 @@ public class ChatHeroVoice implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!activeChar.isHero() && !activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS)) { @@ -62,7 +62,7 @@ public class ChatHeroVoice implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); for (Player player : World.getInstance().getPlayers()) { if ((player != null) && !BlockList.isBlocked(player, activeChar)) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatParty.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatParty.java index f230ec4825..ccdb5e9396 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatParty.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatParty.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -36,7 +38,7 @@ public class ChatParty implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!activeChar.isInParty()) { @@ -54,7 +56,25 @@ public class ChatParty implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } @Override diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java index 121a4ca559..6c568be585 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java @@ -37,7 +37,7 @@ public class ChatPartyMatchRoom implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { final MatchingRoom room = activeChar.getMatchingRoom(); if (room != null) @@ -53,7 +53,7 @@ public class ChatPartyMatchRoom implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); for (Player _member : room.getMembers()) { if (Config.FACTION_SYSTEM_ENABLED) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java index f004e20123..a17f72158c 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java @@ -36,7 +36,7 @@ public class ChatPartyRoomAll implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isInParty() && activeChar.getParty().isInCommandChannel() && activeChar.getParty().isLeader(activeChar)) { @@ -50,7 +50,7 @@ public class ChatPartyRoomAll implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java index e8c788796f..b6dd918fd9 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java @@ -36,7 +36,7 @@ public class ChatPartyRoomCommander implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isInParty() && activeChar.getParty().isInCommandChannel() && activeChar.getParty().getCommandChannel().getLeader().equals(activeChar)) { @@ -50,7 +50,7 @@ public class ChatPartyRoomCommander implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java index 7e7d4a95db..984e074810 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java @@ -37,7 +37,7 @@ public class ChatPetition implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatShout.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatShout.java index 9b8bea6aff..6b53303744 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatShout.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatShout.java @@ -24,6 +24,8 @@ import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -40,7 +42,7 @@ public class ChatShout implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { @@ -58,7 +60,24 @@ public class ChatShout implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS))) { final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java index 79f4b2ce28..771cfabbc2 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java @@ -24,6 +24,8 @@ import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -40,7 +42,7 @@ public class ChatTrade implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { @@ -58,7 +60,24 @@ public class ChatTrade implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS))) { final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java index 0d067d3940..5debbbd1a7 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java @@ -41,7 +41,7 @@ public class ChatWhisper implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java index c0ee2257e5..43b00d3ecc 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java @@ -27,6 +27,8 @@ import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.ExWorldChatCnt; @@ -46,7 +48,7 @@ public class ChatWorld implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!Config.ENABLE_WORLD_CHAT) { @@ -77,6 +79,14 @@ public class ChatWorld implements IChatHandler { activeChar.sendPacket(SystemMessageId.YOU_HAVE_SPENT_YOUR_WORLD_CHAT_QUOTA_FOR_THE_DAY_IT_IS_RESET_DAILY_AT_7_A_M); } + else if (shareLocation && (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST)) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + } + else if (shareLocation && ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE))) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + } else { // Verify if player is not spaming. @@ -93,7 +103,12 @@ public class ChatWorld implements IChatHandler } } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_SPECIFIC_CHAT) { if (activeChar.isGood()) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java index 1f3e05833d..15233949e4 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java @@ -2180,8 +2180,8 @@ public class Config ENABLE_AUTO_ITEM = generalConfig.getBoolean("EnableAutoItem", true); AUTO_PLAY_ATTACK_ACTION = generalConfig.getBoolean("AutoPlayAttackAction", true); RESUME_AUTO_PLAY = generalConfig.getBoolean("ResumeAutoPlay", false); - SHARING_LOCATION_COST = generalConfig.getInt("ShareLocationLcoinCost", 1); - TELEPORT_SHARE_LOCATION_COST = generalConfig.getInt("TeleportShareLocationLcoinCost", 1); + SHARING_LOCATION_COST = generalConfig.getInt("ShareLocationLcoinCost", 50); + TELEPORT_SHARE_LOCATION_COST = generalConfig.getInt("TeleportShareLocationLcoinCost", 400); // Load FloodProtector config file final PropertiesParser floodProtectorConfig = new PropertiesParser(FLOOD_PROTECTOR_CONFIG_FILE); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java index a31c0bfb4c..3ed5413b02 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java @@ -139,7 +139,6 @@ import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager; import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager; import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.instancemanager.RankingPowerManager; import org.l2jmobius.gameserver.instancemanager.MailManager; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.instancemanager.MatchingRoomManager; @@ -151,8 +150,10 @@ import org.l2jmobius.gameserver.instancemanager.PremiumManager; import org.l2jmobius.gameserver.instancemanager.PunishmentManager; import org.l2jmobius.gameserver.instancemanager.QuestManager; import org.l2jmobius.gameserver.instancemanager.RankManager; +import org.l2jmobius.gameserver.instancemanager.RankingPowerManager; import org.l2jmobius.gameserver.instancemanager.SellBuffsManager; import org.l2jmobius.gameserver.instancemanager.ServerRestartManager; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.instancemanager.SiegeGuardManager; import org.l2jmobius.gameserver.instancemanager.SiegeManager; import org.l2jmobius.gameserver.instancemanager.WalkingManager; @@ -369,6 +370,7 @@ public class GameServer HtmCache.getInstance(); CrestTable.getInstance(); TeleportListData.getInstance(); + SharedTeleportManager.getInstance(); PetTypesListData.getInstance(); TeleporterData.getInstance(); TimedHuntingZoneData.getInstance(); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/handler/IChatHandler.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/handler/IChatHandler.java index 91049044fb..0d2d20bdd3 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/handler/IChatHandler.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/handler/IChatHandler.java @@ -31,8 +31,9 @@ public interface IChatHandler * @param player * @param target * @param text + * @param shareLocation */ - void handleChat(ChatType type, Player player, String target, String text); + void handleChat(ChatType type, Player player, String target, String text, boolean shareLocation); /** * Returns a list of all chat types registered to this handler diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java new file mode 100644 index 0000000000..1a0fb2ab8a --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java @@ -0,0 +1,69 @@ +/* + * 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.instancemanager; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; + +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; + +/** + * Shared Teleport Manager + * @author NasSeKa + */ +public class SharedTeleportManager +{ + protected static final Logger LOGGER = Logger.getLogger(SharedTeleportManager.class.getName()); + + private static final int TELEPORT_COUNT = 5; + + private final Map _sharedTeleports = new ConcurrentHashMap<>(); + private int _lastSharedTeleportId = 0; + + protected SharedTeleportManager() + { + LOGGER.info(getClass().getSimpleName() + ": initialized."); + } + + public SharedTeleportHolder getTeleport(int id) + { + return _sharedTeleports.get(id); + } + + public synchronized int nextId(Creature creature) + { + final int nextId = ++_lastSharedTeleportId; + _sharedTeleports.put(nextId, new SharedTeleportHolder(nextId, creature.getName(), TELEPORT_COUNT, creature.getX(), creature.getY(), creature.getZ())); + return nextId; + } + + /** + * Gets the single instance of {@code SharedTeleportManager}. + * @return single instance of {@code SharedTeleportManager} + */ + public static SharedTeleportManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final SharedTeleportManager INSTANCE = new SharedTeleportManager(); + } +} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java new file mode 100644 index 0000000000..28ba3789c4 --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java @@ -0,0 +1,63 @@ +/* + * 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.holders; + +import org.l2jmobius.gameserver.model.Location; + +/** + * @author NasSeKa + */ +public class SharedTeleportHolder +{ + private final int _id; + private final String _name; + private int _count; + private final Location _location; + + public SharedTeleportHolder(int id, String name, int count, int x, int y, int z) + { + _id = id; + _name = name; + _count = count; + _location = new Location(x, y, z); + } + + public int getId() + { + return _id; + } + + public String getName() + { + return _name; + } + + public int getCount() + { + return Math.max(0, _count); + } + + public void decrementCount() + { + _count -= 1; + } + + public Location getLocation() + { + return _location; + } +} \ No newline at end of file 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 bd38e6dca5..02dbbec52e 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 @@ -139,6 +139,7 @@ import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetO import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOn; import org.l2jmobius.gameserver.network.clientpackets.stats.ExResetStatusBonus; import org.l2jmobius.gameserver.network.clientpackets.stats.ExSetStatusBonus; +import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharedLocationTeleport; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharedLocationTeleportUi; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharingLocationUi; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleport; @@ -577,7 +578,7 @@ public enum ExIncomingPackets implements IIncomingPackets // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, ExRequestSharingLocationUi::new, ConnectionState.IN_GAME), EX_SHARED_POSITION_TELEPORT_UI(0x1A2, ExRequestSharedLocationTeleportUi::new, ConnectionState.IN_GAME), - EX_SHARED_POSITION_TELEPORT(0x1A3, ExRequestSharedLocationTeleportUi::new, ConnectionState.IN_GAME), + EX_SHARED_POSITION_TELEPORT(0x1A3, ExRequestSharedLocationTeleport::new, ConnectionState.IN_GAME), EX_AUTH_RECONNECT(0x1A4, null, ConnectionState.IN_GAME), EX_PET_EQUIP_ITEM(0x1A5, ExPetEquipItem::new, ConnectionState.IN_GAME), EX_PET_UNEQUIP_ITEM(0x1A6, ExPetUnequipItem::new, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java index adcedbb746..25807fd662 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java @@ -88,16 +88,18 @@ public class Say2 implements IClientIncomingPacket private String _text; private int _type; private String _target; + private boolean _shareLocation; @Override public boolean read(GameClient client, PacketReader packet) { _text = packet.readS(); _type = packet.readD(); + _shareLocation = packet.readC() == 1; if (_type == ChatType.WHISPER.getClientId()) { - packet.readC(); _target = packet.readS(); + _shareLocation = false; } return true; } @@ -215,7 +217,7 @@ public class Say2 implements IClientIncomingPacket final IChatHandler handler = ChatHandler.getInstance().getHandler(chatType); if (handler != null) { - handler.handleChat(chatType, player, _target, _text); + handler.handleChat(chatType, player, _target, _text, _shareLocation); } else { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java new file mode 100644 index 0000000000..23df8580a4 --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java @@ -0,0 +1,86 @@ +/* + * 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.teleports; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author NasSeKa + */ +public class ExRequestSharedLocationTeleport implements IClientIncomingPacket +{ + private int _id; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _id = (packet.readD() - 1) / 256; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final SharedTeleportHolder teleport = SharedTeleportManager.getInstance().getTeleport(_id); + if ((teleport == null) || (teleport.getCount() == 0)) + { + player.sendPacket(SystemMessageId.TELEPORTATION_LIMIT_FOR_THE_COORDINATES_RECEIVED_IS_REACHED); + return; + } + + if (player.getName().equals(teleport.getName())) + { + player.sendPacket(SystemMessageId.YOU_CAN_T_TELEPORT_HERE_FROM_THIS_CLIENT); + return; + } + + if (player.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.TELEPORT_SHARE_LOCATION_COST) + { + player.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((player.getMovieHolder() != null) || player.isFishing() || player.isInInstance() || player.isOnEvent() || player.isInOlympiadMode() || player.inObserverMode() || player.isInTraingCamp() || player.isInTimedHuntingZone() || player.isInsideZone(ZoneId.SIEGE)) + { + player.sendPacket(SystemMessageId.YOU_CANNOT_TELEPORT_RIGHT_NOW); + return; + } + + if (player.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.TELEPORT_SHARE_LOCATION_COST, player, true)) + { + teleport.decrementCount(); + player.abortCast(); + player.stopMove(null); + player.teleToLocation(teleport.getLocation()); + } + } +} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java index d089428596..0dafb1d17c 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java @@ -17,19 +17,24 @@ package org.l2jmobius.gameserver.network.clientpackets.teleports; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; import org.l2jmobius.gameserver.network.serverpackets.teleports.ExShowSharedLocationTeleportUi; /** - * @author GustavoFonseca + * @author NasSeKa */ public class ExRequestSharedLocationTeleportUi implements IClientIncomingPacket { + private int _id; + @Override public boolean read(GameClient client, PacketReader packet) { + _id = (packet.readD() - 1) / 256; return true; } @@ -42,6 +47,12 @@ public class ExRequestSharedLocationTeleportUi implements IClientIncomingPacket return; } - client.sendPacket(new ExShowSharedLocationTeleportUi()); + final SharedTeleportHolder teleport = SharedTeleportManager.getInstance().getTeleport(_id); + if (teleport == null) + { + return; + } + + player.sendPacket(new ExShowSharedLocationTeleportUi(teleport)); } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java index 0182d345cc..b5d87570c9 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java @@ -42,6 +42,6 @@ public class ExRequestSharingLocationUi implements IClientIncomingPacket return; } - client.sendPacket(new ExShowSharingLocationUi()); + player.sendPacket(new ExShowSharingLocationUi()); } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java index 63acd728ea..655d311405 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java @@ -23,6 +23,7 @@ import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.instancemanager.MentorManager; import org.l2jmobius.gameserver.instancemanager.RankManager; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.clan.Clan; @@ -40,6 +41,7 @@ public class CreatureSay implements IClientOutgoingPacket private int _messageId = -1; private int _mask; private List _parameters; + private boolean _shareLocation; /** * @param sender @@ -49,11 +51,25 @@ public class CreatureSay implements IClientOutgoingPacket * @param text */ public CreatureSay(Player sender, Player receiver, String name, ChatType chatType, String text) + { + this(sender, receiver, name, chatType, text, false); + } + + /** + * @param sender + * @param receiver + * @param name + * @param chatType + * @param text + * @param shareLocation + */ + public CreatureSay(Player sender, Player receiver, String name, ChatType chatType, String text, boolean shareLocation) { _sender = sender; _senderName = name; _chatType = chatType; _text = text; + _shareLocation = shareLocation; if (receiver != null) { if (receiver.getFriendList().contains(sender.getObjectId())) @@ -81,11 +97,17 @@ public class CreatureSay implements IClientOutgoingPacket } public CreatureSay(Creature sender, ChatType chatType, String senderName, String text) + { + this(sender, chatType, senderName, text, false); + } + + public CreatureSay(Creature sender, ChatType chatType, String senderName, String text, boolean shareLocation) { _sender = sender; _chatType = chatType; _senderName = senderName; _text = text; + _shareLocation = shareLocation; } public CreatureSay(Creature sender, ChatType chatType, NpcStringId npcStringId) @@ -162,6 +184,7 @@ public class CreatureSay implements IClientOutgoingPacket { packet.writeC(0); // unknown clan byte } + final int rank = RankManager.getInstance().getPlayerGlobalRank(_sender.getActingPlayer()); if ((rank == 0) || (rank > 100)) { @@ -187,6 +210,12 @@ public class CreatureSay implements IClientOutgoingPacket { packet.writeC(0); } + + if (_shareLocation) + { + packet.writeC(1); + packet.writeH(SharedTeleportManager.getInstance().nextId(_sender)); + } } else { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java index 1afad30674..a9f2ca61a3 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java @@ -100,7 +100,7 @@ public class ExBasicActionList implements IClientOutgoingPacket 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 93, - 94, 96, 97, + 94, 96, 97, 99, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java index 38367eda0b..d95734f394 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java @@ -17,24 +17,33 @@ package org.l2jmobius.gameserver.network.serverpackets.teleports; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; /** - * @author Gustavo Fonseca + * @author NasSeKa */ public class ExShowSharedLocationTeleportUi implements IClientOutgoingPacket { - public static final ExShowSharedLocationTeleportUi STATIC_PACKET = new ExShowSharedLocationTeleportUi(); + private final SharedTeleportHolder _teleport; - public ExShowSharedLocationTeleportUi() + public ExShowSharedLocationTeleportUi(SharedTeleportHolder teleport) { + _teleport = teleport; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_SHARED_POSITION_TELEPORT_UI.writeId(packet); + packet.writeString(_teleport.getName()); + packet.writeD(_teleport.getId()); + packet.writeD(_teleport.getCount()); + packet.writeH(150); + packet.writeD(_teleport.getLocation().getX()); + packet.writeD(_teleport.getLocation().getY()); + packet.writeD(_teleport.getLocation().getZ()); return true; } -} \ No newline at end of file +} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini index c02b1ada80..41d41358b3 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini @@ -685,7 +685,7 @@ SubjugationTopicBody = Reward for being in the top of the best players in cleari Share loction L-Coin cost. # Default: 50 -ShareLocationLcoinCost = 1000 +ShareLocationLcoinCost = 50 # Teleport share location L-Coin cost. # Default: 400 diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java index 5c1023ee81..e984d4e7ba 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -35,7 +37,7 @@ public class ChatAlliance implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if ((activeChar.getClan() == null) || ((activeChar.getClan() != null) && (activeChar.getClan().getAllyId() == 0))) { @@ -53,7 +55,25 @@ public class ChatAlliance implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar, type, activeChar.getName(), text)); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation)); } @Override diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatClan.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatClan.java index e3941e445f..66a4396aa3 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatClan.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatClan.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -36,7 +38,7 @@ public class ChatClan implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.getClan() == null) { @@ -54,7 +56,25 @@ public class ChatClan implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } @Override diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java index 7f0776c2e5..6a6d54ecb1 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java @@ -27,6 +27,8 @@ import org.l2jmobius.gameserver.handler.VoicedCommandHandler; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -43,7 +45,7 @@ public class ChatGeneral implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String paramsValue, String text) + public void handleChat(ChatType type, Player activeChar, String paramsValue, String text, boolean shareLocation) { boolean vcdUsed = false; if (text.startsWith(".")) @@ -87,8 +89,26 @@ public class ChatGeneral implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), text); - final CreatureSay csRandom = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text)); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), text, shareLocation); + final CreatureSay csRandom = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text), shareLocation); + World.getInstance().forEachVisibleObjectInRange(activeChar, Player.class, 1250, player -> { if ((player != null) && !BlockList.isBlocked(player, activeChar)) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java index 3f5dd28c9e..2c7e0fa640 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java @@ -38,7 +38,7 @@ public class ChatHeroVoice implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!activeChar.isHero() && !activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS)) { @@ -62,7 +62,7 @@ public class ChatHeroVoice implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); for (Player player : World.getInstance().getPlayers()) { if ((player != null) && !BlockList.isBlocked(player, activeChar)) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatParty.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatParty.java index f230ec4825..ccdb5e9396 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatParty.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatParty.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -36,7 +38,7 @@ public class ChatParty implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!activeChar.isInParty()) { @@ -54,7 +56,25 @@ public class ChatParty implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } @Override diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java index 121a4ca559..6c568be585 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java @@ -37,7 +37,7 @@ public class ChatPartyMatchRoom implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { final MatchingRoom room = activeChar.getMatchingRoom(); if (room != null) @@ -53,7 +53,7 @@ public class ChatPartyMatchRoom implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); for (Player _member : room.getMembers()) { if (Config.FACTION_SYSTEM_ENABLED) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java index f004e20123..a17f72158c 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java @@ -36,7 +36,7 @@ public class ChatPartyRoomAll implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isInParty() && activeChar.getParty().isInCommandChannel() && activeChar.getParty().isLeader(activeChar)) { @@ -50,7 +50,7 @@ public class ChatPartyRoomAll implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java index e8c788796f..b6dd918fd9 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java @@ -36,7 +36,7 @@ public class ChatPartyRoomCommander implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isInParty() && activeChar.getParty().isInCommandChannel() && activeChar.getParty().getCommandChannel().getLeader().equals(activeChar)) { @@ -50,7 +50,7 @@ public class ChatPartyRoomCommander implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java index 7e7d4a95db..984e074810 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java @@ -37,7 +37,7 @@ public class ChatPetition implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatShout.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatShout.java index adde56a664..96a09d2249 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatShout.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatShout.java @@ -24,6 +24,8 @@ import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -40,7 +42,7 @@ public class ChatShout implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { @@ -58,7 +60,24 @@ public class ChatShout implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS))) { final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java index c7a2f099e1..948c4ade67 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java @@ -24,6 +24,8 @@ import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -40,7 +42,7 @@ public class ChatTrade implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { @@ -58,7 +60,24 @@ public class ChatTrade implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS))) { final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java index cd61499164..c8add914e0 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java @@ -41,7 +41,7 @@ public class ChatWhisper implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java index c0ee2257e5..43b00d3ecc 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java @@ -27,6 +27,8 @@ import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.ExWorldChatCnt; @@ -46,7 +48,7 @@ public class ChatWorld implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!Config.ENABLE_WORLD_CHAT) { @@ -77,6 +79,14 @@ public class ChatWorld implements IChatHandler { activeChar.sendPacket(SystemMessageId.YOU_HAVE_SPENT_YOUR_WORLD_CHAT_QUOTA_FOR_THE_DAY_IT_IS_RESET_DAILY_AT_7_A_M); } + else if (shareLocation && (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST)) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + } + else if (shareLocation && ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE))) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + } else { // Verify if player is not spaming. @@ -93,7 +103,12 @@ public class ChatWorld implements IChatHandler } } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_SPECIFIC_CHAT) { if (activeChar.isGood()) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java index 554df2af15..edfd3ef0d0 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java @@ -2281,8 +2281,8 @@ public class Config RESUME_AUTO_PLAY = generalConfig.getBoolean("ResumeAutoPlay", false); SUBJUGATION_TOPIC_BODY = generalConfig.getString("SubjugationTopicBody", "Reward for being in the top of the best players in clearing the lands of Aden"); SUBJUGATION_TOPIC_HEADER = generalConfig.getString("SubjugationTopicHeader", "Purge reward"); - SHARING_LOCATION_COST = generalConfig.getInt("ShareLocationLcoinCost", 1); - TELEPORT_SHARE_LOCATION_COST = generalConfig.getInt("TeleportShareLocationLcoinCost", 1); + SHARING_LOCATION_COST = generalConfig.getInt("ShareLocationLcoinCost", 50); + TELEPORT_SHARE_LOCATION_COST = generalConfig.getInt("TeleportShareLocationLcoinCost", 400); // Load FloodProtector config file final PropertiesParser floodProtectorConfig = new PropertiesParser(FLOOD_PROTECTOR_CONFIG_FILE); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/GameServer.java index b787f2b957..ba622b7515 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/GameServer.java @@ -143,7 +143,6 @@ import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager; import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager; import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.instancemanager.RankingPowerManager; import org.l2jmobius.gameserver.instancemanager.MailManager; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.instancemanager.MatchingRoomManager; @@ -156,8 +155,10 @@ import org.l2jmobius.gameserver.instancemanager.PunishmentManager; import org.l2jmobius.gameserver.instancemanager.PurgeRankingManager; import org.l2jmobius.gameserver.instancemanager.QuestManager; import org.l2jmobius.gameserver.instancemanager.RankManager; +import org.l2jmobius.gameserver.instancemanager.RankingPowerManager; import org.l2jmobius.gameserver.instancemanager.SellBuffsManager; import org.l2jmobius.gameserver.instancemanager.ServerRestartManager; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.instancemanager.SiegeGuardManager; import org.l2jmobius.gameserver.instancemanager.SiegeManager; import org.l2jmobius.gameserver.instancemanager.WalkingManager; @@ -379,6 +380,7 @@ public class GameServer HtmCache.getInstance(); CrestTable.getInstance(); TeleportListData.getInstance(); + SharedTeleportManager.getInstance(); PetTypesListData.getInstance(); TeleporterData.getInstance(); TimedHuntingZoneData.getInstance(); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/handler/IChatHandler.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/handler/IChatHandler.java index 91049044fb..0d2d20bdd3 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/handler/IChatHandler.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/handler/IChatHandler.java @@ -31,8 +31,9 @@ public interface IChatHandler * @param player * @param target * @param text + * @param shareLocation */ - void handleChat(ChatType type, Player player, String target, String text); + void handleChat(ChatType type, Player player, String target, String text, boolean shareLocation); /** * Returns a list of all chat types registered to this handler diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java new file mode 100644 index 0000000000..1a0fb2ab8a --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java @@ -0,0 +1,69 @@ +/* + * 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.instancemanager; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; + +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; + +/** + * Shared Teleport Manager + * @author NasSeKa + */ +public class SharedTeleportManager +{ + protected static final Logger LOGGER = Logger.getLogger(SharedTeleportManager.class.getName()); + + private static final int TELEPORT_COUNT = 5; + + private final Map _sharedTeleports = new ConcurrentHashMap<>(); + private int _lastSharedTeleportId = 0; + + protected SharedTeleportManager() + { + LOGGER.info(getClass().getSimpleName() + ": initialized."); + } + + public SharedTeleportHolder getTeleport(int id) + { + return _sharedTeleports.get(id); + } + + public synchronized int nextId(Creature creature) + { + final int nextId = ++_lastSharedTeleportId; + _sharedTeleports.put(nextId, new SharedTeleportHolder(nextId, creature.getName(), TELEPORT_COUNT, creature.getX(), creature.getY(), creature.getZ())); + return nextId; + } + + /** + * Gets the single instance of {@code SharedTeleportManager}. + * @return single instance of {@code SharedTeleportManager} + */ + public static SharedTeleportManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final SharedTeleportManager INSTANCE = new SharedTeleportManager(); + } +} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java new file mode 100644 index 0000000000..28ba3789c4 --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java @@ -0,0 +1,63 @@ +/* + * 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.holders; + +import org.l2jmobius.gameserver.model.Location; + +/** + * @author NasSeKa + */ +public class SharedTeleportHolder +{ + private final int _id; + private final String _name; + private int _count; + private final Location _location; + + public SharedTeleportHolder(int id, String name, int count, int x, int y, int z) + { + _id = id; + _name = name; + _count = count; + _location = new Location(x, y, z); + } + + public int getId() + { + return _id; + } + + public String getName() + { + return _name; + } + + public int getCount() + { + return Math.max(0, _count); + } + + public void decrementCount() + { + _count -= 1; + } + + public Location getLocation() + { + return _location; + } +} \ No newline at end of file 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 00db6a8ff6..5b3e949d65 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 @@ -157,6 +157,7 @@ import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjuga import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationGachaUI; import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationList; import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationRanking; +import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharedLocationTeleport; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharedLocationTeleportUi; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharingLocationUi; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleport; @@ -595,7 +596,7 @@ public enum ExIncomingPackets implements IIncomingPackets // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, ExRequestSharingLocationUi::new, ConnectionState.IN_GAME), EX_SHARED_POSITION_TELEPORT_UI(0x1A2, ExRequestSharedLocationTeleportUi::new, ConnectionState.IN_GAME), - EX_SHARED_POSITION_TELEPORT(0x1A3, ExRequestSharedLocationTeleportUi::new, ConnectionState.IN_GAME), + EX_SHARED_POSITION_TELEPORT(0x1A3, ExRequestSharedLocationTeleport::new, ConnectionState.IN_GAME), EX_AUTH_RECONNECT(0x1A4, null, ConnectionState.IN_GAME), EX_PET_EQUIP_ITEM(0x1A5, ExPetEquipItem::new, ConnectionState.IN_GAME), EX_PET_UNEQUIP_ITEM(0x1A6, ExPetUnequipItem::new, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java index adcedbb746..25807fd662 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java @@ -88,16 +88,18 @@ public class Say2 implements IClientIncomingPacket private String _text; private int _type; private String _target; + private boolean _shareLocation; @Override public boolean read(GameClient client, PacketReader packet) { _text = packet.readS(); _type = packet.readD(); + _shareLocation = packet.readC() == 1; if (_type == ChatType.WHISPER.getClientId()) { - packet.readC(); _target = packet.readS(); + _shareLocation = false; } return true; } @@ -215,7 +217,7 @@ public class Say2 implements IClientIncomingPacket final IChatHandler handler = ChatHandler.getInstance().getHandler(chatType); if (handler != null) { - handler.handleChat(chatType, player, _target, _text); + handler.handleChat(chatType, player, _target, _text, _shareLocation); } else { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java new file mode 100644 index 0000000000..03fe76a356 --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java @@ -0,0 +1,86 @@ +/* + * 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.teleports; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author NasSeKa + */ +public class ExRequestSharedLocationTeleport implements IClientIncomingPacket +{ + private int _id; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _id = (packet.readD() - 1) / 256; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final SharedTeleportHolder teleport = SharedTeleportManager.getInstance().getTeleport(_id); + if ((teleport == null) || (teleport.getCount() == 0)) + { + player.sendPacket(SystemMessageId.TELEPORTATION_LIMIT_FOR_THE_COORDINATES_RECEIVED_IS_REACHED); + return; + } + + if (player.getName().equals(teleport.getName())) + { + player.sendPacket(SystemMessageId.YOU_CANNOT_TELEPORT_TO_YOURSELF); + return; + } + + if (player.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.TELEPORT_SHARE_LOCATION_COST) + { + player.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((player.getMovieHolder() != null) || player.isFishing() || player.isInInstance() || player.isOnEvent() || player.isInOlympiadMode() || player.inObserverMode() || player.isInTraingCamp() || player.isInTimedHuntingZone() || player.isInsideZone(ZoneId.SIEGE)) + { + player.sendPacket(SystemMessageId.YOU_CANNOT_TELEPORT_RIGHT_NOW); + return; + } + + if (player.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.TELEPORT_SHARE_LOCATION_COST, player, true)) + { + teleport.decrementCount(); + player.abortCast(); + player.stopMove(null); + player.teleToLocation(teleport.getLocation()); + } + } +} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java index d089428596..0dafb1d17c 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java @@ -17,19 +17,24 @@ package org.l2jmobius.gameserver.network.clientpackets.teleports; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; import org.l2jmobius.gameserver.network.serverpackets.teleports.ExShowSharedLocationTeleportUi; /** - * @author GustavoFonseca + * @author NasSeKa */ public class ExRequestSharedLocationTeleportUi implements IClientIncomingPacket { + private int _id; + @Override public boolean read(GameClient client, PacketReader packet) { + _id = (packet.readD() - 1) / 256; return true; } @@ -42,6 +47,12 @@ public class ExRequestSharedLocationTeleportUi implements IClientIncomingPacket return; } - client.sendPacket(new ExShowSharedLocationTeleportUi()); + final SharedTeleportHolder teleport = SharedTeleportManager.getInstance().getTeleport(_id); + if (teleport == null) + { + return; + } + + player.sendPacket(new ExShowSharedLocationTeleportUi(teleport)); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java index 0182d345cc..b5d87570c9 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java @@ -42,6 +42,6 @@ public class ExRequestSharingLocationUi implements IClientIncomingPacket return; } - client.sendPacket(new ExShowSharingLocationUi()); + player.sendPacket(new ExShowSharingLocationUi()); } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java index 63acd728ea..655d311405 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java @@ -23,6 +23,7 @@ import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.instancemanager.MentorManager; import org.l2jmobius.gameserver.instancemanager.RankManager; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.clan.Clan; @@ -40,6 +41,7 @@ public class CreatureSay implements IClientOutgoingPacket private int _messageId = -1; private int _mask; private List _parameters; + private boolean _shareLocation; /** * @param sender @@ -49,11 +51,25 @@ public class CreatureSay implements IClientOutgoingPacket * @param text */ public CreatureSay(Player sender, Player receiver, String name, ChatType chatType, String text) + { + this(sender, receiver, name, chatType, text, false); + } + + /** + * @param sender + * @param receiver + * @param name + * @param chatType + * @param text + * @param shareLocation + */ + public CreatureSay(Player sender, Player receiver, String name, ChatType chatType, String text, boolean shareLocation) { _sender = sender; _senderName = name; _chatType = chatType; _text = text; + _shareLocation = shareLocation; if (receiver != null) { if (receiver.getFriendList().contains(sender.getObjectId())) @@ -81,11 +97,17 @@ public class CreatureSay implements IClientOutgoingPacket } public CreatureSay(Creature sender, ChatType chatType, String senderName, String text) + { + this(sender, chatType, senderName, text, false); + } + + public CreatureSay(Creature sender, ChatType chatType, String senderName, String text, boolean shareLocation) { _sender = sender; _chatType = chatType; _senderName = senderName; _text = text; + _shareLocation = shareLocation; } public CreatureSay(Creature sender, ChatType chatType, NpcStringId npcStringId) @@ -162,6 +184,7 @@ public class CreatureSay implements IClientOutgoingPacket { packet.writeC(0); // unknown clan byte } + final int rank = RankManager.getInstance().getPlayerGlobalRank(_sender.getActingPlayer()); if ((rank == 0) || (rank > 100)) { @@ -187,6 +210,12 @@ public class CreatureSay implements IClientOutgoingPacket { packet.writeC(0); } + + if (_shareLocation) + { + packet.writeC(1); + packet.writeH(SharedTeleportManager.getInstance().nextId(_sender)); + } } else { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java index 1afad30674..a9f2ca61a3 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java @@ -100,7 +100,7 @@ public class ExBasicActionList implements IClientOutgoingPacket 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 93, - 94, 96, 97, + 94, 96, 97, 99, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java index 38367eda0b..d95734f394 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java @@ -17,24 +17,33 @@ package org.l2jmobius.gameserver.network.serverpackets.teleports; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; /** - * @author Gustavo Fonseca + * @author NasSeKa */ public class ExShowSharedLocationTeleportUi implements IClientOutgoingPacket { - public static final ExShowSharedLocationTeleportUi STATIC_PACKET = new ExShowSharedLocationTeleportUi(); + private final SharedTeleportHolder _teleport; - public ExShowSharedLocationTeleportUi() + public ExShowSharedLocationTeleportUi(SharedTeleportHolder teleport) { + _teleport = teleport; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_SHARED_POSITION_TELEPORT_UI.writeId(packet); + packet.writeString(_teleport.getName()); + packet.writeD(_teleport.getId()); + packet.writeD(_teleport.getCount()); + packet.writeH(150); + packet.writeD(_teleport.getLocation().getX()); + packet.writeD(_teleport.getLocation().getY()); + packet.writeD(_teleport.getLocation().getZ()); return true; } -} \ No newline at end of file +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini index c02b1ada80..41d41358b3 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini @@ -685,7 +685,7 @@ SubjugationTopicBody = Reward for being in the top of the best players in cleari Share loction L-Coin cost. # Default: 50 -ShareLocationLcoinCost = 1000 +ShareLocationLcoinCost = 50 # Teleport share location L-Coin cost. # Default: 400 diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java index c21f23fa9d..2a6958a488 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatAlliance.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -35,7 +37,7 @@ public class ChatAlliance implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if ((activeChar.getClan() == null) || ((activeChar.getClan() != null) && (activeChar.getClan().getAllyId() == 0))) { @@ -53,7 +55,25 @@ public class ChatAlliance implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar, type, activeChar.getName(), text)); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation)); } @Override diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatClan.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatClan.java index a8d942077b..cf13a221e3 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatClan.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatClan.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -36,7 +38,7 @@ public class ChatClan implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.getClan() == null) { @@ -54,7 +56,25 @@ public class ChatClan implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } @Override diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java index e8a5e80bee..62844a5b59 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatGeneral.java @@ -27,6 +27,8 @@ import org.l2jmobius.gameserver.handler.VoicedCommandHandler; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -43,7 +45,7 @@ public class ChatGeneral implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String paramsValue, String text) + public void handleChat(ChatType type, Player activeChar, String paramsValue, String text, boolean shareLocation) { boolean vcdUsed = false; if (text.startsWith(".")) @@ -87,8 +89,26 @@ public class ChatGeneral implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), text); - final CreatureSay csRandom = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text)); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), text, shareLocation); + final CreatureSay csRandom = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text), shareLocation); + World.getInstance().forEachVisibleObjectInRange(activeChar, Player.class, 1250, player -> { if ((player != null) && !BlockList.isBlocked(player, activeChar)) diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java index d92151b445..4f135d7922 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatHeroVoice.java @@ -38,7 +38,7 @@ public class ChatHeroVoice implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!activeChar.isHero() && !activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS)) { @@ -62,7 +62,7 @@ public class ChatHeroVoice implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); for (Player player : World.getInstance().getPlayers()) { if ((player != null) && !BlockList.isBlocked(player, activeChar)) diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatParty.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatParty.java index f2de45f444..36dcdafbcf 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatParty.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatParty.java @@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; @@ -36,7 +38,7 @@ public class ChatParty implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!activeChar.isInParty()) { @@ -54,7 +56,25 @@ public class ChatParty implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } @Override diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java index d288093f56..f8f005b565 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyMatchRoom.java @@ -37,7 +37,7 @@ public class ChatPartyMatchRoom implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { final MatchingRoom room = activeChar.getMatchingRoom(); if (room != null) @@ -53,7 +53,7 @@ public class ChatPartyMatchRoom implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); for (Player _member : room.getMembers()) { if (Config.FACTION_SYSTEM_ENABLED) diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java index 93d6db5323..8c78b10b07 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomAll.java @@ -36,7 +36,7 @@ public class ChatPartyRoomAll implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isInParty() && activeChar.getParty().isInCommandChannel() && activeChar.getParty().isLeader(activeChar)) { @@ -50,7 +50,7 @@ public class ChatPartyRoomAll implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java index b4e8b9eaca..31a059bef4 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPartyRoomCommander.java @@ -36,7 +36,7 @@ public class ChatPartyRoomCommander implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isInParty() && activeChar.getParty().isInCommandChannel() && activeChar.getParty().getCommandChannel().getLeader().equals(activeChar)) { @@ -50,7 +50,7 @@ public class ChatPartyRoomCommander implements IChatHandler activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED); return; } - activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar); + activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation), activeChar); } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java index 591afd0c3a..5b7e8f38e2 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatPetition.java @@ -37,7 +37,7 @@ public class ChatPetition implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatShout.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatShout.java index 740409f67f..34aa63e848 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatShout.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatShout.java @@ -24,6 +24,8 @@ import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -40,7 +42,7 @@ public class ChatShout implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { @@ -58,7 +60,24 @@ public class ChatShout implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS))) { final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java index ed51f1f9c5..754aed865a 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatTrade.java @@ -24,6 +24,8 @@ import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.BlockList; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -40,7 +42,7 @@ public class ChatTrade implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { @@ -58,7 +60,24 @@ public class ChatTrade implements IChatHandler return; } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + if (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE)) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + return; + } + + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS))) { final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java index b5b5ab8aa9..a79e8db0d0 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWhisper.java @@ -41,7 +41,7 @@ public class ChatWhisper implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (activeChar.isChatBanned() && Config.BAN_CHAT_CHANNELS.contains(type)) { diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java index 838dd7b08a..a02d989cbb 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/chathandlers/ChatWorld.java @@ -27,6 +27,8 @@ import org.l2jmobius.gameserver.enums.PlayerCondOverride; import org.l2jmobius.gameserver.handler.IChatHandler; import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.CreatureSay; import org.l2jmobius.gameserver.network.serverpackets.ExWorldChatCnt; @@ -46,7 +48,7 @@ public class ChatWorld implements IChatHandler }; @Override - public void handleChat(ChatType type, Player activeChar, String target, String text) + public void handleChat(ChatType type, Player activeChar, String target, String text, boolean shareLocation) { if (!Config.ENABLE_WORLD_CHAT) { @@ -77,6 +79,14 @@ public class ChatWorld implements IChatHandler { activeChar.sendPacket(SystemMessageId.YOU_HAVE_SPENT_YOUR_WORLD_CHAT_QUOTA_FOR_THE_DAY_IT_IS_RESET_DAILY_AT_7_A_M); } + else if (shareLocation && (activeChar.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.SHARING_LOCATION_COST)) + { + activeChar.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + } + else if (shareLocation && ((activeChar.getMovieHolder() != null) || activeChar.isFishing() || activeChar.isInInstance() || activeChar.isOnEvent() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isInTraingCamp() || activeChar.isInTimedHuntingZone() || activeChar.isInsideZone(ZoneId.SIEGE))) + { + activeChar.sendPacket(SystemMessageId.LOCATION_CANNOT_BE_SHARED_SINCE_THE_CONDITIONS_ARE_NOT_MET); + } else { // Verify if player is not spaming. @@ -93,7 +103,12 @@ public class ChatWorld implements IChatHandler } } - final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text); + if (shareLocation) + { + activeChar.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.SHARING_LOCATION_COST, activeChar, true); + } + + final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text, shareLocation); if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_SPECIFIC_CHAT) { if (activeChar.isGood()) diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java index 9fc25b2016..4a698f1b2e 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java @@ -2316,8 +2316,8 @@ public class Config RESUME_AUTO_PLAY = generalConfig.getBoolean("ResumeAutoPlay", false); SUBJUGATION_TOPIC_BODY = generalConfig.getString("SubjugationTopicBody", "Reward for being in the top of the best players in clearing the lands of Aden"); SUBJUGATION_TOPIC_HEADER = generalConfig.getString("SubjugationTopicHeader", "Purge reward"); - SHARING_LOCATION_COST = generalConfig.getInt("ShareLocationLcoinCost", 1); - TELEPORT_SHARE_LOCATION_COST = generalConfig.getInt("TeleportShareLocationLcoinCost", 1); + SHARING_LOCATION_COST = generalConfig.getInt("ShareLocationLcoinCost", 50); + TELEPORT_SHARE_LOCATION_COST = generalConfig.getInt("TeleportShareLocationLcoinCost", 400); // Load FloodProtector config file final PropertiesParser floodProtectorConfig = new PropertiesParser(FLOOD_PROTECTOR_CONFIG_FILE); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/GameServer.java index d06cdae717..13b36a674f 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/GameServer.java @@ -146,7 +146,6 @@ import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager; import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager; import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; -import org.l2jmobius.gameserver.instancemanager.RankingPowerManager; import org.l2jmobius.gameserver.instancemanager.MailManager; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.instancemanager.MatchingRoomManager; @@ -159,8 +158,10 @@ import org.l2jmobius.gameserver.instancemanager.PunishmentManager; import org.l2jmobius.gameserver.instancemanager.PurgeRankingManager; import org.l2jmobius.gameserver.instancemanager.QuestManager; import org.l2jmobius.gameserver.instancemanager.RankManager; +import org.l2jmobius.gameserver.instancemanager.RankingPowerManager; import org.l2jmobius.gameserver.instancemanager.SellBuffsManager; import org.l2jmobius.gameserver.instancemanager.ServerRestartManager; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.instancemanager.SiegeGuardManager; import org.l2jmobius.gameserver.instancemanager.SiegeManager; import org.l2jmobius.gameserver.instancemanager.WalkingManager; @@ -387,6 +388,7 @@ public class GameServer HtmCache.getInstance(); CrestTable.getInstance(); TeleportListData.getInstance(); + SharedTeleportManager.getInstance(); PetTypesListData.getInstance(); TeleporterData.getInstance(); TimedHuntingZoneData.getInstance(); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/handler/IChatHandler.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/handler/IChatHandler.java index 91049044fb..0d2d20bdd3 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/handler/IChatHandler.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/handler/IChatHandler.java @@ -31,8 +31,9 @@ public interface IChatHandler * @param player * @param target * @param text + * @param shareLocation */ - void handleChat(ChatType type, Player player, String target, String text); + void handleChat(ChatType type, Player player, String target, String text, boolean shareLocation); /** * Returns a list of all chat types registered to this handler diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java new file mode 100644 index 0000000000..1a0fb2ab8a --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/instancemanager/SharedTeleportManager.java @@ -0,0 +1,69 @@ +/* + * 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.instancemanager; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; + +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; + +/** + * Shared Teleport Manager + * @author NasSeKa + */ +public class SharedTeleportManager +{ + protected static final Logger LOGGER = Logger.getLogger(SharedTeleportManager.class.getName()); + + private static final int TELEPORT_COUNT = 5; + + private final Map _sharedTeleports = new ConcurrentHashMap<>(); + private int _lastSharedTeleportId = 0; + + protected SharedTeleportManager() + { + LOGGER.info(getClass().getSimpleName() + ": initialized."); + } + + public SharedTeleportHolder getTeleport(int id) + { + return _sharedTeleports.get(id); + } + + public synchronized int nextId(Creature creature) + { + final int nextId = ++_lastSharedTeleportId; + _sharedTeleports.put(nextId, new SharedTeleportHolder(nextId, creature.getName(), TELEPORT_COUNT, creature.getX(), creature.getY(), creature.getZ())); + return nextId; + } + + /** + * Gets the single instance of {@code SharedTeleportManager}. + * @return single instance of {@code SharedTeleportManager} + */ + public static SharedTeleportManager getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final SharedTeleportManager INSTANCE = new SharedTeleportManager(); + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java new file mode 100644 index 0000000000..28ba3789c4 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/holders/SharedTeleportHolder.java @@ -0,0 +1,63 @@ +/* + * 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.holders; + +import org.l2jmobius.gameserver.model.Location; + +/** + * @author NasSeKa + */ +public class SharedTeleportHolder +{ + private final int _id; + private final String _name; + private int _count; + private final Location _location; + + public SharedTeleportHolder(int id, String name, int count, int x, int y, int z) + { + _id = id; + _name = name; + _count = count; + _location = new Location(x, y, z); + } + + public int getId() + { + return _id; + } + + public String getName() + { + return _name; + } + + public int getCount() + { + return Math.max(0, _count); + } + + public void decrementCount() + { + _count -= 1; + } + + public Location getLocation() + { + return _location; + } +} \ No newline at end of file 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 a8b488b6c4..75fd944bf7 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 @@ -182,6 +182,7 @@ import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjuga import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationGachaUI; import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationList; import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationRanking; +import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharedLocationTeleport; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharedLocationTeleportUi; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharingLocationUi; import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleport; @@ -631,7 +632,7 @@ public enum ExIncomingPackets implements IIncomingPackets // 270 EX_SHARED_POSITION_SHARING_UI(0x1A1, ExRequestSharingLocationUi::new, ConnectionState.IN_GAME), EX_SHARED_POSITION_TELEPORT_UI(0x1A2, ExRequestSharedLocationTeleportUi::new, ConnectionState.IN_GAME), - EX_SHARED_POSITION_TELEPORT(0x1A3, ExRequestSharedLocationTeleportUi::new, ConnectionState.IN_GAME), + EX_SHARED_POSITION_TELEPORT(0x1A3, ExRequestSharedLocationTeleport::new, ConnectionState.IN_GAME), EX_AUTH_RECONNECT(0x1A4, null, ConnectionState.IN_GAME), EX_PET_EQUIP_ITEM(0x1A5, ExPetEquipItem::new, ConnectionState.IN_GAME), EX_PET_UNEQUIP_ITEM(0x1A6, ExPetUnequipItem::new, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java index f94ce7a03e..1f61d69229 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/Say2.java @@ -88,16 +88,18 @@ public class Say2 implements IClientIncomingPacket private String _text; private int _type; private String _target; + private boolean _shareLocation; @Override public boolean read(GameClient client, PacketReader packet) { _text = packet.readS(); _type = packet.readD(); + _shareLocation = packet.readC() == 1; if (_type == ChatType.WHISPER.getClientId()) { - packet.readC(); _target = packet.readS(); + _shareLocation = false; } return true; } @@ -215,7 +217,7 @@ public class Say2 implements IClientIncomingPacket final IChatHandler handler = ChatHandler.getInstance().getHandler(chatType); if (handler != null) { - handler.handleChat(chatType, player, _target, _text); + handler.handleChat(chatType, player, _target, _text, _shareLocation); } else { diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java new file mode 100644 index 0000000000..03fe76a356 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleport.java @@ -0,0 +1,86 @@ +/* + * 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.teleports; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; +import org.l2jmobius.gameserver.model.itemcontainer.Inventory; +import org.l2jmobius.gameserver.model.zone.ZoneId; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; + +/** + * @author NasSeKa + */ +public class ExRequestSharedLocationTeleport implements IClientIncomingPacket +{ + private int _id; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _id = (packet.readD() - 1) / 256; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final SharedTeleportHolder teleport = SharedTeleportManager.getInstance().getTeleport(_id); + if ((teleport == null) || (teleport.getCount() == 0)) + { + player.sendPacket(SystemMessageId.TELEPORTATION_LIMIT_FOR_THE_COORDINATES_RECEIVED_IS_REACHED); + return; + } + + if (player.getName().equals(teleport.getName())) + { + player.sendPacket(SystemMessageId.YOU_CANNOT_TELEPORT_TO_YOURSELF); + return; + } + + if (player.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) < Config.TELEPORT_SHARE_LOCATION_COST) + { + player.sendPacket(SystemMessageId.THERE_ARE_NOT_ENOUGH_L_COINS); + return; + } + + if ((player.getMovieHolder() != null) || player.isFishing() || player.isInInstance() || player.isOnEvent() || player.isInOlympiadMode() || player.inObserverMode() || player.isInTraingCamp() || player.isInTimedHuntingZone() || player.isInsideZone(ZoneId.SIEGE)) + { + player.sendPacket(SystemMessageId.YOU_CANNOT_TELEPORT_RIGHT_NOW); + return; + } + + if (player.destroyItemByItemId("Shared Location", Inventory.LCOIN_ID, Config.TELEPORT_SHARE_LOCATION_COST, player, true)) + { + teleport.decrementCount(); + player.abortCast(); + player.stopMove(null); + player.teleToLocation(teleport.getLocation()); + } + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java index d089428596..0dafb1d17c 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharedLocationTeleportUi.java @@ -17,19 +17,24 @@ package org.l2jmobius.gameserver.network.clientpackets.teleports; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; import org.l2jmobius.gameserver.network.serverpackets.teleports.ExShowSharedLocationTeleportUi; /** - * @author GustavoFonseca + * @author NasSeKa */ public class ExRequestSharedLocationTeleportUi implements IClientIncomingPacket { + private int _id; + @Override public boolean read(GameClient client, PacketReader packet) { + _id = (packet.readD() - 1) / 256; return true; } @@ -42,6 +47,12 @@ public class ExRequestSharedLocationTeleportUi implements IClientIncomingPacket return; } - client.sendPacket(new ExShowSharedLocationTeleportUi()); + final SharedTeleportHolder teleport = SharedTeleportManager.getInstance().getTeleport(_id); + if (teleport == null) + { + return; + } + + player.sendPacket(new ExShowSharedLocationTeleportUi(teleport)); } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java index 0182d345cc..b5d87570c9 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/teleports/ExRequestSharingLocationUi.java @@ -42,6 +42,6 @@ public class ExRequestSharingLocationUi implements IClientIncomingPacket return; } - client.sendPacket(new ExShowSharingLocationUi()); + player.sendPacket(new ExShowSharingLocationUi()); } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java index 63acd728ea..655d311405 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/CreatureSay.java @@ -23,6 +23,7 @@ import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.instancemanager.MentorManager; import org.l2jmobius.gameserver.instancemanager.RankManager; +import org.l2jmobius.gameserver.instancemanager.SharedTeleportManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.clan.Clan; @@ -40,6 +41,7 @@ public class CreatureSay implements IClientOutgoingPacket private int _messageId = -1; private int _mask; private List _parameters; + private boolean _shareLocation; /** * @param sender @@ -49,11 +51,25 @@ public class CreatureSay implements IClientOutgoingPacket * @param text */ public CreatureSay(Player sender, Player receiver, String name, ChatType chatType, String text) + { + this(sender, receiver, name, chatType, text, false); + } + + /** + * @param sender + * @param receiver + * @param name + * @param chatType + * @param text + * @param shareLocation + */ + public CreatureSay(Player sender, Player receiver, String name, ChatType chatType, String text, boolean shareLocation) { _sender = sender; _senderName = name; _chatType = chatType; _text = text; + _shareLocation = shareLocation; if (receiver != null) { if (receiver.getFriendList().contains(sender.getObjectId())) @@ -81,11 +97,17 @@ public class CreatureSay implements IClientOutgoingPacket } public CreatureSay(Creature sender, ChatType chatType, String senderName, String text) + { + this(sender, chatType, senderName, text, false); + } + + public CreatureSay(Creature sender, ChatType chatType, String senderName, String text, boolean shareLocation) { _sender = sender; _chatType = chatType; _senderName = senderName; _text = text; + _shareLocation = shareLocation; } public CreatureSay(Creature sender, ChatType chatType, NpcStringId npcStringId) @@ -162,6 +184,7 @@ public class CreatureSay implements IClientOutgoingPacket { packet.writeC(0); // unknown clan byte } + final int rank = RankManager.getInstance().getPlayerGlobalRank(_sender.getActingPlayer()); if ((rank == 0) || (rank > 100)) { @@ -187,6 +210,12 @@ public class CreatureSay implements IClientOutgoingPacket { packet.writeC(0); } + + if (_shareLocation) + { + packet.writeC(1); + packet.writeH(SharedTeleportManager.getInstance().nextId(_sender)); + } } else { diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java index dc7433fc39..9e3d1b8565 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/ExBasicActionList.java @@ -100,7 +100,7 @@ public class ExBasicActionList implements IClientOutgoingPacket 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 93, - 94, 96, 97, + 94, 96, 97, 99, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java index 38367eda0b..d95734f394 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/teleports/ExShowSharedLocationTeleportUi.java @@ -17,24 +17,33 @@ package org.l2jmobius.gameserver.network.serverpackets.teleports; import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.holders.SharedTeleportHolder; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; /** - * @author Gustavo Fonseca + * @author NasSeKa */ public class ExShowSharedLocationTeleportUi implements IClientOutgoingPacket { - public static final ExShowSharedLocationTeleportUi STATIC_PACKET = new ExShowSharedLocationTeleportUi(); + private final SharedTeleportHolder _teleport; - public ExShowSharedLocationTeleportUi() + public ExShowSharedLocationTeleportUi(SharedTeleportHolder teleport) { + _teleport = teleport; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.EX_SHARED_POSITION_TELEPORT_UI.writeId(packet); + packet.writeString(_teleport.getName()); + packet.writeD(_teleport.getId()); + packet.writeD(_teleport.getCount()); + packet.writeH(150); + packet.writeD(_teleport.getLocation().getX()); + packet.writeD(_teleport.getLocation().getY()); + packet.writeD(_teleport.getLocation().getZ()); return true; } -} \ No newline at end of file +}