Jump to content

Cod3x

Members
  • Posts

    581
  • Credits

  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by Cod3x

  1. Not bad, just remake the background add different logo ( down ) and re-share it.. Also i checked something in the photo there is a link UP and LEFT ? what's this.
  2. Think so... Index: trunk/L2_Gameserver/java/net/sf/l2j/gameserver/datatables/MapRegionTable.java =================================================================== --- trunk/L2_Gameserver/java/net/sf/l2j/gameserver/datatables/MapRegionTable.java (revision 16) +++ trunk/L2_Gameserver/java/net/sf/l2j/gameserver/datatables/MapRegionTable.java (working copy) @@ -176,9 +176,9 @@ _pointsWithKarmas[16][1] = -138560; _pointsWithKarmas[16][2] = -2256; // Primeval Isle - //_pointsWithKarmas[18][0] = 10468; - //_pointsWithKarmas[18][1] = -24569; - //_pointsWithKarmas[18][2] = -3645; + _pointsWithKarmas[18][0] = 10468; + _pointsWithKarmas[18][1] = -24569; + _pointsWithKarmas[18][2] = -3645; } public final int getMapRegion(int posX, int posY)
  3. I got bored with the retard replies, it's not an " easy " code go make it by yourself if you think so. One more reply like IOzo's and shits like fail code will be punished with report to a moderator, and if i am allowed... karma smite.
  4. At the moment the site is down.. cause i cannot open it http://l2iplay.com/ .
  5. Non-registered clans cannot attack the walls the guards the players registered in the siege... This is so so cool feature for PvP Servers. ! THE BEST WILL WIN.
  6. Yes my wrong, and yet it's useless since it is not needed..
  7. You can define the player this way.. L2PcInstance player = (L2PcInstance) this;
  8. You remember right or L2PcInstance player= (L2PcInstance) this;
  9. You don't believe him ?... Regular member - Competition's winner today :P
  10. When someone wants to open a project he/she have to love Doctor house ? xD, Anyway i don't think you gonna achieve something with this.
  11. I am really happy for being awarded with the vip membership. I did my best and i hope you know that. Thanks.
  12. If a clan is not registered he cannot attack the registered clans or participants during the event...
  13. I will start from credits: L2Oneo This checks illegal skills on enter, useful especially on pvp servers you write the skills you allow on configs. Patch: Index: /trunk/Game/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java =================================================================== --- /trunk/Game/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (revision 153) +++ /trunk/Game/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (revision 178) @@ -315,4 +315,8 @@ TvTEvent.onLogin(activeChar); CrownManager.getInstance().checkCrowns(activeChar); + if (Config.CHECK_SKILLS_ON_ENTER && !Config.SKILL_LEARN) + { + activeChar.checkIlegalSkills(); + } } Index: /trunk/Game/java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java =================================================================== --- /trunk/Game/java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (revision 88) +++ /trunk/Game/java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (revision 178) @@ -71,5 +71,5 @@ { String[] commandStr = command.split(" "); - String actualCommand = commandStr[0]; // Get actual command + String actualCommand = commandStr[0]; String cmdParams = ""; @@ -256,4 +256,9 @@ content.append("Change Subclass:<br>Which of the following sub classes would you like to change?<br>"); int classIndex = 1; + + if (Config.CHECK_SKILLS_ON_ENTER && !Config.SKILL_LEARN) + { + player.checkIlegalSkills(); + } for (Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();) @@ -375,4 +380,9 @@ + CharTemplateTable.getClassNameById(player.getActiveClass()) + "</font>."); + if (Config.CHECK_SKILLS_ON_ENTER && !Config.SKILL_LEARN) + { + player.checkIlegalSkills(); + } + player.sendPacket(new SystemMessage(SystemMessageId.SUBCLASS_TRANSFER_COMPLETED)); // Transfer completed. break; @@ -410,4 +420,9 @@ player.sendPacket(new SystemMessage(SystemMessageId.ADD_NEW_SUBCLASS)); // Subclass added. + + if (Config.CHECK_SKILLS_ON_ENTER && !Config.SKILL_LEARN) + { + player.checkIlegalSkills(); + } } else Index: /trunk/Game/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- /trunk/Game/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 161) +++ /trunk/Game/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 178) @@ -10163,3 +10163,69 @@ return _currentSkillWorldPosition; } + + public void checkIlegalSkills() + { + boolean LegalSkill = false; + + if (!isGM()) + { + Collection<L2SkillLearn> skillTree = SkillTreeTable.getInstance().getAllowedSkills(getClassId()); + + for (L2Skill skill : getAllSkills()) + { + int skillid = skill.getId(); + + LegalSkill = false; + + for (L2SkillLearn temp : skillTree) + { + if (temp.getId() == skillid) + LegalSkill = true; + } + + if (isCursedWeaponEquiped() && skillid == CursedWeaponsManager.getInstance().getCursedWeapon(_cursedWeaponEquipedId).getSkillId()) + { + LegalSkill = true; + } + + if (getClan() != null && (skillid >= 370 && skillid <= 391)) + { + LegalSkill = true; + } + + if (getClan() != null && (skillid == 246 || skillid == 247)) + { + if (getClan().getLeaderId() == getObjectId()) + LegalSkill = true; + } + + if (skillid >= 1312 && skillid <= 1322) + { + LegalSkill = true; + } + + if (skillid >= 1368 && skillid <= 1373) + { + LegalSkill = true; + } + + if (skillid >= 3000 && skillid < 7000) + { + LegalSkill = true; + } + + if (Config.ALLOWED_SKILLS_LIST.contains(skillid)) + { + LegalSkill = true; + } + + if (!LegalSkill) + { + removeSkill(skill); + sendMessage("[sVR]: Ilegal skill detected: "+skill.getName()+"."); + sendMessage("[sVR]: The ilegal skill has been removed."); + } + } + } + } } Index: /trunk/Game/java/net/sf/l2j/Config.java =================================================================== --- /trunk/Game/java/net/sf/l2j/Config.java (revision 136) +++ /trunk/Game/java/net/sf/l2j/Config.java (revision 178) @@ -589,4 +589,7 @@ public static int CHAMPION_REWARD_ID; public static int CHAMPION_REWARD_QTY; + public static boolean CHECK_SKILLS_ON_ENTER; + public static String ALLOWED_SKILLS; + public static FastList<Integer> ALLOWED_SKILLS_LIST = new FastList<Integer>(); /** Events */ @@ -616,12 +619,12 @@ public static String GAME_VERSION; public static String BUILD_DATE; - + /** Data Version */ public static String DATA_VERSION; /** HexID */ - public static int SERVER_ID; - public static byte[] HEX_ID; - + public static int SERVER_ID; + public static byte[] HEX_ID; + /** Custom */ // Comming Soon ! @@ -1324,4 +1327,11 @@ CHAMPION_REWARD_ID = Integer.parseInt(Mods.getProperty("ChampionRewardItemID", "6393")); CHAMPION_REWARD_QTY = Integer.parseInt(Mods.getProperty("ChampionRewardItemQty", "1")); + CHECK_SKILLS_ON_ENTER = Boolean.parseBoolean(Mods.getProperty("CheckSkillsOnEnter", "False")); + ALLOWED_SKILLS = Mods.getProperty("AllowedSkills", "541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,617,618,619"); + ALLOWED_SKILLS_LIST = new FastList<Integer>(); + for (String id : ALLOWED_SKILLS.trim().split(",")) + { + ALLOWED_SKILLS_LIST.add(Integer.parseInt(id.trim())); + } } catch (Exception e) @@ -1493,6 +1503,6 @@ Custom.load(is); is.close(); - - // Comming Soon + + // Commgin Soon ! } catch (Exception e) I know shares that are not mine doesn't count a lot for the contest but someone might find it useful thanks thanks thanks.
  14. The worst pack ever ? all these fixes are shared here, and the cost of this pack is 2 euro because you added them... About oly a c/p is not so hard, i will rework it for il and i will share it here...
  15. Updated 24.04.2009 ! :) 1- [L2J Contest - Share] Siege only for registered clans by Cod3x 2- [L2J Contest - Share] Advanced auto-announce by Cod3x 3- [L2J Contest - Share] Partymatching implementation. by Cod3x 4- [L2J Contest - Share] Anti-Noob & Help the nabs system by Cod3x 5- [L2J Contest - Share] Triple TvT Event by Cod3x 6- [L2J Contest - Share] Raid Event - Interlude by Cod3x 7- [L2J Contest - Share] Illegal skills check by Cod3x
  16. Well, this is a patch will allow only the registered players or clans to fight in the siege, so noone else can come and fight. I made it for my server and also a friend helped me, I finished it today. Useful for PvP servers! Patch: Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java (revision 231) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java (revision 317) @@ -25,8 +25,13 @@ import net.sf.l2j.gameserver.ai.L2CharacterAI; import net.sf.l2j.gameserver.ai.L2SiegeGuardAI; +import net.sf.l2j.gameserver.datatables.ClanTable; +import net.sf.l2j.gameserver.instancemanager.SiegeManager; import net.sf.l2j.gameserver.model.L2Attackable; import net.sf.l2j.gameserver.model.L2CharPosition; import net.sf.l2j.gameserver.model.L2Character; +import net.sf.l2j.gameserver.model.L2Clan; +import net.sf.l2j.gameserver.model.L2SiegeClan; import net.sf.l2j.gameserver.model.actor.knownlist.SiegeGuardKnownList; +import net.sf.l2j.gameserver.model.entity.Siege; import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected; @@ -146,5 +151,34 @@ public void onAction(L2PcInstance player) { - if (!canTarget(player)) return; + if (!canTarget(player)) + return; + + boolean opp = false; + Siege siege = SiegeManager.getInstance().getSiege(player); + L2Clan oppClan = player.getClan(); + if (siege != null && siege.getIsInProgress() && oppClan != null) + { + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + if(!opp) + return; + } // Check if the L2PcInstance already target the L2NpcInstance Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java (revision 231) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java (revision 317) @@ -96,6 +96,9 @@ if (player == null || !canTarget(player)) return; + + if(!_player.siegeonlyRegistered(player)) + return; - // Check if the L2PcInstance already target the L2NpcInstance + // Check if the L2PcInstance already target the L2NpcInstance if (this != player.getTarget()) { Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 314) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 317) @@ -106,4 +106,5 @@ import net.sf.l2j.gameserver.model.L2Request; import net.sf.l2j.gameserver.model.L2ShortCut; +import net.sf.l2j.gameserver.model.L2SiegeClan; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.L2SkillLearn; @@ -3419,4 +3420,11 @@ if (!TvTEvent.onAction(player.getName(), getName())) { + player.sendPacket(ActionFailed.STATIC_PACKET); + return; + } + + if (!siegeonlyRegistered(player)) + { + player.sendMessage("Player interaction disabled during sieges."); player.sendPacket(ActionFailed.STATIC_PACKET); return; @@ -10947,3 +10955,60 @@ _isAway = state; } + + public boolean siegeonlyRegistered(L2PcInstance player) + { + Siege siege = SiegeManager.getInstance().getSiege(this); + if (siege != null && siege.getIsInProgress()) + { + L2Clan selfClan = getClan(); + L2Clan oppClan = player.getClan(); + if (selfClan != null && oppClan != null) + { + boolean self = false; + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == selfClan || cl.getAllyId() == getAllyId()) + { + self = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == selfClan || cl.getAllyId() == getAllyId()) + { + self = true; + break; + } + } + + boolean opp = false; + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + return self && opp; + } + return false; + } + return true; + } } Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java (revision 231) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java (revision 317) @@ -31,9 +31,13 @@ import net.sf.l2j.gameserver.ai.L2CharacterAI; import net.sf.l2j.gameserver.ai.L2DoorAI; +import net.sf.l2j.gameserver.datatables.ClanTable; import net.sf.l2j.gameserver.instancemanager.CastleManager; +import net.sf.l2j.gameserver.instancemanager.SiegeManager; import net.sf.l2j.gameserver.model.L2CharPosition; import net.sf.l2j.gameserver.model.L2Character; +import net.sf.l2j.gameserver.model.L2Clan; import net.sf.l2j.gameserver.model.L2ItemInstance; import net.sf.l2j.gameserver.model.L2Object; +import net.sf.l2j.gameserver.model.L2SiegeClan; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.actor.knownlist.DoorKnownList; @@ -42,4 +46,5 @@ import net.sf.l2j.gameserver.model.entity.Castle; import net.sf.l2j.gameserver.model.entity.ClanHall; +import net.sf.l2j.gameserver.model.entity.Siege; import net.sf.l2j.gameserver.network.L2GameClient; import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; @@ -368,4 +373,38 @@ if (player == null) return; + + boolean opp = false; + Siege siege = SiegeManager.getInstance().getSiege(player); + L2Clan oppClan = player.getClan(); + if (siege != null && siege.getIsInProgress()) + { + if (oppClan != null) + { + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + } + } + else + opp = true; + + if (!opp) + return; // Check if the L2PcInstance already target the L2NpcInstance
  17. It's not like the old one... here... http://www.l2jserver.com/old-forum/thread.php?threadid=33772&hilight=auto+announce
  18. o.O rly? http://www.maxcheaters.com/forum/index.php?topic=138079.0
  19. Simple, auto-announce anything you want, you can set the announcement from game //admin and then auto announce. I'ts by default auto-announce every 3 mins. Working on L2j interlude and ofcourse on any other chronicle with 1-2 or 3 changes... The patch is not so big that's why i'm posting it here. Index: /trunk/Interlude/java/config/command-privileges.properties =================================================================== @@ -62,4 +62,13 @@ admin_list_announcements = 75 admin_reload_announcements = 100 +# Auto Announcements +admin_list_autoannouncements = 100 +admin_add_autoannouncement = 100 +admin_del_autoannouncement = 100 +admin_autoannounce = 100 Index: /trunk/Interlude/java/net/sf/l2j/gameserver/handler/AutoAnnouncementHandler.java =================================================================== +package net.sf.l2j.gameserver.handler; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ScheduledFuture; + +import javolution.text.TextBuilder; +import javolution.util.FastMap; +import net.sf.l2j.L2DatabaseFactory; +import net.sf.l2j.gameserver.Announcements; +import net.sf.l2j.gameserver.ThreadPoolManager; +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; +import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage; + +public class AutoAnnouncementHandler +{ + private static AutoAnnouncementHandler _instance; + + private static final long DEFAULT_ANNOUNCEMENT_DELAY = 180000; // 3 mins by default + + protected Map<Integer, AutoAnnouncementInstance> _registeredAnnouncements; + + protected AutoAnnouncementHandler() + { + _registeredAnnouncements = new FastMap<Integer, AutoAnnouncementInstance>(); + restoreAnnouncementData(); + } + + private void restoreAnnouncementData() + { + int numLoaded = 0; + java.sql.Connection con = null; + PreparedStatement statement = null; + ResultSet rs = null; + + try + { + con = L2DatabaseFactory.getInstance().getConnection(); + + statement = con.prepareStatement("SELECT * FROM auto_announcements ORDER BY id"); + rs = statement.executeQuery(); + + while (rs.next()) + { + numLoaded++; + + registerGlobalAnnouncement(rs.getInt("id"), rs.getString("announcement"), rs.getLong("delay")); + + } + + statement.close(); + } + catch (Exception e) + { + } + finally + { + try + { + con.close(); + } + catch (Exception e) + { + } + } + } + + public void listAutoAnnouncements(L2PcInstance activeChar) + { + NpcHtmlMessage adminReply = new NpcHtmlMessage(5); + + TextBuilder replyMSG = new TextBuilder("<html><body>"); + replyMSG.append("<table width=260><tr>"); + replyMSG.append("<td width=40></td>"); + replyMSG.append("<button value=\"Main\" action=\"bypass -h admin_admin\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>"); + replyMSG.append("<td width=180><center>Auto Announcement Menu</center></td>"); + replyMSG.append("<td width=40></td>"); + replyMSG.append("</tr></table>"); + replyMSG.append("<br><br>"); + replyMSG.append("<center>Add new auto announcement:</center>"); + replyMSG.append("<center><multiedit var=\"new_autoannouncement\" width=240 height=30></center><br>"); + replyMSG.append("<br><br>"); + replyMSG.append("<center>Delay: <edit var=\"delay\" width=70></center>"); + replyMSG.append("<center>Note: Time in Seconds 60s = 1 min.</center>"); + replyMSG.append("<br><br>"); + replyMSG.append("<center><table><tr><td>"); + replyMSG.append("<button value=\"Add\" action=\"bypass -h admin_add_autoannouncement $delay $new_autoannouncement\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>"); + replyMSG.append("</td></tr></table></center>"); + replyMSG.append("<br>"); + + for (AutoAnnouncementInstance announcementInst : AutoAnnouncementHandler.getInstance().values()) + { + replyMSG.append("<table width=260><tr><td width=220>[" + announcementInst.getDefaultDelay() + "s] " + announcementInst.getDefaultTexts().toString() + "</td><td width=40>"); + replyMSG.append("<button value=\"Delete\" action=\"bypass -h admin_del_autoannouncement " + announcementInst.getDefaultId() + "\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>"); + } + + replyMSG.append("</body></html>"); + + adminReply.setHtml(replyMSG.toString()); + activeChar.sendPacket(adminReply); + } + + public static AutoAnnouncementHandler getInstance() + { + if (_instance == null) _instance = new AutoAnnouncementHandler(); + + return _instance; + } + + public int size() + { + return _registeredAnnouncements.size(); + } + + /** + * Registers a globally active autoannouncement. + * <BR> + * Returns the associated auto announcement instance. + * + * @param String announcementTexts + * @param int announcementDelay (-1 = default delay) + * @return AutoAnnouncementInstance announcementInst + */ + public AutoAnnouncementInstance registerGlobalAnnouncement(int id, String announcementTexts, long announcementDelay) + { + return registerAnnouncement(id, announcementTexts, announcementDelay); + } + + /** + * Registers a NON globally-active auto announcement + * <BR> + * Returns the associated auto chat instance. + * + * @param String announcementTexts + * @param int announcementDelay (-1 = default delay) + * @return AutoAnnouncementInstance announcementInst + */ + public AutoAnnouncementInstance registerAnnouncment(int id, String announcementTexts, long announcementDelay) + { + return registerAnnouncement(id, announcementTexts, announcementDelay); + } + + public AutoAnnouncementInstance registerAnnouncment(String announcementTexts, long announcementDelay) + { + int nextId = nextAutoAnnouncmentId(); + + java.sql.Connection con = null; + try + { + con = L2DatabaseFactory.getInstance().getConnection(); + PreparedStatement statement = con.prepareStatement("INSERT INTO auto_announcements (id,announcement,delay) " + "VALUES (?,?,?)"); + statement.setInt(1, nextId); + statement.setString(2, announcementTexts); + statement.setLong(3, announcementDelay); + + + statement.executeUpdate(); + + statement.close(); + } catch (Exception e) { + } finally { + try { con.close(); } catch (Exception e) {} + } + + return registerAnnouncement(nextId, announcementTexts, announcementDelay); + } + + public int nextAutoAnnouncmentId() + { + + int nextId = 0; + + java.sql.Connection con = null; + PreparedStatement statement = null; + ResultSet rs = null; + + try + { + con = L2DatabaseFactory.getInstance().getConnection(); + + statement = con.prepareStatement("SELECT id FROM auto_announcements ORDER BY id"); + rs = statement.executeQuery(); + + while (rs.next()) + { + if(rs.getInt("id") > nextId) + nextId = rs.getInt("id"); + } + + statement.close(); + + nextId++; + } + catch (Exception e) + { + } + finally + { + try + { + con.close(); + } + catch (Exception e) + { + } + } + + return nextId; + } + + private final AutoAnnouncementInstance registerAnnouncement(int id, String announcementTexts, long chatDelay) + { + AutoAnnouncementInstance announcementInst = null; + + if (chatDelay < 0) chatDelay = DEFAULT_ANNOUNCEMENT_DELAY; + + if (_registeredAnnouncements.containsKey(id)) announcementInst = _registeredAnnouncements.get(id); + else announcementInst = new AutoAnnouncementInstance(id, announcementTexts, chatDelay); + + _registeredAnnouncements.put(id, announcementInst); + + return announcementInst; + } + + public Collection<AutoAnnouncementInstance> values() + { + return _registeredAnnouncements.values(); + } + + /** + * Removes and cancels ALL auto announcement for the given announcement id. + * + * @param int Id + * @return boolean removedSuccessfully + */ + public boolean removeAnnouncement(int id) + { + AutoAnnouncementInstance announcementInst = _registeredAnnouncements.get(id); + + java.sql.Connection con = null; + try + { + con = L2DatabaseFactory.getInstance().getConnection(); + PreparedStatement statement = con.prepareStatement("DELETE FROM auto_announcements WHERE id=?"); + statement.setInt(1, announcementInst.getDefaultId()); + statement.executeUpdate(); + + statement.close(); + } catch (Exception e) { + } finally { + try { con.close(); } catch (Exception e) {} + } + + return removeAnnouncement(announcementInst); + } + + /** + * Removes and cancels ALL auto announcement for the given announcement instance. + * + * @param AutoAnnouncementInstance announcementInst + * @return boolean removedSuccessfully + */ + public boolean removeAnnouncement(AutoAnnouncementInstance announcementInst) + { + if (announcementInst == null) return false; + + _registeredAnnouncements.remove(announcementInst.getDefaultId()); + announcementInst.setActive(false); + + return true; + } + + /** + * Returns the associated auto announcement instance either by the given announcement ID + * or object ID. + * + * @param int id + * @return AutoAnnouncementInstance announcementInst + */ + public AutoAnnouncementInstance getAutoAnnouncementInstance(int id) + { + return _registeredAnnouncements.get(id); + } + + /** + * Sets the active state of all auto announcement instances to that specified, + * and cancels the scheduled chat task if necessary. + * + * @param boolean isActive + */ + public void setAutoAnnouncementActive(boolean isActive) + { + for (AutoAnnouncementInstance announcementInst : _registeredAnnouncements.values()) + announcementInst.setActive(isActive); + } + + /** + * Auto Announcement Instance + */ + public class AutoAnnouncementInstance + { + private long _defaultDelay = DEFAULT_ANNOUNCEMENT_DELAY; + private String _defaultTexts; + private boolean _defaultRandom = false; + private Integer _defaultId; + + private boolean _isActive; + + public ScheduledFuture<?> _chatTask; + + protected AutoAnnouncementInstance(int id, String announcementTexts, long announcementDelay) + { + _defaultId = id; + _defaultTexts = announcementTexts; + _defaultDelay = (announcementDelay * 1000); + + setActive(true); + } + + public boolean isActive() + { + return _isActive; + } + + public boolean isDefaultRandom() + { + return _defaultRandom; + } + + public long getDefaultDelay() + { + return _defaultDelay; + } + + public String getDefaultTexts() + { + return _defaultTexts; + } + + public Integer getDefaultId() + { + return _defaultId; + } + + public void setDefaultChatDelay(long delayValue) + { + _defaultDelay = delayValue; + } + + public void setDefaultChatTexts(String textsValue) + { + _defaultTexts = textsValue; + } + + public void setDefaultRandom(boolean randValue) + { + _defaultRandom = randValue; + } + + public void setActive(boolean activeValue) + { + if (_isActive == activeValue) return; + + _isActive = activeValue; + + + if (isActive()) + { + AutoAnnouncementRunner acr = new AutoAnnouncementRunner(_defaultId); + _chatTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(acr, + _defaultDelay, + _defaultDelay); + } + else + { + _chatTask.cancel(false); + } + } + + + /** + * Auto Announcement Runner + * <BR><BR> + * Represents the auto announcement scheduled task for each announcement instance. + * + * @author chief + */ + private class AutoAnnouncementRunner implements Runnable + { + protected int id; + + protected AutoAnnouncementRunner(int pId) + { + id = pId; + } + + public synchronized void run() + { + AutoAnnouncementInstance announcementInst = _registeredAnnouncements.get(id); + + String text; + + text = announcementInst.getDefaultTexts(); + + if (text == null) return; + + Announcements.getInstance().announceToAll(text); + } + } + } +} Index: /trunk/Interlude/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAutoAnnouncements.java =================================================================== +package net.sf.l2j.gameserver.handler.admincommandhandlers; + +import java.util.StringTokenizer; + +import net.sf.l2j.Config; +import net.sf.l2j.gameserver.handler.AutoAnnouncementHandler; +import net.sf.l2j.gameserver.handler.IAdminCommandHandler; +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; + +/** + * This class handles following admin commands: + * - announce text = announces text to all players + * - list_announcements = show menu + * - reload_announcements = reloads announcements from txt file + * - announce_announcements = announce all stored announcements to all players + * - add_announcement text = adds text to startup announcements + * - del_announcement id = deletes announcement with respective id + * + * @version $Revision: 1.4.4.5 $ $Date: 2005/04/11 10:06:06 $ + */ +public class AdminAutoAnnouncements implements IAdminCommandHandler { + + private static String[] ADMIN_COMMANDS = { + "admin_list_autoannouncements", + "admin_add_autoannouncement", + "admin_del_autoannouncement", + "admin_autoannounce" + }; + private static final int REQUIRED_LEVEL = Config.GM_ANNOUNCE; + + public boolean useAdminCommand(String command, L2PcInstance admin) { + if (!Config.ALT_PRIVILEGES_ADMIN) + if (!(checkLevel(admin.getAccessLevel()) && admin.isGM())) return false; + + if (command.equals("admin_list_autoannouncements")) + { + AutoAnnouncementHandler.getInstance().listAutoAnnouncements(admin); + } + else if (command.startsWith("admin_add_autoannouncement")) + { + //FIXME the player can send only 16 chars (if you try to send more it sends null), remove this function or not? + if (!command.equals("admin_add_autoannouncement")) + { + try{ + StringTokenizer st = new StringTokenizer(command.substring(27)); + int delay = Integer.parseInt(st.nextToken().trim()); + String autoAnnounce = st.nextToken(); + + if (delay > 30) + { + while (st.hasMoreTokens()) { + autoAnnounce = autoAnnounce + " " + st.nextToken(); + }; + + AutoAnnouncementHandler.getInstance().registerAnnouncment(autoAnnounce, delay); + AutoAnnouncementHandler.getInstance().listAutoAnnouncements(admin); + } + + } catch(StringIndexOutOfBoundsException e){}//ignore errors + } + } + else if (command.startsWith("admin_del_autoannouncement")) + { + try + { + int val = new Integer(command.substring(27)).intValue(); + AutoAnnouncementHandler.getInstance().removeAnnouncement(val); + AutoAnnouncementHandler.getInstance().listAutoAnnouncements(admin); + } + catch (StringIndexOutOfBoundsException e) + { } + } + + // Command is admin autoannounce + else if (command.startsWith("admin_autoannounce")) + { + // Call method from another class + AutoAnnouncementHandler.getInstance().listAutoAnnouncements(admin); + } + + return true; + } + + public String[] getAdminCommandList() { + return ADMIN_COMMANDS; + } + + private boolean checkLevel(int level) { + return (level >= REQUIRED_LEVEL); + } + +} Index: /trunk/Datapack/sql/autoanounce.sql =================================================================== @@ -0,0 +1,9 @@ +-- ---------------------------- +-- Table structure for auto_announcements +-- ---------------------------- +CREATE TABLE `auto_announcements` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `announcement` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '', + `delay` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; Index: /trunk/Datapack/tools/database_installer.bat =================================================================== +autoanounce.sql Index: /trunk/Datapack/data/html/admin/announce.htm =================================================================== @@ -11,4 +11,5 @@ <td><button value="Announce" action="bypass -h admin_announce_menu $new_announcement" width=60 height=15 back="sek.cbui94" fore="sek.cbui92"></td> <td><button value="Reload" action="bypass -h admin_announce_announcements" width=60 height=15 back="sek.cbui94" fore="sek.cbui92"></td> +<td><button value="Auto Announce" action="bypass -h admin_autoannounce $menu_command" width=55 height=15 back="sek.cbui94" fore="sek.cbui92"></td> </tr></table></center> %announces% Credits: L2j-Forum
  20. L2j haven't implemented it yet as i know..
  21. I don't have a problem, but i will soon share an updated version...
  22. think about it. My pc cannot open l2 because i lost my certifcates or something don't really know.
  23. Great idea.. I am working on it, i want more ideas. i will finish it and update my post thank you
  24. You haven't understood what i am talking about... As i know, we don't take karma for easy things...
×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock