Partial sync latest Test changes to HighFive.
This commit is contained in:
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.script;
|
||||
|
||||
/**
|
||||
* @author Luis Arias
|
||||
*/
|
||||
public class IntList
|
||||
{
|
||||
public static int[] parse(String range)
|
||||
{
|
||||
if (range.contains("-"))
|
||||
{
|
||||
return getIntegerRange(range.split("-"));
|
||||
}
|
||||
else if (range.contains(","))
|
||||
{
|
||||
return getIntegerList(range.split(","));
|
||||
}
|
||||
|
||||
final int[] list =
|
||||
{
|
||||
getInt(range)
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
private static int getInt(String number)
|
||||
{
|
||||
return Integer.parseInt(number);
|
||||
}
|
||||
|
||||
private static int[] getIntegerList(String[] numbers)
|
||||
{
|
||||
final int[] list = new int[numbers.length];
|
||||
for (int i = 0; i < list.length; i++)
|
||||
{
|
||||
list[i] = getInt(numbers[i]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static int[] getIntegerRange(String[] numbers)
|
||||
{
|
||||
final int min = getInt(numbers[0]);
|
||||
final int max = getInt(numbers[1]);
|
||||
final int[] list = new int[(max - min) + 1];
|
||||
for (int i = 0; i < list.length; i++)
|
||||
{
|
||||
list[i] = min + i;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.script;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
|
||||
/**
|
||||
* @author Luis Arias
|
||||
*/
|
||||
public class ScriptPackage
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(ScriptPackage.class.getName());
|
||||
|
||||
private final List<ScriptDocument> _scriptFiles = new ArrayList<>();
|
||||
private final List<String> _otherFiles = new ArrayList<>();
|
||||
private final String _name;
|
||||
|
||||
public ScriptPackage(ZipFile pack)
|
||||
{
|
||||
_name = pack.getName();
|
||||
addFiles(pack);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the otherFiles.
|
||||
*/
|
||||
public List<String> getOtherFiles()
|
||||
{
|
||||
return _otherFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the scriptFiles.
|
||||
*/
|
||||
public List<ScriptDocument> getScriptFiles()
|
||||
{
|
||||
return _scriptFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pack
|
||||
*/
|
||||
private void addFiles(ZipFile pack)
|
||||
{
|
||||
for (Enumeration<? extends ZipEntry> e = pack.entries(); e.hasMoreElements();)
|
||||
{
|
||||
final ZipEntry entry = e.nextElement();
|
||||
if (entry.getName().endsWith(".xml"))
|
||||
{
|
||||
try
|
||||
{
|
||||
_scriptFiles.add(new ScriptDocument(entry.getName(), pack.getInputStream(entry)));
|
||||
}
|
||||
catch (IOException io)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": " + io.getMessage());
|
||||
}
|
||||
}
|
||||
else if (!entry.isDirectory())
|
||||
{
|
||||
_otherFiles.add(entry.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if (getScriptFiles().isEmpty() && getOtherFiles().isEmpty())
|
||||
{
|
||||
return "Empty Package.";
|
||||
}
|
||||
|
||||
final StringBuilder out = new StringBuilder();
|
||||
out.append("Package Name: ");
|
||||
out.append(getName());
|
||||
out.append(Config.EOL);
|
||||
|
||||
if (!getScriptFiles().isEmpty())
|
||||
{
|
||||
out.append("Xml Script Files..." + Config.EOL);
|
||||
for (ScriptDocument script : getScriptFiles())
|
||||
{
|
||||
out.append(script.getName());
|
||||
out.append(Config.EOL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!getOtherFiles().isEmpty())
|
||||
{
|
||||
out.append("Other Files..." + Config.EOL);
|
||||
for (String fileName : getOtherFiles())
|
||||
{
|
||||
out.append(fileName);
|
||||
out.append(Config.EOL);
|
||||
}
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.script;
|
||||
|
||||
/**
|
||||
* @author -Nemesiss-
|
||||
*/
|
||||
public class ShortList
|
||||
{
|
||||
public static short[] parse(String range)
|
||||
{
|
||||
if (range.contains("-"))
|
||||
{
|
||||
return getShortList(range.split("-"));
|
||||
}
|
||||
else if (range.contains(","))
|
||||
{
|
||||
return getShortList(range.split(","));
|
||||
}
|
||||
|
||||
final short[] list =
|
||||
{
|
||||
getShort(range)
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
private static short getShort(String number)
|
||||
{
|
||||
return Short.parseShort(number);
|
||||
}
|
||||
|
||||
private static short[] getShortList(String[] numbers)
|
||||
{
|
||||
final short[] list = new short[numbers.length];
|
||||
for (int i = 0; i < list.length; i++)
|
||||
{
|
||||
list[i] = getShort(numbers[i]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user