From e1ff987278cba60c323a8e66992a884e6bf779f2 Mon Sep 17 00:00:00 2001 From: Rogiel Date: Sat, 21 Jan 2012 00:24:46 -0200 Subject: [PATCH] Fixes an issue when loading the server using a zipped data folder --- .../com/l2jserver/service/ServiceManager.java | 19 ++-- .../configuration/ConfigurationService.java | 3 + .../java/com/l2jserver/util/ArrayUtils.java | 6 ++ .../java/com/l2jserver/util/ClassUtils.java | 3 + .../impl/ArrayTransformerTest.java | 95 ------------------- .../main/generated/META-INF/sun-jaxb.episode | 50 +++++----- .../model/template/AbstractTemplate.java | 2 +- .../model/template/ActorTemplate.java | 2 +- .../model/template/CalculatorFunction.java | 2 +- .../template/CalculatorFunctionOperation.java | 2 +- .../model/template/CharacterTemplate.java | 2 +- .../l2jserver/model/template/Coordinate.java | 2 +- .../model/template/ItemTemplate.java | 2 +- .../l2jserver/model/template/NPCTemplate.java | 2 +- .../model/template/ObjectFactory.java | 2 +- .../model/template/SkillTemplate.java | 2 +- .../l2jserver/model/template/Teleports.java | 2 +- .../l2jserver/model/template/ZoneType.java | 2 +- .../com/l2jserver/model/template/Zones.java | 2 +- .../game/net/packet/server/SM_NPC_INFO.java | 42 +++++--- .../game/template/XMLTemplateService.java | 25 ++++- 21 files changed, 110 insertions(+), 159 deletions(-) delete mode 100644 l2jserver2-common/src/test/java/com/l2jserver/util/transformer/impl/ArrayTransformerTest.java diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java b/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java index ca9e13c55..0e2d37a91 100644 --- a/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java +++ b/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java @@ -130,15 +130,15 @@ public class ServiceManager { */ public void init(Injector injector) throws ServiceStartException { this.injector = injector; -// final LoggingService service = injector -// .getInstance(LoggingService.class); -// knownServices.add(service); -// service.start(); + // final LoggingService service = injector + // .getInstance(LoggingService.class); + // knownServices.add(service); + // service.start(); configurationService = start(ConfigurationService.class); - //start(LoggingService.class); - //knownServices.add(configurationService); - //start(ConfigurationService.class); - //configurationService.start(); + // start(LoggingService.class); + // knownServices.add(configurationService); + // start(ConfigurationService.class); + // configurationService.start(); } /** @@ -157,6 +157,9 @@ public class ServiceManager { * implementation of serviceClass, null is * returned. * + * @param + * the service type + * * @param serviceClass * the service class * @return the {@link ServiceDescriptor} for the requested service diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java b/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java index 5e1427e99..085711e2a 100644 --- a/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java +++ b/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java @@ -31,6 +31,9 @@ public interface ConfigurationService extends Service { /** * Get the configuration for the given service * + * @param + * the service configuration instance type + * * @param service * the service * @param serviceInterface diff --git a/l2jserver2-common/src/main/java/com/l2jserver/util/ArrayUtils.java b/l2jserver2-common/src/main/java/com/l2jserver/util/ArrayUtils.java index 66b2c4283..2f3b89944 100644 --- a/l2jserver2-common/src/main/java/com/l2jserver/util/ArrayUtils.java +++ b/l2jserver2-common/src/main/java/com/l2jserver/util/ArrayUtils.java @@ -30,6 +30,9 @@ public class ArrayUtils { /** * Copy an entire array except objects in except array. * + * @param + * the array component type + * * @param array * the source array * @param except @@ -58,6 +61,9 @@ public class ArrayUtils { * Searches for the expected item to be in the * array. * + * @param + * the array component type + * * @param array * the array to search in * @param expected diff --git a/l2jserver2-common/src/main/java/com/l2jserver/util/ClassUtils.java b/l2jserver2-common/src/main/java/com/l2jserver/util/ClassUtils.java index f1e495cc4..fbb5b015a 100644 --- a/l2jserver2-common/src/main/java/com/l2jserver/util/ClassUtils.java +++ b/l2jserver2-common/src/main/java/com/l2jserver/util/ClassUtils.java @@ -73,6 +73,9 @@ public class ClassUtils { * If after all those steps, no annotation is found, null is * returned. * + * @param + * the annotation type + * * @param annotationClass * the annotation class * @param cls diff --git a/l2jserver2-common/src/test/java/com/l2jserver/util/transformer/impl/ArrayTransformerTest.java b/l2jserver2-common/src/test/java/com/l2jserver/util/transformer/impl/ArrayTransformerTest.java deleted file mode 100644 index 93ff70e69..000000000 --- a/l2jserver2-common/src/test/java/com/l2jserver/util/transformer/impl/ArrayTransformerTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of l2jserver2 . - * - * l2jserver2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * l2jserver2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with l2jserver2. If not, see . - */ -package com.l2jserver.util.transformer.impl; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Rogiel - * - */ -public class ArrayTransformerTest { - /** - * An Integer[] array as an string - */ - private static final String INT_ARRAY_STRING = "1|2|3"; - /** - * An Integer[] array - */ - private static final Integer[] INT_ARRAY = new Integer[] { 1, 2, 3 }; - - /** - * An String[] array as an string - */ - private static final String STRING_ARRAY_STRING = "test1|test2|test3"; - /** - * An String[] array - */ - private static final String[] STRING_ARRAY = new String[] { "test1", - "test2", "test3" }; - - /** - * An Class[] array as an string - */ - private static final String CLASS_ARRAY_STRING = "java.lang.Object|java.lang.Integer|java.lang.Long"; - /** - * An Class[] array - */ - private static final Class[] CLASS_ARRAY = new Class[] { - Object.class, Integer.class, Long.class }; - - /** - * Tests transforming an {@link Integer} array - */ - @Test - public void testIntegerTransforming() { - final ArrayTransformer transformer = new ArrayTransformer(); - Assert.assertEquals(INT_ARRAY_STRING, - transformer.transform(Integer[].class, INT_ARRAY)); - Assert.assertArrayEquals(INT_ARRAY, - transformer.untransform(Integer[].class, INT_ARRAY_STRING)); - } - - /** - * Tests transforming an {@link String} array - */ - @Test - public void testStringTransforming() { - final ArrayTransformer transformer = new ArrayTransformer(); - Assert.assertEquals(STRING_ARRAY_STRING, - transformer.transform(String[].class, STRING_ARRAY)); - Assert.assertArrayEquals(STRING_ARRAY, - transformer.untransform(String[].class, STRING_ARRAY_STRING)); - } - - /** - * Tests transforming an {@link Class} array - */ - @Test - @SuppressWarnings("unchecked") - public void testClassTransforming() { - @SuppressWarnings("rawtypes") - final ArrayTransformer transformer = new ArrayTransformer(); - Assert.assertEquals(CLASS_ARRAY_STRING, transformer.transform( - Class[].class, CLASS_ARRAY)); - Assert.assertArrayEquals(CLASS_ARRAY, transformer - .untransform((Class[]>) Class[].class, - CLASS_ARRAY_STRING)); - } - -} diff --git a/l2jserver2-gameserver/src/main/generated/META-INF/sun-jaxb.episode b/l2jserver2-gameserver/src/main/generated/META-INF/sun-jaxb.episode index ccd44de1e..dcd7b06c0 100644 --- a/l2jserver2-gameserver/src/main/generated/META-INF/sun-jaxb.episode +++ b/l2jserver2-gameserver/src/main/generated/META-INF/sun-jaxb.episode @@ -5,21 +5,21 @@ This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 See http://java.sun.com/xml/jaxb Any modifications to this file will be lost upon recompilation of the source schema. -Generated on: 2011.12.31 at 03:24:00 AM BRST +Generated on: 2012.01.19 at 03:37:11 PM BRST --> - - - - - - + + + + + + @@ -38,6 +38,24 @@ Generated on: 2011.12.31 at 03:24:00 AM BRST + + + + + + + + + + + + + + + + + + @@ -47,23 +65,5 @@ Generated on: 2011.12.31 at 03:24:00 AM BRST - - - - - - - - - - - - - - - - - - diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/AbstractTemplate.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/AbstractTemplate.java index a67efaa9b..479214f8f 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/AbstractTemplate.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/AbstractTemplate.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ActorTemplate.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ActorTemplate.java index 3a8b94aac..560a28705 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ActorTemplate.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ActorTemplate.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunction.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunction.java index 61e4f6a95..a6275ac77 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunction.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunction.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunctionOperation.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunctionOperation.java index 3df8a6bd7..63d81b5bb 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunctionOperation.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CalculatorFunctionOperation.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CharacterTemplate.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CharacterTemplate.java index 06d8ca9de..4322389ea 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CharacterTemplate.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/CharacterTemplate.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Coordinate.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Coordinate.java index 7ab04eed8..181e2511e 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Coordinate.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Coordinate.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ItemTemplate.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ItemTemplate.java index 507d9f579..0e244c9a3 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ItemTemplate.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ItemTemplate.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/NPCTemplate.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/NPCTemplate.java index 8300fa70a..00d34a813 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/NPCTemplate.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/NPCTemplate.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ObjectFactory.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ObjectFactory.java index 46b3619a6..39ffc9bc9 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ObjectFactory.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ObjectFactory.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/SkillTemplate.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/SkillTemplate.java index 12e8cde04..a82dd025a 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/SkillTemplate.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/SkillTemplate.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Teleports.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Teleports.java index 7b04677ae..137040f20 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Teleports.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Teleports.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ZoneType.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ZoneType.java index 2ce368f0e..3affba6f9 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ZoneType.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/ZoneType.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Zones.java b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Zones.java index d6be6b694..6127895da 100644 --- a/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Zones.java +++ b/l2jserver2-gameserver/src/main/generated/com/l2jserver/model/template/Zones.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.12.31 at 03:24:00 AM BRST +// Generated on: 2012.01.19 at 03:37:11 PM BRST // diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_NPC_INFO.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_NPC_INFO.java index 6f5c0ab72..13f29c4c9 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_NPC_INFO.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/game/net/packet/server/SM_NPC_INFO.java @@ -54,7 +54,7 @@ public class SM_NPC_INFO extends AbstractServerPacket { buffer.writeInt(npc.getID().getID()); buffer.writeInt(template.getID().getID() + 1000000); // npctype - // id + // id // buffer.writeInt((template.isAttackable() ? 0x01 : 0x00)); // // attackable // FIXME unhard code it @@ -78,20 +78,32 @@ public class SM_NPC_INFO extends AbstractServerPacket { buffer.writeDouble(0x01);// TODO buffer.writeDouble(template.getInfo().getCollision().getRadius()); buffer.writeDouble(template.getInfo().getCollision().getHeigth()); - buffer.writeInt((template.getInfo().getItem().getRightHand() != null ? template - .getInfo().getItem().getRightHand().getID() - : 0x00)); + if (template.getInfo().getItem() != null) { + buffer.writeInt((template.getInfo().getItem().getRightHand() != null ? template + .getInfo().getItem().getRightHand().getID() + : 0x00)); + } else { + buffer.writeInt(0x00); + } buffer.writeInt(0x00); // chest - buffer.writeInt((template.getInfo().getItem().getLeftHand() != null ? template - .getInfo().getItem().getLeftHand().getID() - : 0x00)); + if (template.getInfo().getItem() != null) { + buffer.writeInt((template.getInfo().getItem().getLeftHand() != null ? template + .getInfo().getItem().getLeftHand().getID() + : 0x00)); + } else { + buffer.writeInt(0x00); + } buffer.writeByte(1); // name above char 1=true ... ?? buffer.writeByte(0x00); // is running buffer.writeByte((npc.isAttacking() ? 0x01 : 0x00)); // is in combat buffer.writeByte((npc.isDead() ? 0x01 : 0x00)); // is like dead (faking) buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned - BufferUtils.writeString(buffer, template.getInfo().getName().getValue()); - BufferUtils.writeString(buffer, template.getInfo().getTitle().getValue()); + BufferUtils.writeString(buffer, + (template.getInfo().getName() != null ? template.getInfo() + .getName().getValue() : null)); + BufferUtils.writeString(buffer, + (template.getInfo().getTitle() != null ? template.getInfo() + .getTitle().getValue() : null)); buffer.writeInt(0x00); // Title color 0=client default buffer.writeInt(0x00); // pvp flag buffer.writeInt(0x00); // karma @@ -110,11 +122,13 @@ public class SM_NPC_INFO extends AbstractServerPacket { buffer.writeInt(0x00); // C6 -- is flying buffer.writeInt(0x00); // unk buffer.writeInt(0x00);// CT1.5 Pet form and skills, Color effect - buffer.writeByte((template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide - // name - buffer.writeByte((template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide - // name, - // again + buffer.writeByte((template.getInfo().getName() != null + && template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide + // name + buffer.writeByte((template.getInfo().getName() != null + && template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide + // name, + // again buffer.writeInt(0x00); // special effects buffer.writeInt(0x00); // display effect diff --git a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java index 389c5c097..63c37fa28 100644 --- a/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java +++ b/l2jserver2-gameserver/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java @@ -16,12 +16,14 @@ */ package com.l2jserver.service.game.template; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardOpenOption; import java.nio.file.attribute.BasicFileAttributes; import java.util.List; @@ -181,6 +183,22 @@ public class XMLTemplateService extends log.info("Scanning {} for XML templates", templatePath); final List schemas = CollectionFactory.newList(); + + schemas.add(new StreamSource(new ByteArrayInputStream(Files + .readAllBytes(templatePath.resolve("l2jserver2.xsd"))))); + schemas.add(new StreamSource(new ByteArrayInputStream(Files + .readAllBytes(templatePath.resolve("item.xsd"))))); + schemas.add(new StreamSource(new ByteArrayInputStream(Files + .readAllBytes(templatePath.resolve("skill.xsd"))))); + schemas.add(new StreamSource(new ByteArrayInputStream(Files + .readAllBytes(templatePath.resolve("character.xsd"))))); + schemas.add(new StreamSource(new ByteArrayInputStream(Files + .readAllBytes(templatePath.resolve("npc.xsd"))))); + schemas.add(new StreamSource(new ByteArrayInputStream(Files + .readAllBytes(templatePath.resolve("teleport.xsd"))))); + schemas.add(new StreamSource(new ByteArrayInputStream(Files + .readAllBytes(templatePath.resolve("zones.xsd"))))); + final List templateList = CollectionFactory.newList(); final boolean includeSchemas = config.isSchemaValidationEnabled(); Files.walkFileTree(templatePath, new SimpleFileVisitor() { @@ -188,9 +206,7 @@ public class XMLTemplateService extends public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { final String name = file.getFileName().toString(); - if (name.endsWith(".xsd") && includeSchemas) { - schemas.add(new StreamSource(file.toFile())); - } else if (name.endsWith(".xml")) { + if (name.endsWith(".xml")) { if (name.endsWith("zones.xml")) return FileVisitResult.CONTINUE; templateList.add(file); @@ -245,7 +261,8 @@ public class XMLTemplateService extends public void loadTemplate(Path path) throws JAXBException, IOException { Preconditions.checkNotNull(path, "path"); log.debug("Loading template {}", path); - final InputStream in = Files.newInputStream(path); + final InputStream in = Files.newInputStream(path, + StandardOpenOption.READ); try { Object obj = unmarshaller.unmarshal(in); if (obj instanceof Template) {