Advertisement
Sarada-L2

diff correção carregamento XMLS

Jun 6th, 2021
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. diff --git a/java/Dev/Dungeon/DungeonManager.java b/java/Dev/Dungeon/DungeonManager.java
  2. index 7d251f4..f6b4a95 100644
  3. --- a/java/Dev/Dungeon/DungeonManager.java
  4. +++ b/java/Dev/Dungeon/DungeonManager.java
  5. @@ -32,6 +32,7 @@
  6. import net.sf.l2j.L2DatabaseFactory;
  7. import net.sf.l2j.gameserver.model.actor.Player;
  8. import net.sf.l2j.gameserver.model.location.Location;
  9. +import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;
  10.  
  11. import org.w3c.dom.Document;
  12. import org.w3c.dom.NamedNodeMap;
  13. @@ -103,7 +104,6 @@
  14. return true;
  15. }
  16.  
  17. - @SuppressWarnings("resource")
  18. private void load()
  19. {
  20. try
  21. diff --git a/java/Dev/Dungeon/XMLDocumentFactory.java b/java/Dev/Dungeon/XMLDocumentFactory.java
  22. deleted file mode 100644
  23. index 44c1a59..0000000
  24. --- a/java/Dev/Dungeon/XMLDocumentFactory.java
  25. +++ /dev/null
  26. @@ -1,72 +0,0 @@
  27. -package Dev.Dungeon;
  28. -
  29. -import java.io.File;
  30. -
  31. -import javax.xml.parsers.DocumentBuilder;
  32. -import javax.xml.parsers.DocumentBuilderFactory;
  33. -
  34. -import org.w3c.dom.Document;
  35. -
  36. -/**
  37. - * @author Forsaiken
  38. - */
  39. -public final class XMLDocumentFactory
  40. -{
  41. - public static final XMLDocumentFactory getInstance()
  42. - {
  43. - return SingletonHolder._instance;
  44. - }
  45. -
  46. - private final DocumentBuilder _builder;
  47. -
  48. - protected XMLDocumentFactory() throws Exception
  49. - {
  50. - try
  51. - {
  52. - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  53. - factory.setValidating(false);
  54. - factory.setIgnoringComments(true);
  55. -
  56. - _builder = factory.newDocumentBuilder();
  57. - }
  58. - catch (Exception e)
  59. - {
  60. - throw new Exception("Failed initializing", e);
  61. - }
  62. - }
  63. -
  64. - public final Document loadDocument(final String filePath) throws Exception
  65. - {
  66. - return loadDocument(new File(filePath));
  67. - }
  68. -
  69. - public final Document loadDocument(final File file) throws Exception
  70. - {
  71. - if (!file.exists() || !file.isFile())
  72. - throw new Exception("File: " + file.getAbsolutePath() + " doesn't exist and/or is not a file.");
  73. -
  74. - return _builder.parse(file);
  75. - }
  76. -
  77. - public final Document newDocument()
  78. - {
  79. - return _builder.newDocument();
  80. - }
  81. -
  82. - private static class SingletonHolder
  83. - {
  84. - protected static final XMLDocumentFactory _instance;
  85. -
  86. - static
  87. - {
  88. - try
  89. - {
  90. - _instance = new XMLDocumentFactory();
  91. - }
  92. - catch (Exception e)
  93. - {
  94. - throw new ExceptionInInitializerError(e);
  95. - }
  96. - }
  97. - }
  98. -}
  99. \ No newline at end of file
  100. diff --git a/java/com/rouxy/phantom/XMLDocument.java b/java/com/rouxy/phantom/XMLDocument.java
  101. deleted file mode 100644
  102. index 9e155e7..0000000
  103. --- a/java/com/rouxy/phantom/XMLDocument.java
  104. +++ /dev/null
  105. @@ -1,84 +0,0 @@
  106. -package com.rouxy.phantom;
  107. -
  108. -
  109. -
  110. -import java.io.File;
  111. -
  112. -import javax.xml.parsers.DocumentBuilderFactory;
  113. -
  114. -
  115. -
  116. -import net.sf.l2j.gameserver.templates.StatsSet;
  117. -
  118. -import org.w3c.dom.Document;
  119. -import org.w3c.dom.NamedNodeMap;
  120. -import org.w3c.dom.Node;
  121. -
  122. -/**
  123. - * An XML document, relying on a static and single {@link DocumentBuilderFactory}.
  124. - */
  125. -public abstract class XMLDocument
  126. -{
  127. - protected static final CLogger LOGGER = new CLogger(XMLDocument.class.getName());
  128. -
  129. - private static final DocumentBuilderFactory BUILDER;
  130. - static
  131. - {
  132. - BUILDER = DocumentBuilderFactory.newInstance();
  133. - BUILDER.setValidating(false);
  134. - BUILDER.setIgnoringComments(true);
  135. - }
  136. -
  137. - abstract protected void load();
  138. -
  139. - abstract protected void parseDocument(Document doc, File f);
  140. -
  141. - public void loadDocument(String filePath)
  142. - {
  143. - loadDocument(new File(filePath));
  144. - }
  145. -
  146. - /**
  147. - * Parse an entire directory or file if found.
  148. - * @param file
  149. - */
  150. - public void loadDocument(File file)
  151. - {
  152. - if (!file.exists())
  153. - {
  154. - LOGGER.error("The following file or directory doesn't exist: {}.", file.getName());
  155. - return;
  156. - }
  157. -
  158. - if (file.isDirectory())
  159. - {
  160. - for (File f : file.listFiles())
  161. - loadDocument(f);
  162. - }
  163. - else if (file.isFile())
  164. - {
  165. - try
  166. - {
  167. - parseDocument(BUILDER.newDocumentBuilder().parse(file), file);
  168. - }
  169. - catch (Exception e)
  170. - {
  171. - LOGGER.error("Error loading XML file '{}'.", e, file.getName());
  172. - }
  173. - }
  174. - }
  175. -
  176. - /**
  177. - * This method parses the content of a NamedNodeMap and feed the given StatsSet.
  178. - * @param attrs : The NamedNodeMap to parse.
  179. - * @param set : The StatsSet to feed.
  180. - */
  181. - public static void parseAndFeed(NamedNodeMap attrs, StatsSet set)
  182. - {
  183. - for (int i = 0; i < attrs.getLength(); i++)
  184. - {
  185. - final Node attr = attrs.item(i);
  186. - set.set(attr.getNodeName(), attr.getNodeValue());
  187. - }
  188. - }
  189. -}
  190.  
  191. diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
  192. index b9a1ef0..f0ac485 100644
  193. --- a/java/net/sf/l2j/gameserver/GameServer.java
  194. +++ b/java/net/sf/l2j/gameserver/GameServer.java
  195. @@ -175,9 +175,7 @@
  196. Config.loadGameServer();
  197.  
  198. // Factories
  199. - XMLDocumentFactory.getInstance();
  200. L2DatabaseFactory.getInstance();
  201. - IconTable.getInstance();
  202. StringUtil.printSection("ThreadPool");
  203. ThreadPool.init();
  204. StringUtil.printSection("IdFactory");
  205. @@ -207,6 +205,8 @@
  206. SoulCrystalData.getInstance();
  207. AugmentationData.getInstance();
  208. CursedWeaponsManager.getInstance();
  209. + XMLDocumentFactory.getInstance();
  210. + IconTable.getInstance();
  211.  
  212. StringUtil.printSection("Admins");
  213. AdminData.getInstance();
  214. \ No newline at end of file
  215.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement