Ipk2589 12 Опубликовано 16 декабря, 2013 (изменено) Люди нужна ваша помощь! дайте пожалуйста сервисы на java под l2j hf заранее спасибо! просьба: без лишнего флуда! Изменено 16 декабря, 2013 пользователем Ipk2589 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Emrion 13 Опубликовано 17 декабря, 2013 package services.ServiceManager; import java.sql.Connection; import java.sql.PreparedStatement; import java.util.logging.Logger; import net.sf.l2j.L2DatabaseFactory; import net.sf.l2j.gameserver.datatables.CharNameTable; import net.sf.l2j.gameserver.datatables.ClanTable; import net.sf.l2j.gameserver.model.actor.L2Npc; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; import net.sf.l2j.gameserver.model.olympiad.OlympiadManager; import net.sf.l2j.gameserver.model.quest.Quest; import net.sf.l2j.gameserver.model.quest.QuestState; import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse; public class ServiceManager extends Quest { public static final Logger _log = Logger.getLogger(ServiceManager.class.getName()); // NPC Id int ServiceManagerNpc = 2015; // Noble Items int nobleItemId = 4037; int nobleItemCount = 10; // PK Reduce Items int pkReduceItemId = 4037; int pkReduceItemCount = 10; // Change Name Items int changeNameItemId = 4037; int changeNameItemCount = 10; boolean logNameChanges = true; // Change Clan Name Items int changeClanNameItemId = 4037; long changeClanNameItemCount = 10; boolean logClanNameChanges = true; int clanMinLevel = 5; // Clan Level Items int[] clanLevelItemsId = { 57, // Level 5 to 6 57, // Level 6 to 7 57, // Level 7 to 8 }; int[] clanLevelItemsCount = { 6, // Level 5 to 6 7, // Level 6 to 7 8, // Level 7 to 8 }; // Clan Reputation Points Items int clanReputationPointsItemId = 4037; int clanReputationPointsItemCount = 10; // Change Gender Items int changeGenderItemId = 4037; int changeGenderItemCount = 10; public ServiceManager(int questId, String name, String descr) { super(questId, name, descr); addStartNpc(ServiceManagerNpc); addFirstTalkId(ServiceManagerNpc); addTalkId(ServiceManagerNpc); } public static void main(String[] args) { new ServiceManager(-1, ServiceManager.class.getSimpleName(), "custom"); } @Override public String onFirstTalk(L2Npc npc, L2PcInstance player) { if (player.getQuestState(getName()) == null) { newQuestState(player); } else if (player.isInCombat()) return "ServiceManager-Blocked.htm"; else if (player.getPvpFlag() == 1) return "ServiceManager-Blocked.htm"; else if (player.getKarma() != 0) return "ServiceManager-Blocked.htm"; else if (OlympiadManager.getInstance().isRegistered(player)) return "ServiceManager-Blocked.htm"; else if (player.isDead() || player.isFakeDeath()) return "ServiceManager-Blocked.htm"; return "ServiceManager.htm"; } @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmlText = event; QuestState st = player.getQuestState(getName()); if (event.equals("setNoble")) { if (!player.isNoble()) { if (st.getQuestItemsCount(nobleItemId) >= nobleItemCount) { st.takeItems(nobleItemId, nobleItemCount); player.setNoble(true,true); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); player.broadcastUserInfo(); return "NoblesseServiceManager-Success.htm"; } return "NoblesseServiceManager-NoItems.htm"; } return "NoblesseServiceManager-AlredyNoble.htm"; } else if (event.equals("levelUpClan")) { if (player.getClan() == null) { return "ClanLevelUp-NoClan.htm"; } else if (!player.isClanLeader()) { return "ClanLevelUp-NoLeader.htm"; } else { if (player.getClan().getLevel() == { return "ClanLevelUp-MaxLevel.htm"; } if (((player.getClan().getLevel() <= 1) || (player.getClan().getLevel() == 2) || (player.getClan().getLevel() == 3) || (player.getClan().getLevel() == 4))) { player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } else if (player.getClan().getLevel() == 5) { if (st.getQuestItemsCount(clanLevelItemsId[0]) >= clanLevelItemsCount[0]) { st.takeItems(clanLevelItemsId[0], clanLevelItemsCount[0]); player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } return "ClanLevelUp-NoItems.htm"; } else if (player.getClan().getLevel() == 6) { if (st.getQuestItemsCount(clanLevelItemsId[1]) >= clanLevelItemsCount[1]) { st.takeItems(clanLevelItemsId[1], clanLevelItemsCount[1]); player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } return "ClanLevelUp-NoItems.htm"; } else if (player.getClan().getLevel() == 7) { if (st.getQuestItemsCount(clanLevelItemsId[2]) >= clanLevelItemsCount[2]) { st.takeItems(clanLevelItemsId[2], clanLevelItemsCount[2]); player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } return "ClanLevelUp-NoItems.htm"; } try (Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_level=? WHERE clan_id=?"); statement.setInt(1, player.getClan().getLevel()); statement.setInt(2, player.getClan().getClanId()); statement.execute(); statement.close(); } catch (Exception e) { _log.info("Error updating clan level for player " + player.getName() + ". Error: " + e); } player.getClan().broadcastClanStatus(); return "ClanLevelUp.htm"; } } else if (event.equals("changeGender")) { if (st.getQuestItemsCount(changeGenderItemId) >= changeGenderItemCount) { st.takeItems(changeGenderItemId, changeGenderItemCount); player.getAppearance().setSex(player.getAppearance().getSex() ? false : true); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); player.broadcastUserInfo(); return "ChangeGender-Success.htm"; } return "ChangeGender-NoItems.htm"; } else if (event.startsWith("changeName")) { try { String newName = event.substring(11); if (st.getQuestItemsCount(changeNameItemId) >= changeNameItemCount) { if (newName == null) { return "ChangeName.htm"; } if (!newName.matches("^[a-zA-Z0-9]+$")) { player.sendMessage("Incorrect name. Please try again."); return "ChangeName.htm"; } else if (newName.equals(player.getName())) { player.sendMessage("Please, choose a different name."); return "ChangeName.htm"; } else if (CharNameTable.doesCharNameExist(newName)) { player.sendMessage("The name " + newName + " already exists."); return "ChangeName.htm"; } else { st.takeItems(changeNameItemId, changeNameItemCount); player.setName(newName); player.store(); player.sendMessage("Your new character name is " + newName); player.broadcastUserInfo(); player.getClan().broadcastClanStatus(); return "ChangeName-Success.htm"; } } return "ChangeName-NoItems.htm"; } catch (Exception e) { player.sendMessage("Please, insert a correct name."); return "ChangeName.htm"; } } else if (event.startsWith("reducePks")) { try { String pkReduceString = event.substring(10); int pkReduceCount = Integer.parseInt(pkReduceString); if (player.getPkKills() != 0) { if (pkReduceCount == 0) { player.sendMessage("Please, put a higher value."); return "PkServiceManager.htm"; } if (st.getQuestItemsCount(pkReduceItemId) >= pkReduceItemCount) { st.takeItems(pkReduceItemId, pkReduceItemCount * pkReduceCount); player.setPkKills(player.getPkKills() - pkReduceCount); player.sendMessage("You have successfuly cleaned " + pkReduceCount + " PKs."); player.broadcastUserInfo(); return "PkServiceManager-Success.htm"; } return "PkServiceManager-NoItems.htm"; } return "PkServiceManager-NoPks.htm"; } catch (Exception e) { player.sendMessage("Incorrect value. Please try again."); return "PkServiceManager.htm"; } } else if (event.startsWith("changeClanName")) { if (player.getClan() == null) { return "ChangeClanName-NoClan.htm"; } try { String newClanName = event.substring(15); if (st.getQuestItemsCount(changeClanNameItemId) >= changeClanNameItemCount) { if (newClanName == null) { return "ChangeClanName.htm"; } if (!player.isClanLeader()) { player.sendMessage("Only the clan leader can change the clan name."); return "ChangeClanName.htm"; } else if (player.getClan().getLevel() < clanMinLevel) { player.sendMessage("Your clan must be at least level " + clanMinLevel + " to change the name."); return "ChangeClanName.htm"; } else if (!newClanName.matches("^[a-zA-Z0-9]+$")) { player.sendMessage("Incorrect name. Please try again."); return "ChangeClanName.htm"; } else if (newClanName.equals(player.getClan().getName())) { player.sendMessage("Please, choose a different name."); return "ChangeClanName.htm"; } else if (ClanTable.getInstance().getClanByName(newClanName) != null) { player.sendMessage("The name " + newClanName + " already exists."); return "ChangeClanName.htm"; } else { st.takeItems(changeNameItemId, changeNameItemCount); player.getClan().setName(newClanName); try (Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_name=? WHERE clan_id=?"); statement.setString(1, newClanName); statement.setInt(2, player.getClan().getClanId()); statement.execute(); statement.close(); } catch (Exception e) { _log.info("Error updating clan name for player " + player.getName() + ". Error: " + e); } player.sendMessage("Your new clan name is " + newClanName); player.getClan().broadcastClanStatus(); return "ChangeClanName-Success.htm"; } } return "ChangeClanName-NoItems.htm"; } catch (Exception e) { player.sendMessage("Please, insert a correct name."); return "ChangeClanName.htm"; } } else if (event.startsWith("setReputationPoints")) { try { String reputationPointsString = event.substring(20); int reputationPointsCount = Integer.parseInt(reputationPointsString); if (player.getClan() == null) { return "ClanReputationPoints-NoClan.htm"; } else if (!player.isClanLeader()) { return "ClanReputationPoints-NoLeader.htm"; } else { if (reputationPointsCount == 0) { player.sendMessage("Please, put a higher value."); return "ClanReputationPoints.htm"; } if (st.getQuestItemsCount(clanReputationPointsItemId) >= clanReputationPointsItemCount) { st.takeItems(clanReputationPointsItemId, clanReputationPointsItemCount * reputationPointsCount); player.getClan().addReputationScore(reputationPointsCount); player.getClan().broadcastClanStatus(); return "ClanReputationPoints-Success.htm"; } return "ClanReputationPoints-NoItems.htm"; } } catch (Exception e) { player.sendMessage("Incorrect value. Please try again."); return "ClanReputationPoints.htm"; } } return htmlText; } } Если ты это имел ввиду 2 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Ipk2589 12 Опубликовано 17 декабря, 2013 (изменено) package services.ServiceManager; import java.sql.Connection; import java.sql.PreparedStatement; import java.util.logging.Logger; import net.sf.l2j.L2DatabaseFactory; import net.sf.l2j.gameserver.datatables.CharNameTable; import net.sf.l2j.gameserver.datatables.ClanTable; import net.sf.l2j.gameserver.model.actor.L2Npc; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; import net.sf.l2j.gameserver.model.olympiad.OlympiadManager; import net.sf.l2j.gameserver.model.quest.Quest; import net.sf.l2j.gameserver.model.quest.QuestState; import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse; public class ServiceManager extends Quest { public static final Logger _log = Logger.getLogger(ServiceManager.class.getName()); // NPC Id int ServiceManagerNpc = 2015; // Noble Items int nobleItemId = 4037; int nobleItemCount = 10; // PK Reduce Items int pkReduceItemId = 4037; int pkReduceItemCount = 10; // Change Name Items int changeNameItemId = 4037; int changeNameItemCount = 10; boolean logNameChanges = true; // Change Clan Name Items int changeClanNameItemId = 4037; long changeClanNameItemCount = 10; boolean logClanNameChanges = true; int clanMinLevel = 5; // Clan Level Items int[] clanLevelItemsId = { 57, // Level 5 to 6 57, // Level 6 to 7 57, // Level 7 to 8 }; int[] clanLevelItemsCount = { 6, // Level 5 to 6 7, // Level 6 to 7 8, // Level 7 to 8 }; // Clan Reputation Points Items int clanReputationPointsItemId = 4037; int clanReputationPointsItemCount = 10; // Change Gender Items int changeGenderItemId = 4037; int changeGenderItemCount = 10; public ServiceManager(int questId, String name, String descr) { super(questId, name, descr); addStartNpc(ServiceManagerNpc); addFirstTalkId(ServiceManagerNpc); addTalkId(ServiceManagerNpc); } public static void main(String[] args) { new ServiceManager(-1, ServiceManager.class.getSimpleName(), "custom"); } @Override public String onFirstTalk(L2Npc npc, L2PcInstance player) { if (player.getQuestState(getName()) == null) { newQuestState(player); } else if (player.isInCombat()) return "ServiceManager-Blocked.htm"; else if (player.getPvpFlag() == 1) return "ServiceManager-Blocked.htm"; else if (player.getKarma() != 0) return "ServiceManager-Blocked.htm"; else if (OlympiadManager.getInstance().isRegistered(player)) return "ServiceManager-Blocked.htm"; else if (player.isDead() || player.isFakeDeath()) return "ServiceManager-Blocked.htm"; return "ServiceManager.htm"; } @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmlText = event; QuestState st = player.getQuestState(getName()); if (event.equals("setNoble")) { if (!player.isNoble()) { if (st.getQuestItemsCount(nobleItemId) >= nobleItemCount) { st.takeItems(nobleItemId, nobleItemCount); player.setNoble(true,true); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); player.broadcastUserInfo(); return "NoblesseServiceManager-Success.htm"; } return "NoblesseServiceManager-NoItems.htm"; } return "NoblesseServiceManager-AlredyNoble.htm"; } else if (event.equals("levelUpClan")) { if (player.getClan() == null) { return "ClanLevelUp-NoClan.htm"; } else if (!player.isClanLeader()) { return "ClanLevelUp-NoLeader.htm"; } else { if (player.getClan().getLevel() == { return "ClanLevelUp-MaxLevel.htm"; } if (((player.getClan().getLevel() <= 1) || (player.getClan().getLevel() == 2) || (player.getClan().getLevel() == 3) || (player.getClan().getLevel() == 4))) { player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } else if (player.getClan().getLevel() == 5) { if (st.getQuestItemsCount(clanLevelItemsId[0]) >= clanLevelItemsCount[0]) { st.takeItems(clanLevelItemsId[0], clanLevelItemsCount[0]); player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } return "ClanLevelUp-NoItems.htm"; } else if (player.getClan().getLevel() == 6) { if (st.getQuestItemsCount(clanLevelItemsId[1]) >= clanLevelItemsCount[1]) { st.takeItems(clanLevelItemsId[1], clanLevelItemsCount[1]); player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } return "ClanLevelUp-NoItems.htm"; } else if (player.getClan().getLevel() == 7) { if (st.getQuestItemsCount(clanLevelItemsId[2]) >= clanLevelItemsCount[2]) { st.takeItems(clanLevelItemsId[2], clanLevelItemsCount[2]); player.getClan().setLevel(player.getClan().getLevel() + 1); player.getClan().broadcastClanStatus(); player.sendMessage("Your clan is now level " + player.getClan().getLevel() + "."); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); return "ClanLevelUp.htm"; } return "ClanLevelUp-NoItems.htm"; } try (Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_level=? WHERE clan_id=?"); statement.setInt(1, player.getClan().getLevel()); statement.setInt(2, player.getClan().getClanId()); statement.execute(); statement.close(); } catch (Exception e) { _log.info("Error updating clan level for player " + player.getName() + ". Error: " + e); } player.getClan().broadcastClanStatus(); return "ClanLevelUp.htm"; } } else if (event.equals("changeGender")) { if (st.getQuestItemsCount(changeGenderItemId) >= changeGenderItemCount) { st.takeItems(changeGenderItemId, changeGenderItemCount); player.getAppearance().setSex(player.getAppearance().getSex() ? false : true); player.setTarget(player); player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0)); player.broadcastUserInfo(); return "ChangeGender-Success.htm"; } return "ChangeGender-NoItems.htm"; } else if (event.startsWith("changeName")) { try { String newName = event.substring(11); if (st.getQuestItemsCount(changeNameItemId) >= changeNameItemCount) { if (newName == null) { return "ChangeName.htm"; } if (!newName.matches("^[a-zA-Z0-9]+$")) { player.sendMessage("Incorrect name. Please try again."); return "ChangeName.htm"; } else if (newName.equals(player.getName())) { player.sendMessage("Please, choose a different name."); return "ChangeName.htm"; } else if (CharNameTable.doesCharNameExist(newName)) { player.sendMessage("The name " + newName + " already exists."); return "ChangeName.htm"; } else { st.takeItems(changeNameItemId, changeNameItemCount); player.setName(newName); player.store(); player.sendMessage("Your new character name is " + newName); player.broadcastUserInfo(); player.getClan().broadcastClanStatus(); return "ChangeName-Success.htm"; } } return "ChangeName-NoItems.htm"; } catch (Exception e) { player.sendMessage("Please, insert a correct name."); return "ChangeName.htm"; } } else if (event.startsWith("reducePks")) { try { String pkReduceString = event.substring(10); int pkReduceCount = Integer.parseInt(pkReduceString); if (player.getPkKills() != 0) { if (pkReduceCount == 0) { player.sendMessage("Please, put a higher value."); return "PkServiceManager.htm"; } if (st.getQuestItemsCount(pkReduceItemId) >= pkReduceItemCount) { st.takeItems(pkReduceItemId, pkReduceItemCount * pkReduceCount); player.setPkKills(player.getPkKills() - pkReduceCount); player.sendMessage("You have successfuly cleaned " + pkReduceCount + " PKs."); player.broadcastUserInfo(); return "PkServiceManager-Success.htm"; } return "PkServiceManager-NoItems.htm"; } return "PkServiceManager-NoPks.htm"; } catch (Exception e) { player.sendMessage("Incorrect value. Please try again."); return "PkServiceManager.htm"; } } else if (event.startsWith("changeClanName")) { if (player.getClan() == null) { return "ChangeClanName-NoClan.htm"; } try { String newClanName = event.substring(15); if (st.getQuestItemsCount(changeClanNameItemId) >= changeClanNameItemCount) { if (newClanName == null) { return "ChangeClanName.htm"; } if (!player.isClanLeader()) { player.sendMessage("Only the clan leader can change the clan name."); return "ChangeClanName.htm"; } else if (player.getClan().getLevel() < clanMinLevel) { player.sendMessage("Your clan must be at least level " + clanMinLevel + " to change the name."); return "ChangeClanName.htm"; } else if (!newClanName.matches("^[a-zA-Z0-9]+$")) { player.sendMessage("Incorrect name. Please try again."); return "ChangeClanName.htm"; } else if (newClanName.equals(player.getClan().getName())) { player.sendMessage("Please, choose a different name."); return "ChangeClanName.htm"; } else if (ClanTable.getInstance().getClanByName(newClanName) != null) { player.sendMessage("The name " + newClanName + " already exists."); return "ChangeClanName.htm"; } else { st.takeItems(changeNameItemId, changeNameItemCount); player.getClan().setName(newClanName); try (Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_name=? WHERE clan_id=?"); statement.setString(1, newClanName); statement.setInt(2, player.getClan().getClanId()); statement.execute(); statement.close(); } catch (Exception e) { _log.info("Error updating clan name for player " + player.getName() + ". Error: " + e); } player.sendMessage("Your new clan name is " + newClanName); player.getClan().broadcastClanStatus(); return "ChangeClanName-Success.htm"; } } return "ChangeClanName-NoItems.htm"; } catch (Exception e) { player.sendMessage("Please, insert a correct name."); return "ChangeClanName.htm"; } } else if (event.startsWith("setReputationPoints")) { try { String reputationPointsString = event.substring(20); int reputationPointsCount = Integer.parseInt(reputationPointsString); if (player.getClan() == null) { return "ClanReputationPoints-NoClan.htm"; } else if (!player.isClanLeader()) { return "ClanReputationPoints-NoLeader.htm"; } else { if (reputationPointsCount == 0) { player.sendMessage("Please, put a higher value."); return "ClanReputationPoints.htm"; } if (st.getQuestItemsCount(clanReputationPointsItemId) >= clanReputationPointsItemCount) { st.takeItems(clanReputationPointsItemId, clanReputationPointsItemCount * reputationPointsCount); player.getClan().addReputationScore(reputationPointsCount); player.getClan().broadcastClanStatus(); return "ClanReputationPoints-Success.htm"; } return "ClanReputationPoints-NoItems.htm"; } } catch (Exception e) { player.sendMessage("Incorrect value. Please try again."); return "ClanReputationPoints.htm"; } } return htmlText; } } Если ты это имел ввиду Спасибо,то что нужно) Изменено 17 декабря, 2013 пользователем Ipk2589 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Naik 419 Опубликовано 17 декабря, 2013 БЛ******!!! Вас в детстве не учили в спойлер прятать такой большой код? Где модеры??? 1 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
RastaDev 54 Опубликовано 17 декабря, 2013 Ну или хотя бы в CODE))) Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты