Guest User

Greeting Data L2j

a guest
Jun 4th, 2025
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. package net.sf.l2j.gameserver.enums;
  2.  
  3. public enum ZoneType
  4. {
  5. TOWN,
  6. CASTLE
  7. }
  8.  
  9.  
  10. package net.sf.l2j.gameserver.model.holder;
  11.  
  12. import net.sf.l2j.commons.data.StatSet;
  13. import net.sf.l2j.gameserver.enums.ZoneType;
  14.  
  15.  
  16. public class GreetingHolder
  17. {
  18. private final int _castleId;
  19. private final ZoneType _zoneType;
  20. private final int _actionUse;
  21. private final String _mgs;
  22. private final int _time;
  23.  
  24. public GreetingHolder(StatSet set)
  25. {
  26. _castleId = set.getInteger("castleId");
  27. _zoneType = Enum.valueOf(ZoneType.class, set.getString("zone"));
  28. _actionUse = set.getInteger("actionId", 7);
  29. _mgs = set.getString("msg", "");
  30. _time = set.getInteger("time", 30);
  31. }
  32.  
  33. public int getCastleId()
  34. {
  35. return _castleId;
  36. }
  37.  
  38. public ZoneType getZoneType()
  39. {
  40. return _zoneType;
  41. }
  42.  
  43. public int getActionUse()
  44. {
  45. return _actionUse;
  46. }
  47.  
  48. public String getMessage()
  49. {
  50. return _mgs;
  51. }
  52.  
  53. public int getTime()
  54. {
  55. return _time;
  56. }
  57. }
  58.  
  59.  
  60. package net.sf.l2j.gameserver.data.xml;
  61.  
  62. import java.nio.file.Path;
  63. import java.util.HashMap;
  64. import java.util.Map;
  65.  
  66. import net.sf.l2j.commons.data.StatSet;
  67. import net.sf.l2j.commons.data.xml.IXmlReader;
  68. import net.sf.l2j.gameserver.model.holder.GreetingHolder;
  69. import net.sf.l2j.gameserver.taskmanager.GreetingManager;
  70.  
  71. import org.w3c.dom.Document;
  72.  
  73. public class GreetingData implements IXmlReader
  74. {
  75. private final Map<Integer, GreetingHolder> _greetings = new HashMap<>();
  76.  
  77. public GreetingData()
  78. {
  79. load();
  80. }
  81.  
  82. @Override
  83. public void load()
  84. {
  85. parseFile("./data/xml/greeting.xml");
  86. LOGGER.info(getClass().getSimpleName() + ": Loaded " + _greetings.size() + " greetings.");
  87. GreetingManager.start();
  88. }
  89.  
  90. @Override
  91. public void parseDocument(Document doc, Path path)
  92. {
  93. forEach(doc, "list", listNode -> {
  94. forEach(listNode, "greeting", greetNode -> {
  95. StatSet set = new StatSet(parseAttributes(greetNode));
  96. GreetingHolder holder = new GreetingHolder(set);
  97. _greetings.put(holder.getCastleId(), holder);
  98. });
  99. });
  100. }
  101.  
  102. public GreetingHolder getGreeting(int castleId)
  103. {
  104. return _greetings.get(castleId);
  105. }
  106.  
  107. public static GreetingData getInstance()
  108. {
  109. return SingletonHolder._instance;
  110. }
  111.  
  112. private static class SingletonHolder
  113. {
  114. protected static final GreetingData _instance = new GreetingData();
  115. }
  116. }
  117.  
  118. GameServer.java
  119. StringUtil.printSection("Greeting Data");
  120. GreetingData.getInstance();
  121.  
  122. StringUtil.printSection("Handlers");
  123. LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size());
  124.  
  125.  
  126.  
  127.  
  128. data/xml
  129.  
  130. <?xml version="1.0" encoding="UTF-8"?>
  131. <!--
  132. Configuração do sistema de Saudação Real (Reverência ao Líder de Castelo)
  133.  
  134. Este sistema ativa uma mecânica visual e de respeito dentro das vilas, similar ao Lineage II Classic Kamael.
  135. Quando o líder do clã que possui um castelo estiver presente na vila correspondente, jogadores próximos
  136. automaticamente fazem uma reverência (social ID definido) e recebem uma mensagem de saudação na tela.
  137.  
  138. A saudação só ocorre novamente após o tempo configurado no atributo "time".
  139.  
  140. /////////////////////////////////////////////
  141. TAGS DISPONÍVEIS:
  142. - <greeting> : Define uma configuração de saudação para um castelo específico.
  143. ////////////////////////////////////////////
  144.  
  145. ATRIBUTOS DE <greeting>:
  146.  
  147. • castleId (int)
  148. - ID do castelo.
  149. - Use os IDs conforme definidos no seu servidor (Ex: 1 = Gludio, 2 = Dion, etc).
  150.  
  151. • zone (string)
  152. - Tipo da zona onde a saudação pode ocorrer.
  153. - Use: "TOWN" para dentro da vila. (Outros tipos podem ser adicionados futuramente.)
  154.  
  155. • actionId (int)
  156. - ID da animação social usada.
  157. - Ex: 7 = /socialbow (reverência). Consulte SocialAction.java para outros IDs.
  158.  
  159. • msg (string)
  160. - Mensagem exibida ao jogador no centro da tela (e também via chat).
  161. - Ex: "Salve o Rei de Aden!"
  162.  
  163. • time (int)
  164. - Intervalo mínimo de tempo (em segundos) entre cada saudação por castelo.
  165. - Ex: 60 = saudação pode ocorrer a cada 60 segundos (1 minuto).
  166. -->
  167.  
  168. <list>
  169. <greeting castleId="1" zone="TOWN" actionId="7" msg="Salve o Rei de Gludio!" time="60" />
  170. <greeting castleId="2" zone="TOWN" actionId="7" msg="Honrem o Senhor de Dion!" time="60" />
  171. </list>
  172.  
  173.  
Advertisement
Add Comment
Please, Sign In to add comment