1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Fixes an issue when loading the server using a zipped data folder

This commit is contained in:
2012-01-21 00:24:46 -02:00
parent beea690568
commit e1ff987278
21 changed files with 110 additions and 159 deletions

View File

@@ -130,15 +130,15 @@ public class ServiceManager {
*/ */
public void init(Injector injector) throws ServiceStartException { public void init(Injector injector) throws ServiceStartException {
this.injector = injector; this.injector = injector;
// final LoggingService service = injector // final LoggingService service = injector
// .getInstance(LoggingService.class); // .getInstance(LoggingService.class);
// knownServices.add(service); // knownServices.add(service);
// service.start(); // service.start();
configurationService = start(ConfigurationService.class); configurationService = start(ConfigurationService.class);
//start(LoggingService.class); // start(LoggingService.class);
//knownServices.add(configurationService); // knownServices.add(configurationService);
//start(ConfigurationService.class); // start(ConfigurationService.class);
//configurationService.start(); // configurationService.start();
} }
/** /**
@@ -157,6 +157,9 @@ public class ServiceManager {
* implementation of <code>serviceClass</code>, <code>null</code> is * implementation of <code>serviceClass</code>, <code>null</code> is
* returned. * returned.
* *
* @param <T>
* the service type
*
* @param serviceClass * @param serviceClass
* the service class * the service class
* @return the {@link ServiceDescriptor} for the requested service * @return the {@link ServiceDescriptor} for the requested service

View File

@@ -31,6 +31,9 @@ public interface ConfigurationService extends Service {
/** /**
* Get the configuration for the given service * Get the configuration for the given service
* *
* @param <C>
* the service configuration instance type
*
* @param service * @param service
* the service * the service
* @param serviceInterface * @param serviceInterface

View File

@@ -30,6 +30,9 @@ public class ArrayUtils {
/** /**
* Copy an entire array except objects in <code>except</code> array. * Copy an entire array except objects in <code>except</code> array.
* *
* @param <T>
* the array component type
*
* @param array * @param array
* the source array * the source array
* @param except * @param except
@@ -58,6 +61,9 @@ public class ArrayUtils {
* Searches for the <code>expected</code> item to be in the * Searches for the <code>expected</code> item to be in the
* <code>array</code>. * <code>array</code>.
* *
* @param <T>
* the array component type
*
* @param array * @param array
* the array to search in * the array to search in
* @param expected * @param expected

View File

@@ -73,6 +73,9 @@ public class ClassUtils {
* If after all those steps, no annotation is found, <code>null</code> is * If after all those steps, no annotation is found, <code>null</code> is
* returned. * returned.
* *
* @param <T>
* the annotation type
*
* @param annotationClass * @param annotationClass
* the annotation class * the annotation class
* @param cls * @param cls

View File

@@ -1,95 +0,0 @@
/*
* This file is part of l2jserver2 <l2jserver2.com>.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.util.transformer.impl;
import org.junit.Assert;
import org.junit.Test;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
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<Integer> transformer = new ArrayTransformer<Integer>();
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<String> transformer = new ArrayTransformer<String>();
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<Class> transformer = new ArrayTransformer<Class>();
Assert.assertEquals(CLASS_ARRAY_STRING, transformer.transform(
Class[].class, CLASS_ARRAY));
Assert.assertArrayEquals(CLASS_ARRAY, transformer
.untransform((Class<? extends Class<?>[]>) Class[].class,
CLASS_ARRAY_STRING));
}
}

View File

@@ -5,21 +5,21 @@
This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
Any modifications to this file will be lost upon recompilation of the source schema. 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
--> -->
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/character">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:character">
<jaxb:class ref="com.l2jserver.model.template.CharacterTemplate"/>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/skill"> <jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/skill">
<jaxb:schemaBindings map="false"/> <jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:skill"> <jaxb:bindings scd="tns:skill">
<jaxb:class ref="com.l2jserver.model.template.SkillTemplate"/> <jaxb:class ref="com.l2jserver.model.template.SkillTemplate"/>
</jaxb:bindings> </jaxb:bindings>
</jaxb:bindings> </jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/character">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:character">
<jaxb:class ref="com.l2jserver.model.template.CharacterTemplate"/>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::"> <jaxb:bindings scd="x-schema::">
<jaxb:schemaBindings map="false"/> <jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="~CalculatorFunction"> <jaxb:bindings scd="~CalculatorFunction">
@@ -38,6 +38,24 @@ Generated on: 2011.12.31 at 03:24:00 AM BRST
<jaxb:class ref="com.l2jserver.model.template.CalculatorFunctionOperation"/> <jaxb:class ref="com.l2jserver.model.template.CalculatorFunctionOperation"/>
</jaxb:bindings> </jaxb:bindings>
</jaxb:bindings> </jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/teleport">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:teleports">
<jaxb:class ref="com.l2jserver.model.template.Teleports"/>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/item">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:item">
<jaxb:class ref="com.l2jserver.model.template.ItemTemplate"/>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/npc">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:npc">
<jaxb:class ref="com.l2jserver.model.template.NPCTemplate"/>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="zones"> <jaxb:bindings scd="x-schema::tns" xmlns:tns="zones">
<jaxb:schemaBindings map="false"/> <jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:zones"> <jaxb:bindings scd="tns:zones">
@@ -47,23 +65,5 @@ Generated on: 2011.12.31 at 03:24:00 AM BRST
<jaxb:class ref="com.l2jserver.model.template.ZoneType"/> <jaxb:class ref="com.l2jserver.model.template.ZoneType"/>
</jaxb:bindings> </jaxb:bindings>
</jaxb:bindings> </jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/item">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:item">
<jaxb:class ref="com.l2jserver.model.template.ItemTemplate"/>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/teleport">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:teleports">
<jaxb:class ref="com.l2jserver.model.template.Teleports"/>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://schemas.l2jserver2.com/npc">
<jaxb:schemaBindings map="false"/>
<jaxb:bindings scd="tns:npc">
<jaxb:class ref="com.l2jserver.model.template.NPCTemplate"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings> </jaxb:bindings>

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // 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
// //

View File

@@ -78,20 +78,32 @@ public class SM_NPC_INFO extends AbstractServerPacket {
buffer.writeDouble(0x01);// TODO buffer.writeDouble(0x01);// TODO
buffer.writeDouble(template.getInfo().getCollision().getRadius()); buffer.writeDouble(template.getInfo().getCollision().getRadius());
buffer.writeDouble(template.getInfo().getCollision().getHeigth()); buffer.writeDouble(template.getInfo().getCollision().getHeigth());
if (template.getInfo().getItem() != null) {
buffer.writeInt((template.getInfo().getItem().getRightHand() != null ? template buffer.writeInt((template.getInfo().getItem().getRightHand() != null ? template
.getInfo().getItem().getRightHand().getID() .getInfo().getItem().getRightHand().getID()
: 0x00)); : 0x00));
} else {
buffer.writeInt(0x00);
}
buffer.writeInt(0x00); // chest buffer.writeInt(0x00); // chest
if (template.getInfo().getItem() != null) {
buffer.writeInt((template.getInfo().getItem().getLeftHand() != null ? template buffer.writeInt((template.getInfo().getItem().getLeftHand() != null ? template
.getInfo().getItem().getLeftHand().getID() .getInfo().getItem().getLeftHand().getID()
: 0x00)); : 0x00));
} else {
buffer.writeInt(0x00);
}
buffer.writeByte(1); // name above char 1=true ... ?? buffer.writeByte(1); // name above char 1=true ... ??
buffer.writeByte(0x00); // is running buffer.writeByte(0x00); // is running
buffer.writeByte((npc.isAttacking() ? 0x01 : 0x00)); // is in combat buffer.writeByte((npc.isAttacking() ? 0x01 : 0x00)); // is in combat
buffer.writeByte((npc.isDead() ? 0x01 : 0x00)); // is like dead (faking) buffer.writeByte((npc.isDead() ? 0x01 : 0x00)); // is like dead (faking)
buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned
BufferUtils.writeString(buffer, template.getInfo().getName().getValue()); BufferUtils.writeString(buffer,
BufferUtils.writeString(buffer, template.getInfo().getTitle().getValue()); (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); // Title color 0=client default
buffer.writeInt(0x00); // pvp flag buffer.writeInt(0x00); // pvp flag
buffer.writeInt(0x00); // karma buffer.writeInt(0x00); // karma
@@ -110,9 +122,11 @@ public class SM_NPC_INFO extends AbstractServerPacket {
buffer.writeInt(0x00); // C6 -- is flying buffer.writeInt(0x00); // C6 -- is flying
buffer.writeInt(0x00); // unk buffer.writeInt(0x00); // unk
buffer.writeInt(0x00);// CT1.5 Pet form and skills, Color effect buffer.writeInt(0x00);// CT1.5 Pet form and skills, Color effect
buffer.writeByte((template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide buffer.writeByte((template.getInfo().getName() != null
&& template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide
// name // name
buffer.writeByte((template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide buffer.writeByte((template.getInfo().getName() != null
&& template.getInfo().getName().isDisplay() ? 0x01 : 0x00)); // hide
// name, // name,
// again // again

View File

@@ -16,12 +16,14 @@
*/ */
package com.l2jserver.service.game.template; package com.l2jserver.service.game.template;
import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.FileVisitResult; import java.nio.file.FileVisitResult;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor; import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.List; import java.util.List;
@@ -181,6 +183,22 @@ public class XMLTemplateService extends
log.info("Scanning {} for XML templates", templatePath); log.info("Scanning {} for XML templates", templatePath);
final List<Source> schemas = CollectionFactory.newList(); final List<Source> 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<Path> templateList = CollectionFactory.newList(); final List<Path> templateList = CollectionFactory.newList();
final boolean includeSchemas = config.isSchemaValidationEnabled(); final boolean includeSchemas = config.isSchemaValidationEnabled();
Files.walkFileTree(templatePath, new SimpleFileVisitor<Path>() { Files.walkFileTree(templatePath, new SimpleFileVisitor<Path>() {
@@ -188,9 +206,7 @@ public class XMLTemplateService extends
public FileVisitResult visitFile(Path file, public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException { BasicFileAttributes attrs) throws IOException {
final String name = file.getFileName().toString(); final String name = file.getFileName().toString();
if (name.endsWith(".xsd") && includeSchemas) { if (name.endsWith(".xml")) {
schemas.add(new StreamSource(file.toFile()));
} else if (name.endsWith(".xml")) {
if (name.endsWith("zones.xml")) if (name.endsWith("zones.xml"))
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
templateList.add(file); templateList.add(file);
@@ -245,7 +261,8 @@ public class XMLTemplateService extends
public void loadTemplate(Path path) throws JAXBException, IOException { public void loadTemplate(Path path) throws JAXBException, IOException {
Preconditions.checkNotNull(path, "path"); Preconditions.checkNotNull(path, "path");
log.debug("Loading template {}", path); log.debug("Loading template {}", path);
final InputStream in = Files.newInputStream(path); final InputStream in = Files.newInputStream(path,
StandardOpenOption.READ);
try { try {
Object obj = unmarshaller.unmarshal(in); Object obj = unmarshaller.unmarshal(in);
if (obj instanceof Template) { if (obj instanceof Template) {