public void open(Player player) { // Ouvrir coffre if (player.getFight() != null || player.getIsTalkingWith() != 0 || player.getIsTradingWith() != 0 || player.getCurJobAction() != null || player.getCurExchange() != null) return; House house = World.data.getHouse(this.getHouse()); Trunk trunk = player.getCurTrunk(); if (trunk == null) return; if (trunk.getOwner() == player.getAccount().getUUID() || (player.getGuild() == null ? false : player.getGuild().getId() == house.getGuildId() && house.canDo(HouseRight.CG_NO_CODE.getId()))) { open(player, "-", true); } else if (player.getGuild() == null && house.canDo( HouseRight.CO_CANT_OPEN.getId())) { // si on compare par id ça bug (guild null) SocketManager.GAME_SEND_MESSAGE( player, "Ce coffre ne peut être ouvert que par les membres de la guilde !", Server.config.getMotdColor()); return; } else if (trunk.getOwner() > 0) { // Une personne autre le possède, il faut le code pour rentrer SocketManager.GAME_SEND_KODE(player, "CK0|8"); // 8 étant le nombre de chiffre du code } else if (trunk.getOwner() == 0) { // Coffre a personne return; } else { return; } }
public static void open(Player player, String packet, boolean isTrunk) { // Ouvrir un coffre Trunk trunk = player.getCurTrunk(); if (trunk == null) return; if (packet.compareTo(trunk.getKey()) == 0 || isTrunk) { // Si c'est chez lui ou que le mot de passe est bon SocketManager.GAME_SEND_ECK_PACKET(player.getAccount().getGameClient(), 5, ""); SocketManager.GAME_SEND_EL_TRUNK_PACKET(player, trunk); closeCode(player); } else if (packet.compareTo(trunk.getKey()) != 0) { // Mauvais code SocketManager.GAME_SEND_KODE(player, "KE"); Trunk.closeCode(player); player.setCurTrunk(null); } }
@Override public void parse(GameClient client, String packet) { packet = packet.substring(2); Player player = World.data.getPlayerByName(packet); if (player == null) return; SocketManager.GAME_SEND_BWK( client.getPlayer(), player.getAccount().getPseudo() + "|1|" + player.getName() + "|" + player.getMap().getSubArea().getArea().getId()); }
@Override public void parse(GameClient client, String packet) { if (World.data.isMarchandMap(client.getPlayer().getMap().getId())) { SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "113"); return; } if (client.getPlayer().getMap().getId() == 33 || client.getPlayer().getMap().getId() == 38 || client.getPlayer().getMap().getId() == 4601 || client.getPlayer().getMap().getId() == 4259 || client.getPlayer().getMap().getId() == 8036 || client.getPlayer().getMap().getId() == 10301) { if (client.getPlayer().getMap().getStoreCount() >= 25) { SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "125;25"); return; } } else if (client.getPlayer().getMap().getStoreCount() >= 6) { SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "125;6"); return; } long Apayer2 = client.getPlayer().storeAllBuy() / 1000; if (client.getPlayer().getKamas() < Apayer2) { SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "176"); return; } if (Apayer2 < 0) { SocketManager.GAME_SEND_MESSAGE( client.getPlayer(), "Erreur de mode marchand, la somme est n�gatif.", Server.config.getMotdColor()); return; } int orientation = Formulas.getRandomValue(1, 3); client.getPlayer().setKamas(client.getPlayer().getKamas() - Apayer2); client.getPlayer().setOrientation(orientation); Maps map = client.getPlayer().getMap(); client.getPlayer().setSeeSeller(true); World.data.addSeller(client.getPlayer().getId(), client.getPlayer().getMap().getId()); client.kick(); for (Player z : map.getPlayers()) if (z != null && z.isOnline()) SocketManager.GAME_SEND_MERCHANT_LIST(z, z.getMap().getId()); }
@Override public void parse(GameClient client, String packet) { if (client.getPlayer().isMuted()) { SocketManager.GAME_SEND_Im_PACKET( client.getPlayer(), "1124;" + client.getPlayer().getAccount().getMuteTimer().getInitialDelay()); return; } String msg = ""; packet = packet.replace("<", ""); packet = packet.replace(">", ""); if (packet.length() == 3) return; switch (packet.charAt(2)) { case '*': // Canal noir if (!client.getPlayer().getCanaux().contains(packet.charAt(2) + "")) return; msg = packet.split("\\|", 2)[1]; // Commandes joueurs if (msg.charAt(0) == '.') { String line = msg.substring(1, msg.length() - 1); CommandParser.parse(line.toLowerCase(), client.getPlayer()); return; } if (client.getPlayer().getFight() == null) SocketManager.GAME_SEND_cMK_PACKET_TO_MAP( client.getPlayer().getMap(), "", client.getPlayer().getId(), client.getPlayer().getName(), msg); else SocketManager.GAME_SEND_cMK_PACKET_TO_FIGHT( client.getPlayer().getFight(), 7, "", client.getPlayer().getId(), client.getPlayer().getName(), msg); break; case '#': // Canal Equipe if (!client.getPlayer().getCanaux().contains(packet.charAt(2) + "")) return; if (client.getPlayer().getFight() != null) { msg = packet.split("\\|", 2)[1]; int team = client.getPlayer().getFight().getTeamID(client.getPlayer().getId()); if (team == -1) return; SocketManager.GAME_SEND_cMK_PACKET_TO_FIGHT( client.getPlayer().getFight(), team, "#", client.getPlayer().getId(), client.getPlayer().getName(), msg); } break; case '$': // Canal groupe if (!client.getPlayer().getCanaux().contains(packet.charAt(2) + "")) return; if (client.getPlayer().getGroup() == null) break; msg = packet.split("\\|", 2)[1]; SocketManager.GAME_SEND_cMK_PACKET_TO_GROUP( client.getPlayer().getGroup(), "$", client.getPlayer().getId(), client.getPlayer().getName(), msg); break; case ':': // Canal commerce if (!client.getPlayer().getCanaux().contains(packet.charAt(2) + "")) return; long l; if ((l = System.currentTimeMillis() - client.timeLastTradeMsg) < Server.config.getFloodTime()) { l = (Server.config.getFloodTime() - l) / 1000; SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "0115;" + ((int) Math.ceil(l) + 1)); return; } client.timeLastTradeMsg = System.currentTimeMillis(); msg = packet.split("\\|", 2)[1]; SocketManager.GAME_SEND_cMK_PACKET_TO_ALL( ":", client.getPlayer().getId(), client.getPlayer().getName(), msg); break; case '@': // Canal Admin if (client.getPlayer().getAccount().getGmLvl() == 0) return; msg = packet.split("\\|", 2)[1]; SocketManager.GAME_SEND_cMK_PACKET_TO_ADMIN( "@", client.getPlayer().getId(), client.getPlayer().getName(), msg); break; case '?': // Canal recrutement if (!client.getPlayer().getCanaux().contains(packet.charAt(2) + "")) return; long j; if ((j = System.currentTimeMillis() - client.timeLastRecrutmentMsg) < Server.config.getFloodTime()) { j = (Server.config.getFloodTime() - j) / 1000; SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "0115;" + ((int) Math.ceil(j) + 1)); return; } client.timeLastRecrutmentMsg = System.currentTimeMillis(); msg = packet.split("\\|", 2)[1]; SocketManager.GAME_SEND_cMK_PACKET_TO_ALL( "?", client.getPlayer().getId(), client.getPlayer().getName(), msg); break; case '%': // Canal guilde if (!client.getPlayer().getCanaux().contains(packet.charAt(2) + "")) return; if (client.getPlayer().getGuild() == null) return; msg = packet.split("\\|", 2)[1]; SocketManager.GAME_SEND_cMK_PACKET_TO_GUILD( client.getPlayer().getGuild(), "%", client.getPlayer().getId(), client.getPlayer().getName(), msg); break; case 0xC2: // Canal break; case '!': // Alignement if (!client.getPlayer().getCanaux().contains(packet.charAt(2) + "")) return; if (client.getPlayer().getAlignement() == Alignement.NEUTRE) return; if (client.getPlayer().getDeshonor() >= 1) { SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "183"); return; } long k; if ((k = System.currentTimeMillis() - client.timeLastAlignMsg) < Server.config.getFloodTime()) { k = (Server.config.getFloodTime() - k) / 1000; SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "0115;" + ((int) Math.ceil(k) + 1)); return; } client.timeLastAlignMsg = System.currentTimeMillis(); msg = packet.split("\\|", 2)[1]; SocketManager.GAME_SEND_cMK_PACKET_TO_ALIGN( "!", client.getPlayer().getId(), client.getPlayer().getName(), msg, client.getPlayer()); break; default: String nom = packet.substring(2).split("\\|")[0]; msg = packet.split("\\|", 2)[1]; if (nom.length() <= 1) { Log.addToLog("ChatHandler: Chanel non gere : " + nom); } else { Player target = World.data.getPlayerByName(nom); if (target == null) { SocketManager.GAME_SEND_CHAT_ERROR_PACKET(client, nom); return; } if (target.getAccount() == null) { SocketManager.GAME_SEND_CHAT_ERROR_PACKET(client, nom); return; } if (target.getAccount().getGameClient() == null) { SocketManager.GAME_SEND_CHAT_ERROR_PACKET(client, nom); return; } if (target.getAccount().isEnemyWith(client.getPlayer().getAccount().getUUID()) == true || !target.isDispo(client.getPlayer())) { SocketManager.GAME_SEND_Im_PACKET(client.getPlayer(), "114;" + target.getName()); return; } SocketManager.GAME_SEND_cMK_PACKET( target, "F", client.getPlayer().getId(), client.getPlayer().getName(), msg); SocketManager.GAME_SEND_cMK_PACKET( client.getPlayer(), "T", target.getId(), target.getName(), msg); } break; } }
public void removeFromTrunk(int id, int qua, Player player) { if (player.getCurTrunk().getId() != this.getId()) return; Object object = World.data.getObject(id); if (object == null) return; // Si le joueur n'a pas l'item dans son coffre if (this.getObjects().get(id) == null) { Log.addToLog( "Le joueur " + player.getName() + " a tenter de retirer un objet dans un coffre qu'il n'avait pas."); return; } Object object2 = player.getSimilarItem(object); String str = ""; int newQua = object.getQuantity() - qua; if (object2 == null) { // S'il ne reste rien dans le coffre if (newQua <= 0) { // On retire l'item du coffre this.getObjects().remove(id); // On l'ajoute au joueur player.getItems().put(id, object); // On envoie les packets SocketManager.GAME_SEND_OAKO_PACKET(player, object); str = "O-" + id; } else { // On crée une copy de l'item dans le coffre object2 = Object.getClone(object, qua); // On l'ajoute au monde World.data.addObject(object2, true); // On retire X objet du coffre object.setQuantity(newQua); // On l'ajoute au joueur player.getItems().put(object2.getId(), object2); // On envoie les packets SocketManager.GAME_SEND_OAKO_PACKET(player, object2); str = "O+" + object.getId() + "|" + object.getQuantity() + "|" + object.getTemplate().getId() + "|" + object.parseStatsString(); } } else { // S'il ne reste rien dans le coffre if (newQua <= 0) { // On retire l'item du coffre this.getObjects().remove(object.getId()); World.data.removeObject(object.getId()); // On Modifie la quantité de l'item du sac du joueur object2.setQuantity(object2.getQuantity() + object.getQuantity()); // On envoie les packets SocketManager.GAME_SEND_OBJECT_QUANTITY_PACKET(player, object2); str = "O-" + id; } else { // S'il reste des objets dans le coffre // On retire X objet du coffre object.setQuantity(newQua); // On ajoute X objets au joueurs object2.setQuantity(object2.getQuantity() + qua); // On envoie les packets SocketManager.GAME_SEND_OBJECT_QUANTITY_PACKET(player, object2); str = "O+" + object.getId() + "|" + object.getQuantity() + "|" + object.getTemplate().getId() + "|" + object.parseStatsString(); } } for (Player p : player.getMap().getPlayers()) if (p.getCurTrunk() != null && getId() == p.getCurTrunk().getId()) SocketManager.GAME_SEND_EsK_PACKET(p, str); SocketManager.GAME_SEND_Ow_PACKET(player); World.database.getTrunkData().update(this); }
public void addInTrunk(int id, int qua, Player player) { if (player.getCurTrunk().getId() != this.getId()) return; if (this.getObjects().size() >= 80) { // Le plus grand c'est pour si un admin ajoute des objets via la bdd... SocketManager.GAME_SEND_MESSAGE( player, "Le nombre d'objets maximal de ce coffre à été atteint !", Server.config.getMotdColor()); return; } Object object = World.data.getObject(id); if (object == null) return; if (player.getItems().get(id) == null) { Log.addToLog( "Le joueur " + player.getName() + " a tenter d'ajouter un objet dans un coffre qu'il n'avait pas."); return; } String str = ""; // Si c'est un item équipé ... if (object.getPosition() != ObjectPosition.NO_EQUIPED) return; Object TrunkObj = this.getSimilarTrunkItem(object); int newQua = object.getQuantity() - qua; if (TrunkObj == null) { // S'il n'y pas d'item du meme Template // S'il ne reste pas d'item dans le sac if (newQua <= 0) { // On enleve l'objet du sac du joueur player.removeItem(object.getId()); // On met l'objet du sac dans le coffre, avec la meme quantité this.getObjects().put(object.getId(), object); str = "O+" + object.getId() + "|" + object.getQuantity() + "|" + object.getTemplate().getId() + "|" + object.parseStatsString(); SocketManager.GAME_SEND_REMOVE_ITEM_PACKET(player, id); } else { // S'il reste des objets au joueur // on modifie la quantité d'item du sac object.setQuantity(newQua); // On ajoute l'objet au coffre et au monde TrunkObj = Object.getClone(object, qua); World.data.addObject(TrunkObj, true); this.getObjects().put(TrunkObj.getId(), TrunkObj); // Envoie des packets str = "O+" + TrunkObj.getId() + "|" + TrunkObj.getQuantity() + "|" + TrunkObj.getTemplate().getId() + "|" + TrunkObj.parseStatsString(); SocketManager.GAME_SEND_OBJECT_QUANTITY_PACKET(player, object); } } else { // S'il y avait un item du meme template // S'il ne reste pas d'item dans le sac if (newQua <= 0) { // On enleve l'objet du sac du joueur player.removeItem(object.getId()); // On enleve l'objet du monde World.data.removeObject(object.getId()); // On ajoute la quantité a l'objet dans le coffre TrunkObj.setQuantity(TrunkObj.getQuantity() + object.getQuantity()); // on envoie l'ajout au coffre de l'objet str = "O+" + TrunkObj.getId() + "|" + TrunkObj.getQuantity() + "|" + TrunkObj.getTemplate().getId() + "|" + TrunkObj.parseStatsString(); // on envoie la supression de l'objet du sac au joueur SocketManager.GAME_SEND_REMOVE_ITEM_PACKET(player, id); } else { // S'il restait des objets // on modifie la quantité d'item du sac object.setQuantity(newQua); TrunkObj.setQuantity(TrunkObj.getQuantity() + qua); str = "O+" + TrunkObj.getId() + "|" + TrunkObj.getQuantity() + "|" + TrunkObj.getTemplate().getId() + "|" + TrunkObj.parseStatsString(); SocketManager.GAME_SEND_OBJECT_QUANTITY_PACKET(player, object); } } for (Player perso : player.getMap().getPlayers()) if (perso.getCurTrunk() != null && getId() == perso.getCurTrunk().getId()) SocketManager.GAME_SEND_EsK_PACKET(perso, str); SocketManager.GAME_SEND_Ow_PACKET(player); World.database.getTrunkData().update(this); }
public static void closeCode(Player player) { SocketManager.GAME_SEND_KODE(player, "V"); }
public void lock(Player player) { SocketManager.GAME_SEND_KODE(player, "CK1|8"); }