FourthJobQuestsPortalHandler.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:3k
源码类别:

游戏

开发平台:

Java

  1. package net.sf.odinms.server.fourthjobquests;
  2. import java.util.Collection;
  3. import net.sf.odinms.client.MapleCharacter;
  4. import net.sf.odinms.client.MapleJob;
  5. import net.sf.odinms.client.messages.ServernoticeMapleClientMessageCallback;
  6. import net.sf.odinms.net.StringValueHolder;
  7. import net.sf.odinms.net.world.MapleParty;
  8. import net.sf.odinms.net.world.MaplePartyCharacter;
  9. import net.sf.odinms.tools.MaplePacketCreator;
  10. /**
  11.  *
  12.  * @author AngelSL
  13.  */
  14. public class FourthJobQuestsPortalHandler {
  15. public enum FourthJobQuests implements StringValueHolder {
  16. RUSH("s4rush"),
  17. BERSERK("s4berserk");
  18. private final String name;
  19. private FourthJobQuests(String Newname) {
  20. this.name = Newname;
  21. }
  22. @Override
  23. public String getValue() {
  24. return name;
  25. }
  26. }
  27. private FourthJobQuestsPortalHandler() {
  28. }
  29. //c.getClient().getSession().write(MaplePacketCreator.enableActions());
  30. public static boolean handlePortal(String name, MapleCharacter c) {
  31. ServernoticeMapleClientMessageCallback snmcmc = new ServernoticeMapleClientMessageCallback(5,c.getClient());
  32. if (name.equals(FourthJobQuests.RUSH.getValue())) {
  33. if (!checkPartyLeader(c) && !checkRush(c)) {
  34. snmcmc.dropMessage("You step into the portal, but it swiftly kicks you out.");
  35. c.getClient().getSession().write(MaplePacketCreator.enableActions());
  36. }
  37. if (!checkPartyLeader(c) && checkRush(c)) {
  38. snmcmc.dropMessage("You're not the party leader.");
  39. c.getClient().getSession().write(MaplePacketCreator.enableActions());
  40. return true;
  41. }
  42. if (!checkRush(c)) {
  43. snmcmc.dropMessage("Someone in your party is not a 4th Job warrior.");
  44. c.getClient().getSession().write(MaplePacketCreator.enableActions());
  45. return true;
  46. }
  47. c.getClient().getChannelServer().getEventSM().getEventManager("4jrush").startInstance(c.getParty(), c.getMap());
  48. return true;
  49. } else if (name.equals(FourthJobQuests.BERSERK.getValue())) {
  50. if (!checkBerserk(c)) {
  51. snmcmc.dropMessage("The portal to the Forgotten Shrine is locked");
  52. c.getClient().getSession().write(MaplePacketCreator.enableActions());
  53. return true;
  54. }
  55. c.getClient().getChannelServer().getEventSM().getEventManager("4jberserk").startInstance(c.getParty(), c.getMap());
  56. return true;
  57. }
  58. return false;
  59. }
  60. private static boolean checkRush(MapleCharacter c) {
  61. MapleParty CsParty = c.getParty();
  62. Collection<MaplePartyCharacter> CsPartyMembers = CsParty.getMembers();
  63. for (MaplePartyCharacter mpc : CsPartyMembers) {
  64. if (!MapleJob.getById(mpc.getJobId()).isA(MapleJob.WARRIOR)) return false;
  65. if (!(MapleJob.getById(mpc.getJobId()).isA(MapleJob.HERO) || MapleJob.getById(mpc.getJobId()).isA(MapleJob.PALADIN) || MapleJob.getById(mpc.getJobId()).isA(MapleJob.DARKKNIGHT)))
  66. return false;
  67. }
  68. return true;
  69. }
  70. private static boolean checkPartyLeader(MapleCharacter c) {
  71. return c.getParty().getLeader().getId() == c.getId();
  72. }
  73. private static boolean checkBerserk(MapleCharacter c) {
  74. return c.haveItem(4031475, 1, false, true);
  75. }
  76. }