EventAnnouncement.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model.announce;
  20. import java.util.Date;
  21. import com.l2jserver.gameserver.idfactory.IdFactory;
  22. import com.l2jserver.gameserver.script.DateRange;
  23. /**
  24. * @author UnAfraid
  25. */
  26. public class EventAnnouncement implements IAnnouncement
  27. {
  28. private final int _id;
  29. private final DateRange _range;
  30. private String _content;
  31. public EventAnnouncement(DateRange range, String content)
  32. {
  33. _id = IdFactory.getInstance().getNextId();
  34. _range = range;
  35. _content = content;
  36. }
  37. @Override
  38. public int getId()
  39. {
  40. return _id;
  41. }
  42. @Override
  43. public AnnouncementType getType()
  44. {
  45. return AnnouncementType.EVENT;
  46. }
  47. @Override
  48. public void setType(AnnouncementType type)
  49. {
  50. throw new UnsupportedOperationException();
  51. }
  52. @Override
  53. public boolean isValid()
  54. {
  55. return _range.isWithinRange(new Date());
  56. }
  57. @Override
  58. public String getContent()
  59. {
  60. return _content;
  61. }
  62. @Override
  63. public void setContent(String content)
  64. {
  65. _content = content;
  66. }
  67. @Override
  68. public String getAuthor()
  69. {
  70. return "N/A";
  71. }
  72. @Override
  73. public void setAuthor(String author)
  74. {
  75. throw new UnsupportedOperationException();
  76. }
  77. @Override
  78. public boolean deleteMe()
  79. {
  80. IdFactory.getInstance().releaseId(_id);
  81. return true;
  82. }
  83. @Override
  84. public boolean storeMe()
  85. {
  86. return true;
  87. }
  88. @Override
  89. public boolean updateMe()
  90. {
  91. throw new UnsupportedOperationException();
  92. }
  93. }