Classic branch.

This commit is contained in:
MobiusDev
2017-05-01 10:49:52 +00:00
parent 304ca84360
commit 23c1374047
19872 changed files with 3745265 additions and 0 deletions

View File

@ -0,0 +1,84 @@
/*
* 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.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author Luis Arias
*/
public class DateRange
{
protected static final Logger _log = Logger.getLogger(DateRange.class.getName());
private final Date _startDate, _endDate;
public DateRange(Date from, Date to)
{
_startDate = from;
_endDate = to;
}
public static DateRange parse(String dateRange, DateFormat format)
{
final String[] date = dateRange.split("-");
if (date.length == 2)
{
try
{
final Date start = format.parse(date[0]);
final Date end = format.parse(date[1]);
return new DateRange(start, end);
}
catch (ParseException e)
{
_log.log(Level.WARNING, "Invalid Date Format.", e);
}
}
return new DateRange(null, null);
}
public boolean isValid()
{
return (_startDate != null) && (_endDate != null) && _startDate.before(_endDate);
}
public boolean isWithinRange(Date date)
{
return date.after(_startDate) && date.before(_endDate);
}
public Date getEndDate()
{
return _endDate;
}
public Date getStartDate()
{
return _startDate;
}
@Override
public String toString()
{
return "DateRange: From: " + getStartDate() + " To: " + getEndDate();
}
}

View File

@ -0,0 +1,27 @@
/*
* 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 interface EngineInterface
{
void addEventDrop(int[] items, int[] count, double chance, DateRange range);
void onPlayerLogin(String message, DateRange range);
}

View File

@ -0,0 +1,79 @@
/*
* 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 Zoey76
*/
public class EventDrop
{
private final int[] _itemIdList;
private final long _minCount;
private final long _maxCount;
private final int _dropChance;
public EventDrop(int[] itemIdList, long min, long max, int dropChance)
{
_itemIdList = itemIdList;
_minCount = min;
_maxCount = max;
_dropChance = dropChance;
}
public EventDrop(int itemId, long minCount, long maxCount, int dropChance)
{
_itemIdList = new int[]
{
itemId
};
_minCount = minCount;
_maxCount = maxCount;
_dropChance = dropChance;
}
/**
* @return the _itemId
*/
public int[] getItemIdList()
{
return _itemIdList;
}
/**
* @return the _minCount
*/
public long getMinCount()
{
return _minCount;
}
/**
* @return the _maxCount
*/
public long getMaxCount()
{
return _maxCount;
}
/**
* @return the _dropChance
*/
public int getDropChance()
{
return _dropChance;
}
}

View File

@ -0,0 +1,29 @@
/*
* 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 javax.script.ScriptContext;
import org.w3c.dom.Node;
/**
* @author Luis Arias
*/
public abstract class Parser
{
public abstract void parseScript(Node node, ScriptContext context);
}

View File

@ -0,0 +1,23 @@
/*
* 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;
public abstract class ParserFactory
{
public abstract Parser create();
}

View File

@ -0,0 +1,25 @@
/*
* 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;
public class ParserNotCreatedException extends Exception
{
public ParserNotCreatedException()
{
super("Parser could not be created!");
}
}

View File

@ -0,0 +1,94 @@
/*
* 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.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/**
*
*/
public class ScriptDocument
{
private static final Logger _log = Logger.getLogger(ScriptDocument.class.getName());
private Document _document;
private final String _name;
public ScriptDocument(String name, InputStream input)
{
_name = name;
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try
{
final DocumentBuilder builder = factory.newDocumentBuilder();
_document = builder.parse(input);
}
catch (SAXException sxe)
{
// Error generated during parsing)
Exception x = sxe;
if (sxe.getException() != null)
{
x = sxe.getException();
}
_log.warning(getClass().getSimpleName() + ": " + x.getMessage());
}
catch (ParserConfigurationException pce)
{
// Parser with specified options can't be built
_log.log(Level.WARNING, "", pce);
}
catch (IOException ioe)
{
// I/O error
_log.log(Level.WARNING, "", ioe);
}
}
public Document getDocument()
{
return _document;
}
/**
* @return Returns the _name.
*/
public String getName()
{
return _name;
}
@Override
public String toString()
{
return _name;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.util.Hashtable;
/**
* @author Luis Arias
*/
public class ScriptEngine
{
public static final Hashtable<String, ParserFactory> parserFactories = new Hashtable<>();
protected static Parser createParser(String name) throws ParserNotCreatedException
{
ParserFactory s = parserFactories.get(name);
if (s == null) // shape not found
{
try
{
Class.forName("com.l2jmobius.gameserver.script." + name);
// By now the static block with no function would
// have been executed if the shape was found.
// the shape is expected to have put its factory
// in the hashtable.
s = parserFactories.get(name);
if (s == null) // if the shape factory is not there even now
{
throw (new ParserNotCreatedException());
}
}
catch (ClassNotFoundException e)
{
// We'll throw an exception to indicate that
// the shape could not be created
throw (new ParserNotCreatedException());
}
}
return (s.create());
}
}